babylon.d.txt 3.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053
  1. declare module BABYLON {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module BABYLON {
  50. /**
  51. * A class serves as a medium between the observable and its observers
  52. */
  53. export class EventState {
  54. /**
  55. * Create a new EventState
  56. * @param mask defines the mask associated with this state
  57. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  58. * @param target defines the original target of the state
  59. * @param currentTarget defines the current target of the state
  60. */
  61. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  62. /**
  63. * Initialize the current event state
  64. * @param mask defines the mask associated with this state
  65. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66. * @param target defines the original target of the state
  67. * @param currentTarget defines the current target of the state
  68. * @returns the current event state
  69. */
  70. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  71. /**
  72. * An Observer can set this property to true to prevent subsequent observers of being notified
  73. */
  74. skipNextObservers: boolean;
  75. /**
  76. * Get the mask value that were used to trigger the event corresponding to this EventState object
  77. */
  78. mask: number;
  79. /**
  80. * The object that originally notified the event
  81. */
  82. target?: any;
  83. /**
  84. * The current object in the bubbling phase
  85. */
  86. currentTarget?: any;
  87. /**
  88. * This will be populated with the return value of the last function that was executed.
  89. * If it is the first function in the callback chain it will be the event data.
  90. */
  91. lastReturnValue?: any;
  92. }
  93. /**
  94. * Represent an Observer registered to a given Observable object.
  95. */
  96. export class Observer<T> {
  97. /**
  98. * Defines the callback to call when the observer is notified
  99. */
  100. callback: (eventData: T, eventState: EventState) => void;
  101. /**
  102. * Defines the mask of the observer (used to filter notifications)
  103. */
  104. mask: number;
  105. /**
  106. * Defines the current scope used to restore the JS context
  107. */
  108. scope: any;
  109. /** @hidden */ private _willBeUnregistered: boolean;
  110. /**
  111. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  112. */
  113. unregisterOnNextCall: boolean;
  114. /**
  115. * Creates a new observer
  116. * @param callback defines the callback to call when the observer is notified
  117. * @param mask defines the mask of the observer (used to filter notifications)
  118. * @param scope defines the current scope used to restore the JS context
  119. */
  120. constructor(
  121. /**
  122. * Defines the callback to call when the observer is notified
  123. */
  124. callback: (eventData: T, eventState: EventState) => void,
  125. /**
  126. * Defines the mask of the observer (used to filter notifications)
  127. */
  128. mask: number,
  129. /**
  130. * Defines the current scope used to restore the JS context
  131. */
  132. scope?: any);
  133. }
  134. /**
  135. * Represent a list of observers registered to multiple Observables object.
  136. */
  137. export class MultiObserver<T> {
  138. private _observers;
  139. private _observables;
  140. /**
  141. * Release associated resources
  142. */
  143. dispose(): void;
  144. /**
  145. * Raise a callback when one of the observable will notify
  146. * @param observables defines a list of observables to watch
  147. * @param callback defines the callback to call on notification
  148. * @param mask defines the mask used to filter notifications
  149. * @param scope defines the current scope used to restore the JS context
  150. * @returns the new MultiObserver
  151. */
  152. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  153. }
  154. /**
  155. * The Observable class is a simple implementation of the Observable pattern.
  156. *
  157. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  158. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  159. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  160. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  161. */
  162. export class Observable<T> {
  163. private _observers;
  164. private _eventState;
  165. private _onObserverAdded;
  166. /**
  167. * Gets the list of observers
  168. */
  169. readonly observers: Array<Observer<T>>;
  170. /**
  171. * Creates a new observable
  172. * @param onObserverAdded defines a callback to call when a new observer is added
  173. */
  174. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  175. /**
  176. * Create a new Observer with the specified callback
  177. * @param callback the callback that will be executed for that Observer
  178. * @param mask the mask used to filter observers
  179. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  180. * @param scope optional scope for the callback to be called from
  181. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  182. * @returns the new observer created for the callback
  183. */
  184. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  185. /**
  186. * Create a new Observer with the specified callback and unregisters after the next notification
  187. * @param callback the callback that will be executed for that Observer
  188. * @returns the new observer created for the callback
  189. */
  190. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  191. /**
  192. * Remove an Observer from the Observable object
  193. * @param observer the instance of the Observer to remove
  194. * @returns false if it doesn't belong to this Observable
  195. */
  196. remove(observer: Nullable<Observer<T>>): boolean;
  197. /**
  198. * Remove a callback from the Observable object
  199. * @param callback the callback to remove
  200. * @param scope optional scope. If used only the callbacks with this scope will be removed
  201. * @returns false if it doesn't belong to this Observable
  202. */
  203. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  204. private _deferUnregister;
  205. private _remove;
  206. /**
  207. * Moves the observable to the top of the observer list making it get called first when notified
  208. * @param observer the observer to move
  209. */
  210. makeObserverTopPriority(observer: Observer<T>): void;
  211. /**
  212. * Moves the observable to the bottom of the observer list making it get called last when notified
  213. * @param observer the observer to move
  214. */
  215. makeObserverBottomPriority(observer: Observer<T>): void;
  216. /**
  217. * Notify all Observers by calling their respective callback with the given data
  218. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  219. * @param eventData defines the data to send to all observers
  220. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  221. * @param target defines the original target of the state
  222. * @param currentTarget defines the current target of the state
  223. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  224. */
  225. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  226. /**
  227. * Calling this will execute each callback, expecting it to be a promise or return a value.
  228. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  229. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  230. * and it is crucial that all callbacks will be executed.
  231. * The order of the callbacks is kept, callbacks are not executed parallel.
  232. *
  233. * @param eventData The data to be sent to each callback
  234. * @param mask is used to filter observers defaults to -1
  235. * @param target defines the callback target (see EventState)
  236. * @param currentTarget defines he current object in the bubbling phase
  237. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  238. */
  239. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  240. /**
  241. * Notify a specific observer
  242. * @param observer defines the observer to notify
  243. * @param eventData defines the data to be sent to each callback
  244. * @param mask is used to filter observers defaults to -1
  245. */
  246. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  247. /**
  248. * Gets a boolean indicating if the observable has at least one observer
  249. * @returns true is the Observable has at least one Observer registered
  250. */
  251. hasObservers(): boolean;
  252. /**
  253. * Clear the list of observers
  254. */
  255. clear(): void;
  256. /**
  257. * Clone the current observable
  258. * @returns a new observable
  259. */
  260. clone(): Observable<T>;
  261. /**
  262. * Does this observable handles observer registered with a given mask
  263. * @param mask defines the mask to be tested
  264. * @return whether or not one observer registered with the given mask is handeled
  265. **/
  266. hasSpecificMask(mask?: number): boolean;
  267. }
  268. }
  269. declare module BABYLON {
  270. /**
  271. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  272. * Babylon.js
  273. */
  274. export class DomManagement {
  275. /**
  276. * Checks if the window object exists
  277. * @returns true if the window object exists
  278. */
  279. static IsWindowObjectExist(): boolean;
  280. /**
  281. * Extracts text content from a DOM element hierarchy
  282. * @param element defines the root element
  283. * @returns a string
  284. */
  285. static GetDOMTextContent(element: HTMLElement): string;
  286. }
  287. }
  288. declare module BABYLON {
  289. /**
  290. * Logger used througouht the application to allow configuration of
  291. * the log level required for the messages.
  292. */
  293. export class Logger {
  294. /**
  295. * No log
  296. */
  297. static readonly NoneLogLevel: number;
  298. /**
  299. * Only message logs
  300. */
  301. static readonly MessageLogLevel: number;
  302. /**
  303. * Only warning logs
  304. */
  305. static readonly WarningLogLevel: number;
  306. /**
  307. * Only error logs
  308. */
  309. static readonly ErrorLogLevel: number;
  310. /**
  311. * All logs
  312. */
  313. static readonly AllLogLevel: number;
  314. private static _LogCache;
  315. /**
  316. * Gets a value indicating the number of loading errors
  317. * @ignorenaming
  318. */
  319. static errorsCount: number;
  320. /**
  321. * Callback called when a new log is added
  322. */
  323. static OnNewCacheEntry: (entry: string) => void;
  324. private static _AddLogEntry;
  325. private static _FormatMessage;
  326. private static _LogDisabled;
  327. private static _LogEnabled;
  328. private static _WarnDisabled;
  329. private static _WarnEnabled;
  330. private static _ErrorDisabled;
  331. private static _ErrorEnabled;
  332. /**
  333. * Log a message to the console
  334. */
  335. static Log: (message: string) => void;
  336. /**
  337. * Write a warning message to the console
  338. */
  339. static Warn: (message: string) => void;
  340. /**
  341. * Write an error message to the console
  342. */
  343. static Error: (message: string) => void;
  344. /**
  345. * Gets current log cache (list of logs)
  346. */
  347. static readonly LogCache: string;
  348. /**
  349. * Clears the log cache
  350. */
  351. static ClearLogCache(): void;
  352. /**
  353. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  354. */
  355. static LogLevels: number;
  356. }
  357. }
  358. declare module BABYLON {
  359. /** @hidden */
  360. export class _TypeStore {
  361. /** @hidden */
  362. static RegisteredTypes: {
  363. [key: string]: Object;
  364. };
  365. /** @hidden */
  366. static GetClass(fqdn: string): any;
  367. }
  368. }
  369. declare module BABYLON {
  370. /**
  371. * Class containing a set of static utilities functions for deep copy.
  372. */
  373. export class DeepCopier {
  374. /**
  375. * Tries to copy an object by duplicating every property
  376. * @param source defines the source object
  377. * @param destination defines the target object
  378. * @param doNotCopyList defines a list of properties to avoid
  379. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  380. */
  381. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  382. }
  383. }
  384. declare module BABYLON {
  385. /**
  386. * Class containing a set of static utilities functions for precision date
  387. */
  388. export class PrecisionDate {
  389. /**
  390. * Gets either window.performance.now() if supported or Date.now() else
  391. */
  392. static readonly Now: number;
  393. }
  394. }
  395. declare module BABYLON {
  396. /** @hidden */
  397. export class _DevTools {
  398. static WarnImport(name: string): string;
  399. }
  400. }
  401. declare module BABYLON {
  402. /**
  403. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  404. */
  405. export class WebRequest {
  406. private _xhr;
  407. /**
  408. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  409. * i.e. when loading files, where the server/service expects an Authorization header
  410. */
  411. static CustomRequestHeaders: {
  412. [key: string]: string;
  413. };
  414. /**
  415. * Add callback functions in this array to update all the requests before they get sent to the network
  416. */
  417. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  418. private _injectCustomRequestHeaders;
  419. /**
  420. * Gets or sets a function to be called when loading progress changes
  421. */
  422. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  423. /**
  424. * Returns client's state
  425. */
  426. readonly readyState: number;
  427. /**
  428. * Returns client's status
  429. */
  430. readonly status: number;
  431. /**
  432. * Returns client's status as a text
  433. */
  434. readonly statusText: string;
  435. /**
  436. * Returns client's response
  437. */
  438. readonly response: any;
  439. /**
  440. * Returns client's response url
  441. */
  442. readonly responseURL: string;
  443. /**
  444. * Returns client's response as text
  445. */
  446. readonly responseText: string;
  447. /**
  448. * Gets or sets the expected response type
  449. */
  450. responseType: XMLHttpRequestResponseType;
  451. /** @hidden */
  452. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  453. /** @hidden */
  454. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  455. /**
  456. * Cancels any network activity
  457. */
  458. abort(): void;
  459. /**
  460. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  461. * @param body defines an optional request body
  462. */
  463. send(body?: Document | BodyInit | null): void;
  464. /**
  465. * Sets the request method, request URL
  466. * @param method defines the method to use (GET, POST, etc..)
  467. * @param url defines the url to connect with
  468. */
  469. open(method: string, url: string): void;
  470. }
  471. }
  472. declare module BABYLON {
  473. /**
  474. * File request interface
  475. */
  476. export interface IFileRequest {
  477. /**
  478. * Raised when the request is complete (success or error).
  479. */
  480. onCompleteObservable: Observable<IFileRequest>;
  481. /**
  482. * Aborts the request for a file.
  483. */
  484. abort: () => void;
  485. }
  486. }
  487. declare module BABYLON {
  488. /**
  489. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  490. */
  491. export class PerformanceMonitor {
  492. private _enabled;
  493. private _rollingFrameTime;
  494. private _lastFrameTimeMs;
  495. /**
  496. * constructor
  497. * @param frameSampleSize The number of samples required to saturate the sliding window
  498. */
  499. constructor(frameSampleSize?: number);
  500. /**
  501. * Samples current frame
  502. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  503. */
  504. sampleFrame(timeMs?: number): void;
  505. /**
  506. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  507. */
  508. readonly averageFrameTime: number;
  509. /**
  510. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  511. */
  512. readonly averageFrameTimeVariance: number;
  513. /**
  514. * Returns the frame time of the most recent frame
  515. */
  516. readonly instantaneousFrameTime: number;
  517. /**
  518. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  519. */
  520. readonly averageFPS: number;
  521. /**
  522. * Returns the average framerate in frames per second using the most recent frame time
  523. */
  524. readonly instantaneousFPS: number;
  525. /**
  526. * Returns true if enough samples have been taken to completely fill the sliding window
  527. */
  528. readonly isSaturated: boolean;
  529. /**
  530. * Enables contributions to the sliding window sample set
  531. */
  532. enable(): void;
  533. /**
  534. * Disables contributions to the sliding window sample set
  535. * Samples will not be interpolated over the disabled period
  536. */
  537. disable(): void;
  538. /**
  539. * Returns true if sampling is enabled
  540. */
  541. readonly isEnabled: boolean;
  542. /**
  543. * Resets performance monitor
  544. */
  545. reset(): void;
  546. }
  547. /**
  548. * RollingAverage
  549. *
  550. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  551. */
  552. export class RollingAverage {
  553. /**
  554. * Current average
  555. */
  556. average: number;
  557. /**
  558. * Current variance
  559. */
  560. variance: number;
  561. protected _samples: Array<number>;
  562. protected _sampleCount: number;
  563. protected _pos: number;
  564. protected _m2: number;
  565. /**
  566. * constructor
  567. * @param length The number of samples required to saturate the sliding window
  568. */
  569. constructor(length: number);
  570. /**
  571. * Adds a sample to the sample set
  572. * @param v The sample value
  573. */
  574. add(v: number): void;
  575. /**
  576. * Returns previously added values or null if outside of history or outside the sliding window domain
  577. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  578. * @return Value previously recorded with add() or null if outside of range
  579. */
  580. history(i: number): number;
  581. /**
  582. * Returns true if enough samples have been taken to completely fill the sliding window
  583. * @return true if sample-set saturated
  584. */
  585. isSaturated(): boolean;
  586. /**
  587. * Resets the rolling average (equivalent to 0 samples taken so far)
  588. */
  589. reset(): void;
  590. /**
  591. * Wraps a value around the sample range boundaries
  592. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  593. * @return Wrapped position in sample range
  594. */
  595. protected _wrapPosition(i: number): number;
  596. }
  597. }
  598. declare module BABYLON {
  599. /**
  600. * This class implement a typical dictionary using a string as key and the generic type T as value.
  601. * The underlying implementation relies on an associative array to ensure the best performances.
  602. * The value can be anything including 'null' but except 'undefined'
  603. */
  604. export class StringDictionary<T> {
  605. /**
  606. * This will clear this dictionary and copy the content from the 'source' one.
  607. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  608. * @param source the dictionary to take the content from and copy to this dictionary
  609. */
  610. copyFrom(source: StringDictionary<T>): void;
  611. /**
  612. * Get a value based from its key
  613. * @param key the given key to get the matching value from
  614. * @return the value if found, otherwise undefined is returned
  615. */
  616. get(key: string): T | undefined;
  617. /**
  618. * Get a value from its key or add it if it doesn't exist.
  619. * This method will ensure you that a given key/data will be present in the dictionary.
  620. * @param key the given key to get the matching value from
  621. * @param factory the factory that will create the value if the key is not present in the dictionary.
  622. * The factory will only be invoked if there's no data for the given key.
  623. * @return the value corresponding to the key.
  624. */
  625. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  626. /**
  627. * Get a value from its key if present in the dictionary otherwise add it
  628. * @param key the key to get the value from
  629. * @param val if there's no such key/value pair in the dictionary add it with this value
  630. * @return the value corresponding to the key
  631. */
  632. getOrAdd(key: string, val: T): T;
  633. /**
  634. * Check if there's a given key in the dictionary
  635. * @param key the key to check for
  636. * @return true if the key is present, false otherwise
  637. */
  638. contains(key: string): boolean;
  639. /**
  640. * Add a new key and its corresponding value
  641. * @param key the key to add
  642. * @param value the value corresponding to the key
  643. * @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
  644. */
  645. add(key: string, value: T): boolean;
  646. /**
  647. * Update a specific value associated to a key
  648. * @param key defines the key to use
  649. * @param value defines the value to store
  650. * @returns true if the value was updated (or false if the key was not found)
  651. */
  652. set(key: string, value: T): boolean;
  653. /**
  654. * Get the element of the given key and remove it from the dictionary
  655. * @param key defines the key to search
  656. * @returns the value associated with the key or null if not found
  657. */
  658. getAndRemove(key: string): Nullable<T>;
  659. /**
  660. * Remove a key/value from the dictionary.
  661. * @param key the key to remove
  662. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  663. */
  664. remove(key: string): boolean;
  665. /**
  666. * Clear the whole content of the dictionary
  667. */
  668. clear(): void;
  669. /**
  670. * Gets the current count
  671. */
  672. readonly count: number;
  673. /**
  674. * Execute a callback on each key/val of the dictionary.
  675. * Note that you can remove any element in this dictionary in the callback implementation
  676. * @param callback the callback to execute on a given key/value pair
  677. */
  678. forEach(callback: (key: string, val: T) => void): void;
  679. /**
  680. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  681. * If the callback returns null or undefined the method will iterate to the next key/value pair
  682. * Note that you can remove any element in this dictionary in the callback implementation
  683. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  684. * @returns the first item
  685. */
  686. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  687. private _count;
  688. private _data;
  689. }
  690. }
  691. declare module BABYLON {
  692. /**
  693. * Class used to store gfx data (like WebGLBuffer)
  694. */
  695. export class DataBuffer {
  696. /**
  697. * Gets or sets the number of objects referencing this buffer
  698. */
  699. references: number;
  700. /** Gets or sets the size of the underlying buffer */
  701. capacity: number;
  702. /**
  703. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  704. */
  705. is32Bits: boolean;
  706. /**
  707. * Gets the underlying buffer
  708. */
  709. readonly underlyingResource: any;
  710. }
  711. }
  712. declare module BABYLON {
  713. /**
  714. * Class used to store data that will be store in GPU memory
  715. */
  716. export class Buffer {
  717. private _engine;
  718. private _buffer;
  719. /** @hidden */ private _data: Nullable<DataArray>;
  720. private _updatable;
  721. private _instanced;
  722. /**
  723. * Gets the byte stride.
  724. */
  725. readonly byteStride: number;
  726. /**
  727. * Constructor
  728. * @param engine the engine
  729. * @param data the data to use for this buffer
  730. * @param updatable whether the data is updatable
  731. * @param stride the stride (optional)
  732. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  733. * @param instanced whether the buffer is instanced (optional)
  734. * @param useBytes set to true if the stride in in bytes (optional)
  735. */
  736. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  737. /**
  738. * Create a new VertexBuffer based on the current buffer
  739. * @param kind defines the vertex buffer kind (position, normal, etc.)
  740. * @param offset defines offset in the buffer (0 by default)
  741. * @param size defines the size in floats of attributes (position is 3 for instance)
  742. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  743. * @param instanced defines if the vertex buffer contains indexed data
  744. * @param useBytes defines if the offset and stride are in bytes
  745. * @returns the new vertex buffer
  746. */
  747. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  748. /**
  749. * Gets a boolean indicating if the Buffer is updatable?
  750. * @returns true if the buffer is updatable
  751. */
  752. isUpdatable(): boolean;
  753. /**
  754. * Gets current buffer's data
  755. * @returns a DataArray or null
  756. */
  757. getData(): Nullable<DataArray>;
  758. /**
  759. * Gets underlying native buffer
  760. * @returns underlying native buffer
  761. */
  762. getBuffer(): Nullable<DataBuffer>;
  763. /**
  764. * Gets the stride in float32 units (i.e. byte stride / 4).
  765. * May not be an integer if the byte stride is not divisible by 4.
  766. * DEPRECATED. Use byteStride instead.
  767. * @returns the stride in float32 units
  768. */
  769. getStrideSize(): number;
  770. /**
  771. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  772. * @param data defines the data to store
  773. */
  774. create(data?: Nullable<DataArray>): void;
  775. /** @hidden */ private _rebuild(): void;
  776. /**
  777. * Update current buffer data
  778. * @param data defines the data to store
  779. */
  780. update(data: DataArray): void;
  781. /**
  782. * Updates the data directly.
  783. * @param data the new data
  784. * @param offset the new offset
  785. * @param vertexCount the vertex count (optional)
  786. * @param useBytes set to true if the offset is in bytes
  787. */
  788. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  789. /**
  790. * Release all resources
  791. */
  792. dispose(): void;
  793. }
  794. /**
  795. * Specialized buffer used to store vertex data
  796. */
  797. export class VertexBuffer {
  798. /** @hidden */ private _buffer: Buffer;
  799. private _kind;
  800. private _size;
  801. private _ownsBuffer;
  802. private _instanced;
  803. private _instanceDivisor;
  804. /**
  805. * The byte type.
  806. */
  807. static readonly BYTE: number;
  808. /**
  809. * The unsigned byte type.
  810. */
  811. static readonly UNSIGNED_BYTE: number;
  812. /**
  813. * The short type.
  814. */
  815. static readonly SHORT: number;
  816. /**
  817. * The unsigned short type.
  818. */
  819. static readonly UNSIGNED_SHORT: number;
  820. /**
  821. * The integer type.
  822. */
  823. static readonly INT: number;
  824. /**
  825. * The unsigned integer type.
  826. */
  827. static readonly UNSIGNED_INT: number;
  828. /**
  829. * The float type.
  830. */
  831. static readonly FLOAT: number;
  832. /**
  833. * Gets or sets the instance divisor when in instanced mode
  834. */
  835. instanceDivisor: number;
  836. /**
  837. * Gets the byte stride.
  838. */
  839. readonly byteStride: number;
  840. /**
  841. * Gets the byte offset.
  842. */
  843. readonly byteOffset: number;
  844. /**
  845. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  846. */
  847. readonly normalized: boolean;
  848. /**
  849. * Gets the data type of each component in the array.
  850. */
  851. readonly type: number;
  852. /**
  853. * Constructor
  854. * @param engine the engine
  855. * @param data the data to use for this vertex buffer
  856. * @param kind the vertex buffer kind
  857. * @param updatable whether the data is updatable
  858. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  859. * @param stride the stride (optional)
  860. * @param instanced whether the buffer is instanced (optional)
  861. * @param offset the offset of the data (optional)
  862. * @param size the number of components (optional)
  863. * @param type the type of the component (optional)
  864. * @param normalized whether the data contains normalized data (optional)
  865. * @param useBytes set to true if stride and offset are in bytes (optional)
  866. */
  867. 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);
  868. /** @hidden */ private _rebuild(): void;
  869. /**
  870. * Returns the kind of the VertexBuffer (string)
  871. * @returns a string
  872. */
  873. getKind(): string;
  874. /**
  875. * Gets a boolean indicating if the VertexBuffer is updatable?
  876. * @returns true if the buffer is updatable
  877. */
  878. isUpdatable(): boolean;
  879. /**
  880. * Gets current buffer's data
  881. * @returns a DataArray or null
  882. */
  883. getData(): Nullable<DataArray>;
  884. /**
  885. * Gets underlying native buffer
  886. * @returns underlying native buffer
  887. */
  888. getBuffer(): Nullable<DataBuffer>;
  889. /**
  890. * Gets the stride in float32 units (i.e. byte stride / 4).
  891. * May not be an integer if the byte stride is not divisible by 4.
  892. * DEPRECATED. Use byteStride instead.
  893. * @returns the stride in float32 units
  894. */
  895. getStrideSize(): number;
  896. /**
  897. * Returns the offset as a multiple of the type byte length.
  898. * DEPRECATED. Use byteOffset instead.
  899. * @returns the offset in bytes
  900. */
  901. getOffset(): number;
  902. /**
  903. * Returns the number of components per vertex attribute (integer)
  904. * @returns the size in float
  905. */
  906. getSize(): number;
  907. /**
  908. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  909. * @returns true if this buffer is instanced
  910. */
  911. getIsInstanced(): boolean;
  912. /**
  913. * Returns the instancing divisor, zero for non-instanced (integer).
  914. * @returns a number
  915. */
  916. getInstanceDivisor(): number;
  917. /**
  918. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  919. * @param data defines the data to store
  920. */
  921. create(data?: DataArray): void;
  922. /**
  923. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  924. * This function will create a new buffer if the current one is not updatable
  925. * @param data defines the data to store
  926. */
  927. update(data: DataArray): void;
  928. /**
  929. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  930. * Returns the directly updated WebGLBuffer.
  931. * @param data the new data
  932. * @param offset the new offset
  933. * @param useBytes set to true if the offset is in bytes
  934. */
  935. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  936. /**
  937. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  938. */
  939. dispose(): void;
  940. /**
  941. * Enumerates each value of this vertex buffer as numbers.
  942. * @param count the number of values to enumerate
  943. * @param callback the callback function called for each value
  944. */
  945. forEach(count: number, callback: (value: number, index: number) => void): void;
  946. /**
  947. * Positions
  948. */
  949. static readonly PositionKind: string;
  950. /**
  951. * Normals
  952. */
  953. static readonly NormalKind: string;
  954. /**
  955. * Tangents
  956. */
  957. static readonly TangentKind: string;
  958. /**
  959. * Texture coordinates
  960. */
  961. static readonly UVKind: string;
  962. /**
  963. * Texture coordinates 2
  964. */
  965. static readonly UV2Kind: string;
  966. /**
  967. * Texture coordinates 3
  968. */
  969. static readonly UV3Kind: string;
  970. /**
  971. * Texture coordinates 4
  972. */
  973. static readonly UV4Kind: string;
  974. /**
  975. * Texture coordinates 5
  976. */
  977. static readonly UV5Kind: string;
  978. /**
  979. * Texture coordinates 6
  980. */
  981. static readonly UV6Kind: string;
  982. /**
  983. * Colors
  984. */
  985. static readonly ColorKind: string;
  986. /**
  987. * Matrix indices (for bones)
  988. */
  989. static readonly MatricesIndicesKind: string;
  990. /**
  991. * Matrix weights (for bones)
  992. */
  993. static readonly MatricesWeightsKind: string;
  994. /**
  995. * Additional matrix indices (for bones)
  996. */
  997. static readonly MatricesIndicesExtraKind: string;
  998. /**
  999. * Additional matrix weights (for bones)
  1000. */
  1001. static readonly MatricesWeightsExtraKind: string;
  1002. /**
  1003. * Deduces the stride given a kind.
  1004. * @param kind The kind string to deduce
  1005. * @returns The deduced stride
  1006. */
  1007. static DeduceStride(kind: string): number;
  1008. /**
  1009. * Gets the byte length of the given type.
  1010. * @param type the type
  1011. * @returns the number of bytes
  1012. */
  1013. static GetTypeByteLength(type: number): number;
  1014. /**
  1015. * Enumerates each value of the given parameters as numbers.
  1016. * @param data the data to enumerate
  1017. * @param byteOffset the byte offset of the data
  1018. * @param byteStride the byte stride of the data
  1019. * @param componentCount the number of components per element
  1020. * @param componentType the type of the component
  1021. * @param count the number of values to enumerate
  1022. * @param normalized whether the data is normalized
  1023. * @param callback the callback function called for each value
  1024. */
  1025. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  1026. private static _GetFloatValue;
  1027. }
  1028. }
  1029. declare module BABYLON {
  1030. /**
  1031. * Scalar computation library
  1032. */
  1033. export class Scalar {
  1034. /**
  1035. * Two pi constants convenient for computation.
  1036. */
  1037. static TwoPi: number;
  1038. /**
  1039. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1040. * @param a number
  1041. * @param b number
  1042. * @param epsilon (default = 1.401298E-45)
  1043. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1044. */
  1045. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1046. /**
  1047. * Returns a string : the upper case translation of the number i to hexadecimal.
  1048. * @param i number
  1049. * @returns the upper case translation of the number i to hexadecimal.
  1050. */
  1051. static ToHex(i: number): string;
  1052. /**
  1053. * Returns -1 if value is negative and +1 is value is positive.
  1054. * @param value the value
  1055. * @returns the value itself if it's equal to zero.
  1056. */
  1057. static Sign(value: number): number;
  1058. /**
  1059. * Returns the value itself if it's between min and max.
  1060. * Returns min if the value is lower than min.
  1061. * Returns max if the value is greater than max.
  1062. * @param value the value to clmap
  1063. * @param min the min value to clamp to (default: 0)
  1064. * @param max the max value to clamp to (default: 1)
  1065. * @returns the clamped value
  1066. */
  1067. static Clamp(value: number, min?: number, max?: number): number;
  1068. /**
  1069. * the log2 of value.
  1070. * @param value the value to compute log2 of
  1071. * @returns the log2 of value.
  1072. */
  1073. static Log2(value: number): number;
  1074. /**
  1075. * Loops the value, so that it is never larger than length and never smaller than 0.
  1076. *
  1077. * This is similar to the modulo operator but it works with floating point numbers.
  1078. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1079. * With t = 5 and length = 2.5, the result would be 0.0.
  1080. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1081. * @param value the value
  1082. * @param length the length
  1083. * @returns the looped value
  1084. */
  1085. static Repeat(value: number, length: number): number;
  1086. /**
  1087. * Normalize the value between 0.0 and 1.0 using min and max values
  1088. * @param value value to normalize
  1089. * @param min max to normalize between
  1090. * @param max min to normalize between
  1091. * @returns the normalized value
  1092. */
  1093. static Normalize(value: number, min: number, max: number): number;
  1094. /**
  1095. * Denormalize the value from 0.0 and 1.0 using min and max values
  1096. * @param normalized value to denormalize
  1097. * @param min max to denormalize between
  1098. * @param max min to denormalize between
  1099. * @returns the denormalized value
  1100. */
  1101. static Denormalize(normalized: number, min: number, max: number): number;
  1102. /**
  1103. * Calculates the shortest difference between two given angles given in degrees.
  1104. * @param current current angle in degrees
  1105. * @param target target angle in degrees
  1106. * @returns the delta
  1107. */
  1108. static DeltaAngle(current: number, target: number): number;
  1109. /**
  1110. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1111. * @param tx value
  1112. * @param length length
  1113. * @returns The returned value will move back and forth between 0 and length
  1114. */
  1115. static PingPong(tx: number, length: number): number;
  1116. /**
  1117. * Interpolates between min and max with smoothing at the limits.
  1118. *
  1119. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1120. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1121. * @param from from
  1122. * @param to to
  1123. * @param tx value
  1124. * @returns the smooth stepped value
  1125. */
  1126. static SmoothStep(from: number, to: number, tx: number): number;
  1127. /**
  1128. * Moves a value current towards target.
  1129. *
  1130. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1131. * Negative values of maxDelta pushes the value away from target.
  1132. * @param current current value
  1133. * @param target target value
  1134. * @param maxDelta max distance to move
  1135. * @returns resulting value
  1136. */
  1137. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1138. /**
  1139. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1140. *
  1141. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1142. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1143. * @param current current value
  1144. * @param target target value
  1145. * @param maxDelta max distance to move
  1146. * @returns resulting angle
  1147. */
  1148. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1149. /**
  1150. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1151. * @param start start value
  1152. * @param end target value
  1153. * @param amount amount to lerp between
  1154. * @returns the lerped value
  1155. */
  1156. static Lerp(start: number, end: number, amount: number): number;
  1157. /**
  1158. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1159. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1160. * @param start start value
  1161. * @param end target value
  1162. * @param amount amount to lerp between
  1163. * @returns the lerped value
  1164. */
  1165. static LerpAngle(start: number, end: number, amount: number): number;
  1166. /**
  1167. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1168. * @param a start value
  1169. * @param b target value
  1170. * @param value value between a and b
  1171. * @returns the inverseLerp value
  1172. */
  1173. static InverseLerp(a: number, b: number, value: number): number;
  1174. /**
  1175. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1176. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1177. * @param value1 spline value
  1178. * @param tangent1 spline value
  1179. * @param value2 spline value
  1180. * @param tangent2 spline value
  1181. * @param amount input value
  1182. * @returns hermite result
  1183. */
  1184. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1185. /**
  1186. * Returns a random float number between and min and max values
  1187. * @param min min value of random
  1188. * @param max max value of random
  1189. * @returns random value
  1190. */
  1191. static RandomRange(min: number, max: number): number;
  1192. /**
  1193. * This function returns percentage of a number in a given range.
  1194. *
  1195. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1196. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1197. * @param number to convert to percentage
  1198. * @param min min range
  1199. * @param max max range
  1200. * @returns the percentage
  1201. */
  1202. static RangeToPercent(number: number, min: number, max: number): number;
  1203. /**
  1204. * This function returns number that corresponds to the percentage in a given range.
  1205. *
  1206. * PercentToRange(0.34,0,100) will return 34.
  1207. * @param percent to convert to number
  1208. * @param min min range
  1209. * @param max max range
  1210. * @returns the number
  1211. */
  1212. static PercentToRange(percent: number, min: number, max: number): number;
  1213. /**
  1214. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1215. * @param angle The angle to normalize in radian.
  1216. * @return The converted angle.
  1217. */
  1218. static NormalizeRadians(angle: number): number;
  1219. }
  1220. }
  1221. declare module BABYLON {
  1222. /**
  1223. * Constant used to convert a value to gamma space
  1224. * @ignorenaming
  1225. */
  1226. export const ToGammaSpace: number;
  1227. /**
  1228. * Constant used to convert a value to linear space
  1229. * @ignorenaming
  1230. */
  1231. export const ToLinearSpace = 2.2;
  1232. /**
  1233. * Constant used to define the minimal number value in Babylon.js
  1234. * @ignorenaming
  1235. */
  1236. let Epsilon: number;
  1237. }
  1238. declare module BABYLON {
  1239. /**
  1240. * Class used to represent a viewport on screen
  1241. */
  1242. export class Viewport {
  1243. /** viewport left coordinate */
  1244. x: number;
  1245. /** viewport top coordinate */
  1246. y: number;
  1247. /**viewport width */
  1248. width: number;
  1249. /** viewport height */
  1250. height: number;
  1251. /**
  1252. * Creates a Viewport object located at (x, y) and sized (width, height)
  1253. * @param x defines viewport left coordinate
  1254. * @param y defines viewport top coordinate
  1255. * @param width defines the viewport width
  1256. * @param height defines the viewport height
  1257. */
  1258. constructor(
  1259. /** viewport left coordinate */
  1260. x: number,
  1261. /** viewport top coordinate */
  1262. y: number,
  1263. /**viewport width */
  1264. width: number,
  1265. /** viewport height */
  1266. height: number);
  1267. /**
  1268. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1269. * @param renderWidth defines the rendering width
  1270. * @param renderHeight defines the rendering height
  1271. * @returns a new Viewport
  1272. */
  1273. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1274. /**
  1275. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1276. * @param renderWidth defines the rendering width
  1277. * @param renderHeight defines the rendering height
  1278. * @param ref defines the target viewport
  1279. * @returns the current viewport
  1280. */
  1281. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1282. /**
  1283. * Returns a new Viewport copied from the current one
  1284. * @returns a new Viewport
  1285. */
  1286. clone(): Viewport;
  1287. }
  1288. }
  1289. declare module BABYLON {
  1290. /**
  1291. * Class containing a set of static utilities functions for arrays.
  1292. */
  1293. export class ArrayTools {
  1294. /**
  1295. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1296. * @param size the number of element to construct and put in the array
  1297. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1298. * @returns a new array filled with new objects
  1299. */
  1300. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1301. }
  1302. }
  1303. declare module BABYLON {
  1304. /**
  1305. * @hidden
  1306. */
  1307. export interface IColor4Like {
  1308. r: float;
  1309. g: float;
  1310. b: float;
  1311. a: float;
  1312. }
  1313. /**
  1314. * @hidden
  1315. */
  1316. export interface IColor3Like {
  1317. r: float;
  1318. g: float;
  1319. b: float;
  1320. }
  1321. /**
  1322. * @hidden
  1323. */
  1324. export interface IVector4Like {
  1325. x: float;
  1326. y: float;
  1327. z: float;
  1328. w: float;
  1329. }
  1330. /**
  1331. * @hidden
  1332. */
  1333. export interface IVector3Like {
  1334. x: float;
  1335. y: float;
  1336. z: float;
  1337. }
  1338. /**
  1339. * @hidden
  1340. */
  1341. export interface IVector2Like {
  1342. x: float;
  1343. y: float;
  1344. }
  1345. /**
  1346. * @hidden
  1347. */
  1348. export interface IMatrixLike {
  1349. toArray(): DeepImmutable<Float32Array>;
  1350. updateFlag: int;
  1351. }
  1352. /**
  1353. * @hidden
  1354. */
  1355. export interface IViewportLike {
  1356. x: float;
  1357. y: float;
  1358. width: float;
  1359. height: float;
  1360. }
  1361. /**
  1362. * @hidden
  1363. */
  1364. export interface IPlaneLike {
  1365. normal: IVector3Like;
  1366. d: float;
  1367. normalize(): void;
  1368. }
  1369. }
  1370. declare module BABYLON {
  1371. /**
  1372. * Class representing a vector containing 2 coordinates
  1373. */
  1374. export class Vector2 {
  1375. /** defines the first coordinate */
  1376. x: number;
  1377. /** defines the second coordinate */
  1378. y: number;
  1379. /**
  1380. * Creates a new Vector2 from the given x and y coordinates
  1381. * @param x defines the first coordinate
  1382. * @param y defines the second coordinate
  1383. */
  1384. constructor(
  1385. /** defines the first coordinate */
  1386. x?: number,
  1387. /** defines the second coordinate */
  1388. y?: number);
  1389. /**
  1390. * Gets a string with the Vector2 coordinates
  1391. * @returns a string with the Vector2 coordinates
  1392. */
  1393. toString(): string;
  1394. /**
  1395. * Gets class name
  1396. * @returns the string "Vector2"
  1397. */
  1398. getClassName(): string;
  1399. /**
  1400. * Gets current vector hash code
  1401. * @returns the Vector2 hash code as a number
  1402. */
  1403. getHashCode(): number;
  1404. /**
  1405. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  1406. * @param array defines the source array
  1407. * @param index defines the offset in source array
  1408. * @returns the current Vector2
  1409. */
  1410. toArray(array: FloatArray, index?: number): Vector2;
  1411. /**
  1412. * Copy the current vector to an array
  1413. * @returns a new array with 2 elements: the Vector2 coordinates.
  1414. */
  1415. asArray(): number[];
  1416. /**
  1417. * Sets the Vector2 coordinates with the given Vector2 coordinates
  1418. * @param source defines the source Vector2
  1419. * @returns the current updated Vector2
  1420. */
  1421. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  1422. /**
  1423. * Sets the Vector2 coordinates with the given floats
  1424. * @param x defines the first coordinate
  1425. * @param y defines the second coordinate
  1426. * @returns the current updated Vector2
  1427. */
  1428. copyFromFloats(x: number, y: number): Vector2;
  1429. /**
  1430. * Sets the Vector2 coordinates with the given floats
  1431. * @param x defines the first coordinate
  1432. * @param y defines the second coordinate
  1433. * @returns the current updated Vector2
  1434. */
  1435. set(x: number, y: number): Vector2;
  1436. /**
  1437. * Add another vector with the current one
  1438. * @param otherVector defines the other vector
  1439. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  1440. */
  1441. add(otherVector: DeepImmutable<Vector2>): Vector2;
  1442. /**
  1443. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  1444. * @param otherVector defines the other vector
  1445. * @param result defines the target vector
  1446. * @returns the unmodified current Vector2
  1447. */
  1448. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1449. /**
  1450. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  1451. * @param otherVector defines the other vector
  1452. * @returns the current updated Vector2
  1453. */
  1454. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1455. /**
  1456. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  1457. * @param otherVector defines the other vector
  1458. * @returns a new Vector2
  1459. */
  1460. addVector3(otherVector: Vector3): Vector2;
  1461. /**
  1462. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  1463. * @param otherVector defines the other vector
  1464. * @returns a new Vector2
  1465. */
  1466. subtract(otherVector: Vector2): Vector2;
  1467. /**
  1468. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  1469. * @param otherVector defines the other vector
  1470. * @param result defines the target vector
  1471. * @returns the unmodified current Vector2
  1472. */
  1473. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1474. /**
  1475. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  1476. * @param otherVector defines the other vector
  1477. * @returns the current updated Vector2
  1478. */
  1479. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1480. /**
  1481. * Multiplies in place the current Vector2 coordinates by the given ones
  1482. * @param otherVector defines the other vector
  1483. * @returns the current updated Vector2
  1484. */
  1485. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1486. /**
  1487. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  1488. * @param otherVector defines the other vector
  1489. * @returns a new Vector2
  1490. */
  1491. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  1492. /**
  1493. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  1494. * @param otherVector defines the other vector
  1495. * @param result defines the target vector
  1496. * @returns the unmodified current Vector2
  1497. */
  1498. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1499. /**
  1500. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  1501. * @param x defines the first coordinate
  1502. * @param y defines the second coordinate
  1503. * @returns a new Vector2
  1504. */
  1505. multiplyByFloats(x: number, y: number): Vector2;
  1506. /**
  1507. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1508. * @param otherVector defines the other vector
  1509. * @returns a new Vector2
  1510. */
  1511. divide(otherVector: Vector2): Vector2;
  1512. /**
  1513. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1514. * @param otherVector defines the other vector
  1515. * @param result defines the target vector
  1516. * @returns the unmodified current Vector2
  1517. */
  1518. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1519. /**
  1520. * Divides the current Vector2 coordinates by the given ones
  1521. * @param otherVector defines the other vector
  1522. * @returns the current updated Vector2
  1523. */
  1524. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1525. /**
  1526. * Gets a new Vector2 with current Vector2 negated coordinates
  1527. * @returns a new Vector2
  1528. */
  1529. negate(): Vector2;
  1530. /**
  1531. * Multiply the Vector2 coordinates by scale
  1532. * @param scale defines the scaling factor
  1533. * @returns the current updated Vector2
  1534. */
  1535. scaleInPlace(scale: number): Vector2;
  1536. /**
  1537. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1538. * @param scale defines the scaling factor
  1539. * @returns a new Vector2
  1540. */
  1541. scale(scale: number): Vector2;
  1542. /**
  1543. * Scale the current Vector2 values by a factor to a given Vector2
  1544. * @param scale defines the scale factor
  1545. * @param result defines the Vector2 object where to store the result
  1546. * @returns the unmodified current Vector2
  1547. */
  1548. scaleToRef(scale: number, result: Vector2): Vector2;
  1549. /**
  1550. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1551. * @param scale defines the scale factor
  1552. * @param result defines the Vector2 object where to store the result
  1553. * @returns the unmodified current Vector2
  1554. */
  1555. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1556. /**
  1557. * Gets a boolean if two vectors are equals
  1558. * @param otherVector defines the other vector
  1559. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1560. */
  1561. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1562. /**
  1563. * Gets a boolean if two vectors are equals (using an epsilon value)
  1564. * @param otherVector defines the other vector
  1565. * @param epsilon defines the minimal distance to consider equality
  1566. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1567. */
  1568. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1569. /**
  1570. * Gets a new Vector2 from current Vector2 floored values
  1571. * @returns a new Vector2
  1572. */
  1573. floor(): Vector2;
  1574. /**
  1575. * Gets a new Vector2 from current Vector2 floored values
  1576. * @returns a new Vector2
  1577. */
  1578. fract(): Vector2;
  1579. /**
  1580. * Gets the length of the vector
  1581. * @returns the vector length (float)
  1582. */
  1583. length(): number;
  1584. /**
  1585. * Gets the vector squared length
  1586. * @returns the vector squared length (float)
  1587. */
  1588. lengthSquared(): number;
  1589. /**
  1590. * Normalize the vector
  1591. * @returns the current updated Vector2
  1592. */
  1593. normalize(): Vector2;
  1594. /**
  1595. * Gets a new Vector2 copied from the Vector2
  1596. * @returns a new Vector2
  1597. */
  1598. clone(): Vector2;
  1599. /**
  1600. * Gets a new Vector2(0, 0)
  1601. * @returns a new Vector2
  1602. */
  1603. static Zero(): Vector2;
  1604. /**
  1605. * Gets a new Vector2(1, 1)
  1606. * @returns a new Vector2
  1607. */
  1608. static One(): Vector2;
  1609. /**
  1610. * Gets a new Vector2 set from the given index element of the given array
  1611. * @param array defines the data source
  1612. * @param offset defines the offset in the data source
  1613. * @returns a new Vector2
  1614. */
  1615. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1616. /**
  1617. * Sets "result" from the given index element of the given array
  1618. * @param array defines the data source
  1619. * @param offset defines the offset in the data source
  1620. * @param result defines the target vector
  1621. */
  1622. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1623. /**
  1624. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1625. * @param value1 defines 1st point of control
  1626. * @param value2 defines 2nd point of control
  1627. * @param value3 defines 3rd point of control
  1628. * @param value4 defines 4th point of control
  1629. * @param amount defines the interpolation factor
  1630. * @returns a new Vector2
  1631. */
  1632. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1633. /**
  1634. * 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".
  1635. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1636. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1637. * @param value defines the value to clamp
  1638. * @param min defines the lower limit
  1639. * @param max defines the upper limit
  1640. * @returns a new Vector2
  1641. */
  1642. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1643. /**
  1644. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1645. * @param value1 defines the 1st control point
  1646. * @param tangent1 defines the outgoing tangent
  1647. * @param value2 defines the 2nd control point
  1648. * @param tangent2 defines the incoming tangent
  1649. * @param amount defines the interpolation factor
  1650. * @returns a new Vector2
  1651. */
  1652. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1653. /**
  1654. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1655. * @param start defines the start vector
  1656. * @param end defines the end vector
  1657. * @param amount defines the interpolation factor
  1658. * @returns a new Vector2
  1659. */
  1660. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1661. /**
  1662. * Gets the dot product of the vector "left" and the vector "right"
  1663. * @param left defines first vector
  1664. * @param right defines second vector
  1665. * @returns the dot product (float)
  1666. */
  1667. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1668. /**
  1669. * Returns a new Vector2 equal to the normalized given vector
  1670. * @param vector defines the vector to normalize
  1671. * @returns a new Vector2
  1672. */
  1673. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1674. /**
  1675. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1676. * @param left defines 1st vector
  1677. * @param right defines 2nd vector
  1678. * @returns a new Vector2
  1679. */
  1680. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1681. /**
  1682. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1683. * @param left defines 1st vector
  1684. * @param right defines 2nd vector
  1685. * @returns a new Vector2
  1686. */
  1687. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1688. /**
  1689. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1690. * @param vector defines the vector to transform
  1691. * @param transformation defines the matrix to apply
  1692. * @returns a new Vector2
  1693. */
  1694. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1695. /**
  1696. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1697. * @param vector defines the vector to transform
  1698. * @param transformation defines the matrix to apply
  1699. * @param result defines the target vector
  1700. */
  1701. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1702. /**
  1703. * Determines if a given vector is included in a triangle
  1704. * @param p defines the vector to test
  1705. * @param p0 defines 1st triangle point
  1706. * @param p1 defines 2nd triangle point
  1707. * @param p2 defines 3rd triangle point
  1708. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1709. */
  1710. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1711. /**
  1712. * Gets the distance between the vectors "value1" and "value2"
  1713. * @param value1 defines first vector
  1714. * @param value2 defines second vector
  1715. * @returns the distance between vectors
  1716. */
  1717. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1718. /**
  1719. * Returns the squared distance between the vectors "value1" and "value2"
  1720. * @param value1 defines first vector
  1721. * @param value2 defines second vector
  1722. * @returns the squared distance between vectors
  1723. */
  1724. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1725. /**
  1726. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1727. * @param value1 defines first vector
  1728. * @param value2 defines second vector
  1729. * @returns a new Vector2
  1730. */
  1731. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1732. /**
  1733. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1734. * @param p defines the middle point
  1735. * @param segA defines one point of the segment
  1736. * @param segB defines the other point of the segment
  1737. * @returns the shortest distance
  1738. */
  1739. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1740. }
  1741. /**
  1742. * Classed used to store (x,y,z) vector representation
  1743. * A Vector3 is the main object used in 3D geometry
  1744. * It can represent etiher the coordinates of a point the space, either a direction
  1745. * Reminder: js uses a left handed forward facing system
  1746. */
  1747. export class Vector3 {
  1748. /**
  1749. * Defines the first coordinates (on X axis)
  1750. */
  1751. x: number;
  1752. /**
  1753. * Defines the second coordinates (on Y axis)
  1754. */
  1755. y: number;
  1756. /**
  1757. * Defines the third coordinates (on Z axis)
  1758. */
  1759. z: number;
  1760. private static _UpReadOnly;
  1761. private static _ZeroReadOnly;
  1762. /**
  1763. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1764. * @param x defines the first coordinates (on X axis)
  1765. * @param y defines the second coordinates (on Y axis)
  1766. * @param z defines the third coordinates (on Z axis)
  1767. */
  1768. constructor(
  1769. /**
  1770. * Defines the first coordinates (on X axis)
  1771. */
  1772. x?: number,
  1773. /**
  1774. * Defines the second coordinates (on Y axis)
  1775. */
  1776. y?: number,
  1777. /**
  1778. * Defines the third coordinates (on Z axis)
  1779. */
  1780. z?: number);
  1781. /**
  1782. * Creates a string representation of the Vector3
  1783. * @returns a string with the Vector3 coordinates.
  1784. */
  1785. toString(): string;
  1786. /**
  1787. * Gets the class name
  1788. * @returns the string "Vector3"
  1789. */
  1790. getClassName(): string;
  1791. /**
  1792. * Creates the Vector3 hash code
  1793. * @returns a number which tends to be unique between Vector3 instances
  1794. */
  1795. getHashCode(): number;
  1796. /**
  1797. * Creates an array containing three elements : the coordinates of the Vector3
  1798. * @returns a new array of numbers
  1799. */
  1800. asArray(): number[];
  1801. /**
  1802. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1803. * @param array defines the destination array
  1804. * @param index defines the offset in the destination array
  1805. * @returns the current Vector3
  1806. */
  1807. toArray(array: FloatArray, index?: number): Vector3;
  1808. /**
  1809. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1810. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1811. */
  1812. toQuaternion(): Quaternion;
  1813. /**
  1814. * Adds the given vector to the current Vector3
  1815. * @param otherVector defines the second operand
  1816. * @returns the current updated Vector3
  1817. */
  1818. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1819. /**
  1820. * Adds the given coordinates to the current Vector3
  1821. * @param x defines the x coordinate of the operand
  1822. * @param y defines the y coordinate of the operand
  1823. * @param z defines the z coordinate of the operand
  1824. * @returns the current updated Vector3
  1825. */
  1826. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1827. /**
  1828. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1829. * @param otherVector defines the second operand
  1830. * @returns the resulting Vector3
  1831. */
  1832. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1833. /**
  1834. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1835. * @param otherVector defines the second operand
  1836. * @param result defines the Vector3 object where to store the result
  1837. * @returns the current Vector3
  1838. */
  1839. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1840. /**
  1841. * Subtract the given vector from the current Vector3
  1842. * @param otherVector defines the second operand
  1843. * @returns the current updated Vector3
  1844. */
  1845. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1846. /**
  1847. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1848. * @param otherVector defines the second operand
  1849. * @returns the resulting Vector3
  1850. */
  1851. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1852. /**
  1853. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1854. * @param otherVector defines the second operand
  1855. * @param result defines the Vector3 object where to store the result
  1856. * @returns the current Vector3
  1857. */
  1858. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1859. /**
  1860. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1861. * @param x defines the x coordinate of the operand
  1862. * @param y defines the y coordinate of the operand
  1863. * @param z defines the z coordinate of the operand
  1864. * @returns the resulting Vector3
  1865. */
  1866. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1867. /**
  1868. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1869. * @param x defines the x coordinate of the operand
  1870. * @param y defines the y coordinate of the operand
  1871. * @param z defines the z coordinate of the operand
  1872. * @param result defines the Vector3 object where to store the result
  1873. * @returns the current Vector3
  1874. */
  1875. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1876. /**
  1877. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1878. * @returns a new Vector3
  1879. */
  1880. negate(): Vector3;
  1881. /**
  1882. * Multiplies the Vector3 coordinates by the float "scale"
  1883. * @param scale defines the multiplier factor
  1884. * @returns the current updated Vector3
  1885. */
  1886. scaleInPlace(scale: number): Vector3;
  1887. /**
  1888. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1889. * @param scale defines the multiplier factor
  1890. * @returns a new Vector3
  1891. */
  1892. scale(scale: number): Vector3;
  1893. /**
  1894. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1895. * @param scale defines the multiplier factor
  1896. * @param result defines the Vector3 object where to store the result
  1897. * @returns the current Vector3
  1898. */
  1899. scaleToRef(scale: number, result: Vector3): Vector3;
  1900. /**
  1901. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1902. * @param scale defines the scale factor
  1903. * @param result defines the Vector3 object where to store the result
  1904. * @returns the unmodified current Vector3
  1905. */
  1906. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1907. /**
  1908. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1909. * @param otherVector defines the second operand
  1910. * @returns true if both vectors are equals
  1911. */
  1912. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1913. /**
  1914. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1915. * @param otherVector defines the second operand
  1916. * @param epsilon defines the minimal distance to define values as equals
  1917. * @returns true if both vectors are distant less than epsilon
  1918. */
  1919. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1920. /**
  1921. * Returns true if the current Vector3 coordinates equals the given floats
  1922. * @param x defines the x coordinate of the operand
  1923. * @param y defines the y coordinate of the operand
  1924. * @param z defines the z coordinate of the operand
  1925. * @returns true if both vectors are equals
  1926. */
  1927. equalsToFloats(x: number, y: number, z: number): boolean;
  1928. /**
  1929. * Multiplies the current Vector3 coordinates by the given ones
  1930. * @param otherVector defines the second operand
  1931. * @returns the current updated Vector3
  1932. */
  1933. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1934. /**
  1935. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1936. * @param otherVector defines the second operand
  1937. * @returns the new Vector3
  1938. */
  1939. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1940. /**
  1941. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1942. * @param otherVector defines the second operand
  1943. * @param result defines the Vector3 object where to store the result
  1944. * @returns the current Vector3
  1945. */
  1946. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1947. /**
  1948. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1949. * @param x defines the x coordinate of the operand
  1950. * @param y defines the y coordinate of the operand
  1951. * @param z defines the z coordinate of the operand
  1952. * @returns the new Vector3
  1953. */
  1954. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1955. /**
  1956. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1957. * @param otherVector defines the second operand
  1958. * @returns the new Vector3
  1959. */
  1960. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1961. /**
  1962. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1963. * @param otherVector defines the second operand
  1964. * @param result defines the Vector3 object where to store the result
  1965. * @returns the current Vector3
  1966. */
  1967. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1968. /**
  1969. * Divides the current Vector3 coordinates by the given ones.
  1970. * @param otherVector defines the second operand
  1971. * @returns the current updated Vector3
  1972. */
  1973. divideInPlace(otherVector: Vector3): Vector3;
  1974. /**
  1975. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1976. * @param other defines the second operand
  1977. * @returns the current updated Vector3
  1978. */
  1979. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1980. /**
  1981. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1982. * @param other defines the second operand
  1983. * @returns the current updated Vector3
  1984. */
  1985. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1986. /**
  1987. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1988. * @param x defines the x coordinate of the operand
  1989. * @param y defines the y coordinate of the operand
  1990. * @param z defines the z coordinate of the operand
  1991. * @returns the current updated Vector3
  1992. */
  1993. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1994. /**
  1995. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1996. * @param x defines the x coordinate of the operand
  1997. * @param y defines the y coordinate of the operand
  1998. * @param z defines the z coordinate of the operand
  1999. * @returns the current updated Vector3
  2000. */
  2001. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2002. /**
  2003. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2004. * Check if is non uniform within a certain amount of decimal places to account for this
  2005. * @param epsilon the amount the values can differ
  2006. * @returns if the the vector is non uniform to a certain number of decimal places
  2007. */
  2008. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2009. /**
  2010. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2011. */
  2012. readonly isNonUniform: boolean;
  2013. /**
  2014. * Gets a new Vector3 from current Vector3 floored values
  2015. * @returns a new Vector3
  2016. */
  2017. floor(): Vector3;
  2018. /**
  2019. * Gets a new Vector3 from current Vector3 floored values
  2020. * @returns a new Vector3
  2021. */
  2022. fract(): Vector3;
  2023. /**
  2024. * Gets the length of the Vector3
  2025. * @returns the length of the Vector3
  2026. */
  2027. length(): number;
  2028. /**
  2029. * Gets the squared length of the Vector3
  2030. * @returns squared length of the Vector3
  2031. */
  2032. lengthSquared(): number;
  2033. /**
  2034. * Normalize the current Vector3.
  2035. * Please note that this is an in place operation.
  2036. * @returns the current updated Vector3
  2037. */
  2038. normalize(): Vector3;
  2039. /**
  2040. * Reorders the x y z properties of the vector in place
  2041. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2042. * @returns the current updated vector
  2043. */
  2044. reorderInPlace(order: string): this;
  2045. /**
  2046. * Rotates the vector around 0,0,0 by a quaternion
  2047. * @param quaternion the rotation quaternion
  2048. * @param result vector to store the result
  2049. * @returns the resulting vector
  2050. */
  2051. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2052. /**
  2053. * Rotates a vector around a given point
  2054. * @param quaternion the rotation quaternion
  2055. * @param point the point to rotate around
  2056. * @param result vector to store the result
  2057. * @returns the resulting vector
  2058. */
  2059. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2060. /**
  2061. * Normalize the current Vector3 with the given input length.
  2062. * Please note that this is an in place operation.
  2063. * @param len the length of the vector
  2064. * @returns the current updated Vector3
  2065. */
  2066. normalizeFromLength(len: number): Vector3;
  2067. /**
  2068. * Normalize the current Vector3 to a new vector
  2069. * @returns the new Vector3
  2070. */
  2071. normalizeToNew(): Vector3;
  2072. /**
  2073. * Normalize the current Vector3 to the reference
  2074. * @param reference define the Vector3 to update
  2075. * @returns the updated Vector3
  2076. */
  2077. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  2078. /**
  2079. * Creates a new Vector3 copied from the current Vector3
  2080. * @returns the new Vector3
  2081. */
  2082. clone(): Vector3;
  2083. /**
  2084. * Copies the given vector coordinates to the current Vector3 ones
  2085. * @param source defines the source Vector3
  2086. * @returns the current updated Vector3
  2087. */
  2088. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2089. /**
  2090. * Copies the given floats to the current Vector3 coordinates
  2091. * @param x defines the x coordinate of the operand
  2092. * @param y defines the y coordinate of the operand
  2093. * @param z defines the z coordinate of the operand
  2094. * @returns the current updated Vector3
  2095. */
  2096. copyFromFloats(x: number, y: number, z: number): Vector3;
  2097. /**
  2098. * Copies the given floats to the current Vector3 coordinates
  2099. * @param x defines the x coordinate of the operand
  2100. * @param y defines the y coordinate of the operand
  2101. * @param z defines the z coordinate of the operand
  2102. * @returns the current updated Vector3
  2103. */
  2104. set(x: number, y: number, z: number): Vector3;
  2105. /**
  2106. * Copies the given float to the current Vector3 coordinates
  2107. * @param v defines the x, y and z coordinates of the operand
  2108. * @returns the current updated Vector3
  2109. */
  2110. setAll(v: number): Vector3;
  2111. /**
  2112. * Get the clip factor between two vectors
  2113. * @param vector0 defines the first operand
  2114. * @param vector1 defines the second operand
  2115. * @param axis defines the axis to use
  2116. * @param size defines the size along the axis
  2117. * @returns the clip factor
  2118. */
  2119. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2120. /**
  2121. * Get angle between two vectors
  2122. * @param vector0 angle between vector0 and vector1
  2123. * @param vector1 angle between vector0 and vector1
  2124. * @param normal direction of the normal
  2125. * @return the angle between vector0 and vector1
  2126. */
  2127. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2128. /**
  2129. * Returns a new Vector3 set from the index "offset" of the given array
  2130. * @param array defines the source array
  2131. * @param offset defines the offset in the source array
  2132. * @returns the new Vector3
  2133. */
  2134. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2135. /**
  2136. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2137. * This function is deprecated. Use FromArray instead
  2138. * @param array defines the source array
  2139. * @param offset defines the offset in the source array
  2140. * @returns the new Vector3
  2141. */
  2142. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2143. /**
  2144. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2145. * @param array defines the source array
  2146. * @param offset defines the offset in the source array
  2147. * @param result defines the Vector3 where to store the result
  2148. */
  2149. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2150. /**
  2151. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2152. * This function is deprecated. Use FromArrayToRef instead.
  2153. * @param array defines the source array
  2154. * @param offset defines the offset in the source array
  2155. * @param result defines the Vector3 where to store the result
  2156. */
  2157. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2158. /**
  2159. * Sets the given vector "result" with the given floats.
  2160. * @param x defines the x coordinate of the source
  2161. * @param y defines the y coordinate of the source
  2162. * @param z defines the z coordinate of the source
  2163. * @param result defines the Vector3 where to store the result
  2164. */
  2165. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2166. /**
  2167. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2168. * @returns a new empty Vector3
  2169. */
  2170. static Zero(): Vector3;
  2171. /**
  2172. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2173. * @returns a new unit Vector3
  2174. */
  2175. static One(): Vector3;
  2176. /**
  2177. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2178. * @returns a new up Vector3
  2179. */
  2180. static Up(): Vector3;
  2181. /**
  2182. * Gets a up Vector3 that must not be updated
  2183. */
  2184. static readonly UpReadOnly: DeepImmutable<Vector3>;
  2185. /**
  2186. * Gets a zero Vector3 that must not be updated
  2187. */
  2188. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  2189. /**
  2190. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2191. * @returns a new down Vector3
  2192. */
  2193. static Down(): Vector3;
  2194. /**
  2195. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2196. * @returns a new forward Vector3
  2197. */
  2198. static Forward(): Vector3;
  2199. /**
  2200. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2201. * @returns a new forward Vector3
  2202. */
  2203. static Backward(): Vector3;
  2204. /**
  2205. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  2206. * @returns a new right Vector3
  2207. */
  2208. static Right(): Vector3;
  2209. /**
  2210. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  2211. * @returns a new left Vector3
  2212. */
  2213. static Left(): Vector3;
  2214. /**
  2215. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  2216. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2217. * @param vector defines the Vector3 to transform
  2218. * @param transformation defines the transformation matrix
  2219. * @returns the transformed Vector3
  2220. */
  2221. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2222. /**
  2223. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  2224. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  2225. * @param vector defines the Vector3 to transform
  2226. * @param transformation defines the transformation matrix
  2227. * @param result defines the Vector3 where to store the result
  2228. */
  2229. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2230. /**
  2231. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  2232. * This method computes tranformed coordinates only, not transformed direction vectors
  2233. * @param x define the x coordinate of the source vector
  2234. * @param y define the y coordinate of the source vector
  2235. * @param z define the z coordinate of the source vector
  2236. * @param transformation defines the transformation matrix
  2237. * @param result defines the Vector3 where to store the result
  2238. */
  2239. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2240. /**
  2241. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  2242. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2243. * @param vector defines the Vector3 to transform
  2244. * @param transformation defines the transformation matrix
  2245. * @returns the new Vector3
  2246. */
  2247. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  2248. /**
  2249. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  2250. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2251. * @param vector defines the Vector3 to transform
  2252. * @param transformation defines the transformation matrix
  2253. * @param result defines the Vector3 where to store the result
  2254. */
  2255. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2256. /**
  2257. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  2258. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  2259. * @param x define the x coordinate of the source vector
  2260. * @param y define the y coordinate of the source vector
  2261. * @param z define the z coordinate of the source vector
  2262. * @param transformation defines the transformation matrix
  2263. * @param result defines the Vector3 where to store the result
  2264. */
  2265. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  2266. /**
  2267. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  2268. * @param value1 defines the first control point
  2269. * @param value2 defines the second control point
  2270. * @param value3 defines the third control point
  2271. * @param value4 defines the fourth control point
  2272. * @param amount defines the amount on the spline to use
  2273. * @returns the new Vector3
  2274. */
  2275. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  2276. /**
  2277. * 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"
  2278. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2279. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2280. * @param value defines the current value
  2281. * @param min defines the lower range value
  2282. * @param max defines the upper range value
  2283. * @returns the new Vector3
  2284. */
  2285. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  2286. /**
  2287. * 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"
  2288. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  2289. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  2290. * @param value defines the current value
  2291. * @param min defines the lower range value
  2292. * @param max defines the upper range value
  2293. * @param result defines the Vector3 where to store the result
  2294. */
  2295. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  2296. /**
  2297. * Checks if a given vector is inside a specific range
  2298. * @param v defines the vector to test
  2299. * @param min defines the minimum range
  2300. * @param max defines the maximum range
  2301. */
  2302. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  2303. /**
  2304. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  2305. * @param value1 defines the first control point
  2306. * @param tangent1 defines the first tangent vector
  2307. * @param value2 defines the second control point
  2308. * @param tangent2 defines the second tangent vector
  2309. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  2310. * @returns the new Vector3
  2311. */
  2312. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  2313. /**
  2314. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  2315. * @param start defines the start value
  2316. * @param end defines the end value
  2317. * @param amount max defines amount between both (between 0 and 1)
  2318. * @returns the new Vector3
  2319. */
  2320. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  2321. /**
  2322. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  2323. * @param start defines the start value
  2324. * @param end defines the end value
  2325. * @param amount max defines amount between both (between 0 and 1)
  2326. * @param result defines the Vector3 where to store the result
  2327. */
  2328. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  2329. /**
  2330. * Returns the dot product (float) between the vectors "left" and "right"
  2331. * @param left defines the left operand
  2332. * @param right defines the right operand
  2333. * @returns the dot product
  2334. */
  2335. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  2336. /**
  2337. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  2338. * The cross product is then orthogonal to both "left" and "right"
  2339. * @param left defines the left operand
  2340. * @param right defines the right operand
  2341. * @returns the cross product
  2342. */
  2343. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2344. /**
  2345. * Sets the given vector "result" with the cross product of "left" and "right"
  2346. * The cross product is then orthogonal to both "left" and "right"
  2347. * @param left defines the left operand
  2348. * @param right defines the right operand
  2349. * @param result defines the Vector3 where to store the result
  2350. */
  2351. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  2352. /**
  2353. * Returns a new Vector3 as the normalization of the given vector
  2354. * @param vector defines the Vector3 to normalize
  2355. * @returns the new Vector3
  2356. */
  2357. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  2358. /**
  2359. * Sets the given vector "result" with the normalization of the given first vector
  2360. * @param vector defines the Vector3 to normalize
  2361. * @param result defines the Vector3 where to store the result
  2362. */
  2363. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  2364. /**
  2365. * Project a Vector3 onto screen space
  2366. * @param vector defines the Vector3 to project
  2367. * @param world defines the world matrix to use
  2368. * @param transform defines the transform (view x projection) matrix to use
  2369. * @param viewport defines the screen viewport to use
  2370. * @returns the new Vector3
  2371. */
  2372. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  2373. /** @hidden */ private static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  2374. /**
  2375. * Unproject from screen space to object space
  2376. * @param source defines the screen space Vector3 to use
  2377. * @param viewportWidth defines the current width of the viewport
  2378. * @param viewportHeight defines the current height of the viewport
  2379. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2380. * @param transform defines the transform (view x projection) matrix to use
  2381. * @returns the new Vector3
  2382. */
  2383. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  2384. /**
  2385. * Unproject from screen space to object space
  2386. * @param source defines the screen space Vector3 to use
  2387. * @param viewportWidth defines the current width of the viewport
  2388. * @param viewportHeight defines the current height of the viewport
  2389. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2390. * @param view defines the view matrix to use
  2391. * @param projection defines the projection matrix to use
  2392. * @returns the new Vector3
  2393. */
  2394. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  2395. /**
  2396. * Unproject from screen space to object space
  2397. * @param source defines the screen space Vector3 to use
  2398. * @param viewportWidth defines the current width of the viewport
  2399. * @param viewportHeight defines the current height of the viewport
  2400. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2401. * @param view defines the view matrix to use
  2402. * @param projection defines the projection matrix to use
  2403. * @param result defines the Vector3 where to store the result
  2404. */
  2405. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2406. /**
  2407. * Unproject from screen space to object space
  2408. * @param sourceX defines the screen space x coordinate to use
  2409. * @param sourceY defines the screen space y coordinate to use
  2410. * @param sourceZ defines the screen space z coordinate to use
  2411. * @param viewportWidth defines the current width of the viewport
  2412. * @param viewportHeight defines the current height of the viewport
  2413. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  2414. * @param view defines the view matrix to use
  2415. * @param projection defines the projection matrix to use
  2416. * @param result defines the Vector3 where to store the result
  2417. */
  2418. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  2419. /**
  2420. * Gets the minimal coordinate values between two Vector3
  2421. * @param left defines the first operand
  2422. * @param right defines the second operand
  2423. * @returns the new Vector3
  2424. */
  2425. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2426. /**
  2427. * Gets the maximal coordinate values between two Vector3
  2428. * @param left defines the first operand
  2429. * @param right defines the second operand
  2430. * @returns the new Vector3
  2431. */
  2432. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  2433. /**
  2434. * Returns the distance between the vectors "value1" and "value2"
  2435. * @param value1 defines the first operand
  2436. * @param value2 defines the second operand
  2437. * @returns the distance
  2438. */
  2439. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2440. /**
  2441. * Returns the squared distance between the vectors "value1" and "value2"
  2442. * @param value1 defines the first operand
  2443. * @param value2 defines the second operand
  2444. * @returns the squared distance
  2445. */
  2446. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  2447. /**
  2448. * Returns a new Vector3 located at the center between "value1" and "value2"
  2449. * @param value1 defines the first operand
  2450. * @param value2 defines the second operand
  2451. * @returns the new Vector3
  2452. */
  2453. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  2454. /**
  2455. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  2456. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  2457. * to something in order to rotate it from its local system to the given target system
  2458. * Note: axis1, axis2 and axis3 are normalized during this operation
  2459. * @param axis1 defines the first axis
  2460. * @param axis2 defines the second axis
  2461. * @param axis3 defines the third axis
  2462. * @returns a new Vector3
  2463. */
  2464. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  2465. /**
  2466. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  2467. * @param axis1 defines the first axis
  2468. * @param axis2 defines the second axis
  2469. * @param axis3 defines the third axis
  2470. * @param ref defines the Vector3 where to store the result
  2471. */
  2472. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  2473. }
  2474. /**
  2475. * Vector4 class created for EulerAngle class conversion to Quaternion
  2476. */
  2477. export class Vector4 {
  2478. /** x value of the vector */
  2479. x: number;
  2480. /** y value of the vector */
  2481. y: number;
  2482. /** z value of the vector */
  2483. z: number;
  2484. /** w value of the vector */
  2485. w: number;
  2486. /**
  2487. * Creates a Vector4 object from the given floats.
  2488. * @param x x value of the vector
  2489. * @param y y value of the vector
  2490. * @param z z value of the vector
  2491. * @param w w value of the vector
  2492. */
  2493. constructor(
  2494. /** x value of the vector */
  2495. x: number,
  2496. /** y value of the vector */
  2497. y: number,
  2498. /** z value of the vector */
  2499. z: number,
  2500. /** w value of the vector */
  2501. w: number);
  2502. /**
  2503. * Returns the string with the Vector4 coordinates.
  2504. * @returns a string containing all the vector values
  2505. */
  2506. toString(): string;
  2507. /**
  2508. * Returns the string "Vector4".
  2509. * @returns "Vector4"
  2510. */
  2511. getClassName(): string;
  2512. /**
  2513. * Returns the Vector4 hash code.
  2514. * @returns a unique hash code
  2515. */
  2516. getHashCode(): number;
  2517. /**
  2518. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2519. * @returns the resulting array
  2520. */
  2521. asArray(): number[];
  2522. /**
  2523. * Populates the given array from the given index with the Vector4 coordinates.
  2524. * @param array array to populate
  2525. * @param index index of the array to start at (default: 0)
  2526. * @returns the Vector4.
  2527. */
  2528. toArray(array: FloatArray, index?: number): Vector4;
  2529. /**
  2530. * Adds the given vector to the current Vector4.
  2531. * @param otherVector the vector to add
  2532. * @returns the updated Vector4.
  2533. */
  2534. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2535. /**
  2536. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2537. * @param otherVector the vector to add
  2538. * @returns the resulting vector
  2539. */
  2540. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2541. /**
  2542. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2543. * @param otherVector the vector to add
  2544. * @param result the vector to store the result
  2545. * @returns the current Vector4.
  2546. */
  2547. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2548. /**
  2549. * Subtract in place the given vector from the current Vector4.
  2550. * @param otherVector the vector to subtract
  2551. * @returns the updated Vector4.
  2552. */
  2553. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2554. /**
  2555. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2556. * @param otherVector the vector to add
  2557. * @returns the new vector with the result
  2558. */
  2559. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2560. /**
  2561. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2562. * @param otherVector the vector to subtract
  2563. * @param result the vector to store the result
  2564. * @returns the current Vector4.
  2565. */
  2566. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2567. /**
  2568. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2569. */
  2570. /**
  2571. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2572. * @param x value to subtract
  2573. * @param y value to subtract
  2574. * @param z value to subtract
  2575. * @param w value to subtract
  2576. * @returns new vector containing the result
  2577. */
  2578. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2579. /**
  2580. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2581. * @param x value to subtract
  2582. * @param y value to subtract
  2583. * @param z value to subtract
  2584. * @param w value to subtract
  2585. * @param result the vector to store the result in
  2586. * @returns the current Vector4.
  2587. */
  2588. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2589. /**
  2590. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2591. * @returns a new vector with the negated values
  2592. */
  2593. negate(): Vector4;
  2594. /**
  2595. * Multiplies the current Vector4 coordinates by scale (float).
  2596. * @param scale the number to scale with
  2597. * @returns the updated Vector4.
  2598. */
  2599. scaleInPlace(scale: number): Vector4;
  2600. /**
  2601. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2602. * @param scale the number to scale with
  2603. * @returns a new vector with the result
  2604. */
  2605. scale(scale: number): Vector4;
  2606. /**
  2607. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2608. * @param scale the number to scale with
  2609. * @param result a vector to store the result in
  2610. * @returns the current Vector4.
  2611. */
  2612. scaleToRef(scale: number, result: Vector4): Vector4;
  2613. /**
  2614. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2615. * @param scale defines the scale factor
  2616. * @param result defines the Vector4 object where to store the result
  2617. * @returns the unmodified current Vector4
  2618. */
  2619. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2620. /**
  2621. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2622. * @param otherVector the vector to compare against
  2623. * @returns true if they are equal
  2624. */
  2625. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2626. /**
  2627. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2628. * @param otherVector vector to compare against
  2629. * @param epsilon (Default: very small number)
  2630. * @returns true if they are equal
  2631. */
  2632. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2633. /**
  2634. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2635. * @param x x value to compare against
  2636. * @param y y value to compare against
  2637. * @param z z value to compare against
  2638. * @param w w value to compare against
  2639. * @returns true if equal
  2640. */
  2641. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2642. /**
  2643. * Multiplies in place the current Vector4 by the given one.
  2644. * @param otherVector vector to multiple with
  2645. * @returns the updated Vector4.
  2646. */
  2647. multiplyInPlace(otherVector: Vector4): Vector4;
  2648. /**
  2649. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2650. * @param otherVector vector to multiple with
  2651. * @returns resulting new vector
  2652. */
  2653. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2654. /**
  2655. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2656. * @param otherVector vector to multiple with
  2657. * @param result vector to store the result
  2658. * @returns the current Vector4.
  2659. */
  2660. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2661. /**
  2662. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2663. * @param x x value multiply with
  2664. * @param y y value multiply with
  2665. * @param z z value multiply with
  2666. * @param w w value multiply with
  2667. * @returns resulting new vector
  2668. */
  2669. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2670. /**
  2671. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2672. * @param otherVector vector to devide with
  2673. * @returns resulting new vector
  2674. */
  2675. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2676. /**
  2677. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2678. * @param otherVector vector to devide with
  2679. * @param result vector to store the result
  2680. * @returns the current Vector4.
  2681. */
  2682. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2683. /**
  2684. * Divides the current Vector3 coordinates by the given ones.
  2685. * @param otherVector vector to devide with
  2686. * @returns the updated Vector3.
  2687. */
  2688. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2689. /**
  2690. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2691. * @param other defines the second operand
  2692. * @returns the current updated Vector4
  2693. */
  2694. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2695. /**
  2696. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2697. * @param other defines the second operand
  2698. * @returns the current updated Vector4
  2699. */
  2700. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2701. /**
  2702. * Gets a new Vector4 from current Vector4 floored values
  2703. * @returns a new Vector4
  2704. */
  2705. floor(): Vector4;
  2706. /**
  2707. * Gets a new Vector4 from current Vector3 floored values
  2708. * @returns a new Vector4
  2709. */
  2710. fract(): Vector4;
  2711. /**
  2712. * Returns the Vector4 length (float).
  2713. * @returns the length
  2714. */
  2715. length(): number;
  2716. /**
  2717. * Returns the Vector4 squared length (float).
  2718. * @returns the length squared
  2719. */
  2720. lengthSquared(): number;
  2721. /**
  2722. * Normalizes in place the Vector4.
  2723. * @returns the updated Vector4.
  2724. */
  2725. normalize(): Vector4;
  2726. /**
  2727. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2728. * @returns this converted to a new vector3
  2729. */
  2730. toVector3(): Vector3;
  2731. /**
  2732. * Returns a new Vector4 copied from the current one.
  2733. * @returns the new cloned vector
  2734. */
  2735. clone(): Vector4;
  2736. /**
  2737. * Updates the current Vector4 with the given one coordinates.
  2738. * @param source the source vector to copy from
  2739. * @returns the updated Vector4.
  2740. */
  2741. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2742. /**
  2743. * Updates the current Vector4 coordinates with the given floats.
  2744. * @param x float to copy from
  2745. * @param y float to copy from
  2746. * @param z float to copy from
  2747. * @param w float to copy from
  2748. * @returns the updated Vector4.
  2749. */
  2750. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2751. /**
  2752. * Updates the current Vector4 coordinates with the given floats.
  2753. * @param x float to set from
  2754. * @param y float to set from
  2755. * @param z float to set from
  2756. * @param w float to set from
  2757. * @returns the updated Vector4.
  2758. */
  2759. set(x: number, y: number, z: number, w: number): Vector4;
  2760. /**
  2761. * Copies the given float to the current Vector3 coordinates
  2762. * @param v defines the x, y, z and w coordinates of the operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. setAll(v: number): Vector4;
  2766. /**
  2767. * Returns a new Vector4 set from the starting index of the given array.
  2768. * @param array the array to pull values from
  2769. * @param offset the offset into the array to start at
  2770. * @returns the new vector
  2771. */
  2772. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2773. /**
  2774. * Updates the given vector "result" from the starting index of the given array.
  2775. * @param array the array to pull values from
  2776. * @param offset the offset into the array to start at
  2777. * @param result the vector to store the result in
  2778. */
  2779. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2780. /**
  2781. * Updates the given vector "result" from the starting index of the given Float32Array.
  2782. * @param array the array to pull values from
  2783. * @param offset the offset into the array to start at
  2784. * @param result the vector to store the result in
  2785. */
  2786. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2787. /**
  2788. * Updates the given vector "result" coordinates from the given floats.
  2789. * @param x float to set from
  2790. * @param y float to set from
  2791. * @param z float to set from
  2792. * @param w float to set from
  2793. * @param result the vector to the floats in
  2794. */
  2795. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2796. /**
  2797. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2798. * @returns the new vector
  2799. */
  2800. static Zero(): Vector4;
  2801. /**
  2802. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2803. * @returns the new vector
  2804. */
  2805. static One(): Vector4;
  2806. /**
  2807. * Returns a new normalized Vector4 from the given one.
  2808. * @param vector the vector to normalize
  2809. * @returns the vector
  2810. */
  2811. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2812. /**
  2813. * Updates the given vector "result" from the normalization of the given one.
  2814. * @param vector the vector to normalize
  2815. * @param result the vector to store the result in
  2816. */
  2817. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2818. /**
  2819. * Returns a vector with the minimum values from the left and right vectors
  2820. * @param left left vector to minimize
  2821. * @param right right vector to minimize
  2822. * @returns a new vector with the minimum of the left and right vector values
  2823. */
  2824. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2825. /**
  2826. * Returns a vector with the maximum values from the left and right vectors
  2827. * @param left left vector to maximize
  2828. * @param right right vector to maximize
  2829. * @returns a new vector with the maximum of the left and right vector values
  2830. */
  2831. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2832. /**
  2833. * Returns the distance (float) between the vectors "value1" and "value2".
  2834. * @param value1 value to calulate the distance between
  2835. * @param value2 value to calulate the distance between
  2836. * @return the distance between the two vectors
  2837. */
  2838. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2839. /**
  2840. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2841. * @param value1 value to calulate the distance between
  2842. * @param value2 value to calulate the distance between
  2843. * @return the distance between the two vectors squared
  2844. */
  2845. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2846. /**
  2847. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2848. * @param value1 value to calulate the center between
  2849. * @param value2 value to calulate the center between
  2850. * @return the center between the two vectors
  2851. */
  2852. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2853. /**
  2854. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2855. * This methods computes transformed normalized direction vectors only.
  2856. * @param vector the vector to transform
  2857. * @param transformation the transformation matrix to apply
  2858. * @returns the new vector
  2859. */
  2860. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2861. /**
  2862. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2863. * This methods computes transformed normalized direction vectors only.
  2864. * @param vector the vector to transform
  2865. * @param transformation the transformation matrix to apply
  2866. * @param result the vector to store the result in
  2867. */
  2868. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2869. /**
  2870. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2871. * This methods computes transformed normalized direction vectors only.
  2872. * @param x value to transform
  2873. * @param y value to transform
  2874. * @param z value to transform
  2875. * @param w value to transform
  2876. * @param transformation the transformation matrix to apply
  2877. * @param result the vector to store the results in
  2878. */
  2879. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2880. /**
  2881. * Creates a new Vector4 from a Vector3
  2882. * @param source defines the source data
  2883. * @param w defines the 4th component (default is 0)
  2884. * @returns a new Vector4
  2885. */
  2886. static FromVector3(source: Vector3, w?: number): Vector4;
  2887. }
  2888. /**
  2889. * Class used to store quaternion data
  2890. * @see https://en.wikipedia.org/wiki/Quaternion
  2891. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2892. */
  2893. export class Quaternion {
  2894. /** defines the first component (0 by default) */
  2895. x: number;
  2896. /** defines the second component (0 by default) */
  2897. y: number;
  2898. /** defines the third component (0 by default) */
  2899. z: number;
  2900. /** defines the fourth component (1.0 by default) */
  2901. w: number;
  2902. /**
  2903. * Creates a new Quaternion from the given floats
  2904. * @param x defines the first component (0 by default)
  2905. * @param y defines the second component (0 by default)
  2906. * @param z defines the third component (0 by default)
  2907. * @param w defines the fourth component (1.0 by default)
  2908. */
  2909. constructor(
  2910. /** defines the first component (0 by default) */
  2911. x?: number,
  2912. /** defines the second component (0 by default) */
  2913. y?: number,
  2914. /** defines the third component (0 by default) */
  2915. z?: number,
  2916. /** defines the fourth component (1.0 by default) */
  2917. w?: number);
  2918. /**
  2919. * Gets a string representation for the current quaternion
  2920. * @returns a string with the Quaternion coordinates
  2921. */
  2922. toString(): string;
  2923. /**
  2924. * Gets the class name of the quaternion
  2925. * @returns the string "Quaternion"
  2926. */
  2927. getClassName(): string;
  2928. /**
  2929. * Gets a hash code for this quaternion
  2930. * @returns the quaternion hash code
  2931. */
  2932. getHashCode(): number;
  2933. /**
  2934. * Copy the quaternion to an array
  2935. * @returns a new array populated with 4 elements from the quaternion coordinates
  2936. */
  2937. asArray(): number[];
  2938. /**
  2939. * Check if two quaternions are equals
  2940. * @param otherQuaternion defines the second operand
  2941. * @return true if the current quaternion and the given one coordinates are strictly equals
  2942. */
  2943. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2944. /**
  2945. * Clone the current quaternion
  2946. * @returns a new quaternion copied from the current one
  2947. */
  2948. clone(): Quaternion;
  2949. /**
  2950. * Copy a quaternion to the current one
  2951. * @param other defines the other quaternion
  2952. * @returns the updated current quaternion
  2953. */
  2954. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2955. /**
  2956. * Updates the current quaternion with the given float coordinates
  2957. * @param x defines the x coordinate
  2958. * @param y defines the y coordinate
  2959. * @param z defines the z coordinate
  2960. * @param w defines the w coordinate
  2961. * @returns the updated current quaternion
  2962. */
  2963. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2964. /**
  2965. * Updates the current quaternion from the given float coordinates
  2966. * @param x defines the x coordinate
  2967. * @param y defines the y coordinate
  2968. * @param z defines the z coordinate
  2969. * @param w defines the w coordinate
  2970. * @returns the updated current quaternion
  2971. */
  2972. set(x: number, y: number, z: number, w: number): Quaternion;
  2973. /**
  2974. * Adds two quaternions
  2975. * @param other defines the second operand
  2976. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2977. */
  2978. add(other: DeepImmutable<Quaternion>): Quaternion;
  2979. /**
  2980. * Add a quaternion to the current one
  2981. * @param other defines the quaternion to add
  2982. * @returns the current quaternion
  2983. */
  2984. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2985. /**
  2986. * Subtract two quaternions
  2987. * @param other defines the second operand
  2988. * @returns a new quaternion as the subtraction result of the given one from the current one
  2989. */
  2990. subtract(other: Quaternion): Quaternion;
  2991. /**
  2992. * Multiplies the current quaternion by a scale factor
  2993. * @param value defines the scale factor
  2994. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2995. */
  2996. scale(value: number): Quaternion;
  2997. /**
  2998. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2999. * @param scale defines the scale factor
  3000. * @param result defines the Quaternion object where to store the result
  3001. * @returns the unmodified current quaternion
  3002. */
  3003. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3004. /**
  3005. * Multiplies in place the current quaternion by a scale factor
  3006. * @param value defines the scale factor
  3007. * @returns the current modified quaternion
  3008. */
  3009. scaleInPlace(value: number): Quaternion;
  3010. /**
  3011. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3012. * @param scale defines the scale factor
  3013. * @param result defines the Quaternion object where to store the result
  3014. * @returns the unmodified current quaternion
  3015. */
  3016. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3017. /**
  3018. * Multiplies two quaternions
  3019. * @param q1 defines the second operand
  3020. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3021. */
  3022. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3023. /**
  3024. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3025. * @param q1 defines the second operand
  3026. * @param result defines the target quaternion
  3027. * @returns the current quaternion
  3028. */
  3029. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3030. /**
  3031. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3032. * @param q1 defines the second operand
  3033. * @returns the currentupdated quaternion
  3034. */
  3035. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3036. /**
  3037. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3038. * @param ref defines the target quaternion
  3039. * @returns the current quaternion
  3040. */
  3041. conjugateToRef(ref: Quaternion): Quaternion;
  3042. /**
  3043. * Conjugates in place (1-q) the current quaternion
  3044. * @returns the current updated quaternion
  3045. */
  3046. conjugateInPlace(): Quaternion;
  3047. /**
  3048. * Conjugates in place (1-q) the current quaternion
  3049. * @returns a new quaternion
  3050. */
  3051. conjugate(): Quaternion;
  3052. /**
  3053. * Gets length of current quaternion
  3054. * @returns the quaternion length (float)
  3055. */
  3056. length(): number;
  3057. /**
  3058. * Normalize in place the current quaternion
  3059. * @returns the current updated quaternion
  3060. */
  3061. normalize(): Quaternion;
  3062. /**
  3063. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3064. * @param order is a reserved parameter and is ignore for now
  3065. * @returns a new Vector3 containing the Euler angles
  3066. */
  3067. toEulerAngles(order?: string): Vector3;
  3068. /**
  3069. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3070. * @param result defines the vector which will be filled with the Euler angles
  3071. * @param order is a reserved parameter and is ignore for now
  3072. * @returns the current unchanged quaternion
  3073. */
  3074. toEulerAnglesToRef(result: Vector3): Quaternion;
  3075. /**
  3076. * Updates the given rotation matrix with the current quaternion values
  3077. * @param result defines the target matrix
  3078. * @returns the current unchanged quaternion
  3079. */
  3080. toRotationMatrix(result: Matrix): Quaternion;
  3081. /**
  3082. * Updates the current quaternion from the given rotation matrix values
  3083. * @param matrix defines the source matrix
  3084. * @returns the current updated quaternion
  3085. */
  3086. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3087. /**
  3088. * Creates a new quaternion from a rotation matrix
  3089. * @param matrix defines the source matrix
  3090. * @returns a new quaternion created from the given rotation matrix values
  3091. */
  3092. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3093. /**
  3094. * Updates the given quaternion with the given rotation matrix values
  3095. * @param matrix defines the source matrix
  3096. * @param result defines the target quaternion
  3097. */
  3098. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3099. /**
  3100. * Returns the dot product (float) between the quaternions "left" and "right"
  3101. * @param left defines the left operand
  3102. * @param right defines the right operand
  3103. * @returns the dot product
  3104. */
  3105. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3106. /**
  3107. * Checks if the two quaternions are close to each other
  3108. * @param quat0 defines the first quaternion to check
  3109. * @param quat1 defines the second quaternion to check
  3110. * @returns true if the two quaternions are close to each other
  3111. */
  3112. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3113. /**
  3114. * Creates an empty quaternion
  3115. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3116. */
  3117. static Zero(): Quaternion;
  3118. /**
  3119. * Inverse a given quaternion
  3120. * @param q defines the source quaternion
  3121. * @returns a new quaternion as the inverted current quaternion
  3122. */
  3123. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3124. /**
  3125. * Inverse a given quaternion
  3126. * @param q defines the source quaternion
  3127. * @param result the quaternion the result will be stored in
  3128. * @returns the result quaternion
  3129. */
  3130. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3131. /**
  3132. * Creates an identity quaternion
  3133. * @returns the identity quaternion
  3134. */
  3135. static Identity(): Quaternion;
  3136. /**
  3137. * Gets a boolean indicating if the given quaternion is identity
  3138. * @param quaternion defines the quaternion to check
  3139. * @returns true if the quaternion is identity
  3140. */
  3141. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3142. /**
  3143. * Creates a quaternion from a rotation around an axis
  3144. * @param axis defines the axis to use
  3145. * @param angle defines the angle to use
  3146. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3147. */
  3148. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3149. /**
  3150. * Creates a rotation around an axis and stores it into the given quaternion
  3151. * @param axis defines the axis to use
  3152. * @param angle defines the angle to use
  3153. * @param result defines the target quaternion
  3154. * @returns the target quaternion
  3155. */
  3156. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3157. /**
  3158. * Creates a new quaternion from data stored into an array
  3159. * @param array defines the data source
  3160. * @param offset defines the offset in the source array where the data starts
  3161. * @returns a new quaternion
  3162. */
  3163. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3164. /**
  3165. * Create a quaternion from Euler rotation angles
  3166. * @param x Pitch
  3167. * @param y Yaw
  3168. * @param z Roll
  3169. * @returns the new Quaternion
  3170. */
  3171. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  3172. /**
  3173. * Updates a quaternion from Euler rotation angles
  3174. * @param x Pitch
  3175. * @param y Yaw
  3176. * @param z Roll
  3177. * @param result the quaternion to store the result
  3178. * @returns the updated quaternion
  3179. */
  3180. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  3181. /**
  3182. * Create a quaternion from Euler rotation vector
  3183. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3184. * @returns the new Quaternion
  3185. */
  3186. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  3187. /**
  3188. * Updates a quaternion from Euler rotation vector
  3189. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  3190. * @param result the quaternion to store the result
  3191. * @returns the updated quaternion
  3192. */
  3193. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  3194. /**
  3195. * Creates a new quaternion from the given Euler float angles (y, x, z)
  3196. * @param yaw defines the rotation around Y axis
  3197. * @param pitch defines the rotation around X axis
  3198. * @param roll defines the rotation around Z axis
  3199. * @returns the new quaternion
  3200. */
  3201. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3202. /**
  3203. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  3204. * @param yaw defines the rotation around Y axis
  3205. * @param pitch defines the rotation around X axis
  3206. * @param roll defines the rotation around Z axis
  3207. * @param result defines the target quaternion
  3208. */
  3209. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3210. /**
  3211. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  3212. * @param alpha defines the rotation around first axis
  3213. * @param beta defines the rotation around second axis
  3214. * @param gamma defines the rotation around third axis
  3215. * @returns the new quaternion
  3216. */
  3217. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3218. /**
  3219. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  3220. * @param alpha defines the rotation around first axis
  3221. * @param beta defines the rotation around second axis
  3222. * @param gamma defines the rotation around third axis
  3223. * @param result defines the target quaternion
  3224. */
  3225. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3226. /**
  3227. * 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)
  3228. * @param axis1 defines the first axis
  3229. * @param axis2 defines the second axis
  3230. * @param axis3 defines the third axis
  3231. * @returns the new quaternion
  3232. */
  3233. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  3234. /**
  3235. * 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
  3236. * @param axis1 defines the first axis
  3237. * @param axis2 defines the second axis
  3238. * @param axis3 defines the third axis
  3239. * @param ref defines the target quaternion
  3240. */
  3241. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  3242. /**
  3243. * Interpolates between two quaternions
  3244. * @param left defines first quaternion
  3245. * @param right defines second quaternion
  3246. * @param amount defines the gradient to use
  3247. * @returns the new interpolated quaternion
  3248. */
  3249. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3250. /**
  3251. * Interpolates between two quaternions and stores it into a target quaternion
  3252. * @param left defines first quaternion
  3253. * @param right defines second quaternion
  3254. * @param amount defines the gradient to use
  3255. * @param result defines the target quaternion
  3256. */
  3257. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  3258. /**
  3259. * Interpolate between two quaternions using Hermite interpolation
  3260. * @param value1 defines first quaternion
  3261. * @param tangent1 defines the incoming tangent
  3262. * @param value2 defines second quaternion
  3263. * @param tangent2 defines the outgoing tangent
  3264. * @param amount defines the target quaternion
  3265. * @returns the new interpolated quaternion
  3266. */
  3267. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  3268. }
  3269. /**
  3270. * Class used to store matrix data (4x4)
  3271. */
  3272. export class Matrix {
  3273. private static _updateFlagSeed;
  3274. private static _identityReadOnly;
  3275. private _isIdentity;
  3276. private _isIdentityDirty;
  3277. private _isIdentity3x2;
  3278. private _isIdentity3x2Dirty;
  3279. /**
  3280. * Gets the update flag of the matrix which is an unique number for the matrix.
  3281. * It will be incremented every time the matrix data change.
  3282. * You can use it to speed the comparison between two versions of the same matrix.
  3283. */
  3284. updateFlag: number;
  3285. private readonly _m;
  3286. /**
  3287. * Gets the internal data of the matrix
  3288. */
  3289. readonly m: DeepImmutable<Float32Array>;
  3290. /** @hidden */ private _markAsUpdated(): void;
  3291. /** @hidden */
  3292. private _updateIdentityStatus;
  3293. /**
  3294. * Creates an empty matrix (filled with zeros)
  3295. */
  3296. constructor();
  3297. /**
  3298. * Check if the current matrix is identity
  3299. * @returns true is the matrix is the identity matrix
  3300. */
  3301. isIdentity(): boolean;
  3302. /**
  3303. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  3304. * @returns true is the matrix is the identity matrix
  3305. */
  3306. isIdentityAs3x2(): boolean;
  3307. /**
  3308. * Gets the determinant of the matrix
  3309. * @returns the matrix determinant
  3310. */
  3311. determinant(): number;
  3312. /**
  3313. * Returns the matrix as a Float32Array
  3314. * @returns the matrix underlying array
  3315. */
  3316. toArray(): DeepImmutable<Float32Array>;
  3317. /**
  3318. * Returns the matrix as a Float32Array
  3319. * @returns the matrix underlying array.
  3320. */
  3321. asArray(): DeepImmutable<Float32Array>;
  3322. /**
  3323. * Inverts the current matrix in place
  3324. * @returns the current inverted matrix
  3325. */
  3326. invert(): Matrix;
  3327. /**
  3328. * Sets all the matrix elements to zero
  3329. * @returns the current matrix
  3330. */
  3331. reset(): Matrix;
  3332. /**
  3333. * Adds the current matrix with a second one
  3334. * @param other defines the matrix to add
  3335. * @returns a new matrix as the addition of the current matrix and the given one
  3336. */
  3337. add(other: DeepImmutable<Matrix>): Matrix;
  3338. /**
  3339. * Sets the given matrix "result" to the addition of the current matrix and the given one
  3340. * @param other defines the matrix to add
  3341. * @param result defines the target matrix
  3342. * @returns the current matrix
  3343. */
  3344. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3345. /**
  3346. * Adds in place the given matrix to the current matrix
  3347. * @param other defines the second operand
  3348. * @returns the current updated matrix
  3349. */
  3350. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  3351. /**
  3352. * Sets the given matrix to the current inverted Matrix
  3353. * @param other defines the target matrix
  3354. * @returns the unmodified current matrix
  3355. */
  3356. invertToRef(other: Matrix): Matrix;
  3357. /**
  3358. * add a value at the specified position in the current Matrix
  3359. * @param index the index of the value within the matrix. between 0 and 15.
  3360. * @param value the value to be added
  3361. * @returns the current updated matrix
  3362. */
  3363. addAtIndex(index: number, value: number): Matrix;
  3364. /**
  3365. * mutiply the specified position in the current Matrix by a value
  3366. * @param index the index of the value within the matrix. between 0 and 15.
  3367. * @param value the value to be added
  3368. * @returns the current updated matrix
  3369. */
  3370. multiplyAtIndex(index: number, value: number): Matrix;
  3371. /**
  3372. * Inserts the translation vector (using 3 floats) in the current matrix
  3373. * @param x defines the 1st component of the translation
  3374. * @param y defines the 2nd component of the translation
  3375. * @param z defines the 3rd component of the translation
  3376. * @returns the current updated matrix
  3377. */
  3378. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3379. /**
  3380. * Adds the translation vector (using 3 floats) in the current matrix
  3381. * @param x defines the 1st component of the translation
  3382. * @param y defines the 2nd component of the translation
  3383. * @param z defines the 3rd component of the translation
  3384. * @returns the current updated matrix
  3385. */
  3386. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  3387. /**
  3388. * Inserts the translation vector in the current matrix
  3389. * @param vector3 defines the translation to insert
  3390. * @returns the current updated matrix
  3391. */
  3392. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  3393. /**
  3394. * Gets the translation value of the current matrix
  3395. * @returns a new Vector3 as the extracted translation from the matrix
  3396. */
  3397. getTranslation(): Vector3;
  3398. /**
  3399. * Fill a Vector3 with the extracted translation from the matrix
  3400. * @param result defines the Vector3 where to store the translation
  3401. * @returns the current matrix
  3402. */
  3403. getTranslationToRef(result: Vector3): Matrix;
  3404. /**
  3405. * Remove rotation and scaling part from the matrix
  3406. * @returns the updated matrix
  3407. */
  3408. removeRotationAndScaling(): Matrix;
  3409. /**
  3410. * Multiply two matrices
  3411. * @param other defines the second operand
  3412. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  3413. */
  3414. multiply(other: DeepImmutable<Matrix>): Matrix;
  3415. /**
  3416. * Copy the current matrix from the given one
  3417. * @param other defines the source matrix
  3418. * @returns the current updated matrix
  3419. */
  3420. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  3421. /**
  3422. * Populates the given array from the starting index with the current matrix values
  3423. * @param array defines the target array
  3424. * @param offset defines the offset in the target array where to start storing values
  3425. * @returns the current matrix
  3426. */
  3427. copyToArray(array: Float32Array, offset?: number): Matrix;
  3428. /**
  3429. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  3430. * @param other defines the second operand
  3431. * @param result defines the matrix where to store the multiplication
  3432. * @returns the current matrix
  3433. */
  3434. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  3435. /**
  3436. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3437. * @param other defines the second operand
  3438. * @param result defines the array where to store the multiplication
  3439. * @param offset defines the offset in the target array where to start storing values
  3440. * @returns the current matrix
  3441. */
  3442. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3443. /**
  3444. * Check equality between this matrix and a second one
  3445. * @param value defines the second matrix to compare
  3446. * @returns true is the current matrix and the given one values are strictly equal
  3447. */
  3448. equals(value: DeepImmutable<Matrix>): boolean;
  3449. /**
  3450. * Clone the current matrix
  3451. * @returns a new matrix from the current matrix
  3452. */
  3453. clone(): Matrix;
  3454. /**
  3455. * Returns the name of the current matrix class
  3456. * @returns the string "Matrix"
  3457. */
  3458. getClassName(): string;
  3459. /**
  3460. * Gets the hash code of the current matrix
  3461. * @returns the hash code
  3462. */
  3463. getHashCode(): number;
  3464. /**
  3465. * Decomposes the current Matrix into a translation, rotation and scaling components
  3466. * @param scale defines the scale vector3 given as a reference to update
  3467. * @param rotation defines the rotation quaternion given as a reference to update
  3468. * @param translation defines the translation vector3 given as a reference to update
  3469. * @returns true if operation was successful
  3470. */
  3471. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3472. /**
  3473. * Gets specific row of the matrix
  3474. * @param index defines the number of the row to get
  3475. * @returns the index-th row of the current matrix as a new Vector4
  3476. */
  3477. getRow(index: number): Nullable<Vector4>;
  3478. /**
  3479. * Sets the index-th row of the current matrix to the vector4 values
  3480. * @param index defines the number of the row to set
  3481. * @param row defines the target vector4
  3482. * @returns the updated current matrix
  3483. */
  3484. setRow(index: number, row: Vector4): Matrix;
  3485. /**
  3486. * Compute the transpose of the matrix
  3487. * @returns the new transposed matrix
  3488. */
  3489. transpose(): Matrix;
  3490. /**
  3491. * Compute the transpose of the matrix and store it in a given matrix
  3492. * @param result defines the target matrix
  3493. * @returns the current matrix
  3494. */
  3495. transposeToRef(result: Matrix): Matrix;
  3496. /**
  3497. * Sets the index-th row of the current matrix with the given 4 x float values
  3498. * @param index defines the row index
  3499. * @param x defines the x component to set
  3500. * @param y defines the y component to set
  3501. * @param z defines the z component to set
  3502. * @param w defines the w component to set
  3503. * @returns the updated current matrix
  3504. */
  3505. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3506. /**
  3507. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3508. * @param scale defines the scale factor
  3509. * @returns a new matrix
  3510. */
  3511. scale(scale: number): Matrix;
  3512. /**
  3513. * Scale the current matrix values by a factor to a given result matrix
  3514. * @param scale defines the scale factor
  3515. * @param result defines the matrix to store the result
  3516. * @returns the current matrix
  3517. */
  3518. scaleToRef(scale: number, result: Matrix): Matrix;
  3519. /**
  3520. * Scale the current matrix values by a factor and add the result to a given matrix
  3521. * @param scale defines the scale factor
  3522. * @param result defines the Matrix to store the result
  3523. * @returns the current matrix
  3524. */
  3525. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3526. /**
  3527. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3528. * @param ref matrix to store the result
  3529. */
  3530. toNormalMatrix(ref: Matrix): void;
  3531. /**
  3532. * Gets only rotation part of the current matrix
  3533. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3534. */
  3535. getRotationMatrix(): Matrix;
  3536. /**
  3537. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3538. * @param result defines the target matrix to store data to
  3539. * @returns the current matrix
  3540. */
  3541. getRotationMatrixToRef(result: Matrix): Matrix;
  3542. /**
  3543. * Toggles model matrix from being right handed to left handed in place and vice versa
  3544. */
  3545. toggleModelMatrixHandInPlace(): void;
  3546. /**
  3547. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3548. */
  3549. toggleProjectionMatrixHandInPlace(): void;
  3550. /**
  3551. * Creates a matrix from an array
  3552. * @param array defines the source array
  3553. * @param offset defines an offset in the source array
  3554. * @returns a new Matrix set from the starting index of the given array
  3555. */
  3556. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3557. /**
  3558. * Copy the content of an array into a given matrix
  3559. * @param array defines the source array
  3560. * @param offset defines an offset in the source array
  3561. * @param result defines the target matrix
  3562. */
  3563. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3564. /**
  3565. * Stores an array into a matrix after having multiplied each component by a given factor
  3566. * @param array defines the source array
  3567. * @param offset defines the offset in the source array
  3568. * @param scale defines the scaling factor
  3569. * @param result defines the target matrix
  3570. */
  3571. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3572. /**
  3573. * Gets an identity matrix that must not be updated
  3574. */
  3575. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3576. /**
  3577. * Stores a list of values (16) inside a given matrix
  3578. * @param initialM11 defines 1st value of 1st row
  3579. * @param initialM12 defines 2nd value of 1st row
  3580. * @param initialM13 defines 3rd value of 1st row
  3581. * @param initialM14 defines 4th value of 1st row
  3582. * @param initialM21 defines 1st value of 2nd row
  3583. * @param initialM22 defines 2nd value of 2nd row
  3584. * @param initialM23 defines 3rd value of 2nd row
  3585. * @param initialM24 defines 4th value of 2nd row
  3586. * @param initialM31 defines 1st value of 3rd row
  3587. * @param initialM32 defines 2nd value of 3rd row
  3588. * @param initialM33 defines 3rd value of 3rd row
  3589. * @param initialM34 defines 4th value of 3rd row
  3590. * @param initialM41 defines 1st value of 4th row
  3591. * @param initialM42 defines 2nd value of 4th row
  3592. * @param initialM43 defines 3rd value of 4th row
  3593. * @param initialM44 defines 4th value of 4th row
  3594. * @param result defines the target matrix
  3595. */
  3596. 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;
  3597. /**
  3598. * Creates new matrix from a list of values (16)
  3599. * @param initialM11 defines 1st value of 1st row
  3600. * @param initialM12 defines 2nd value of 1st row
  3601. * @param initialM13 defines 3rd value of 1st row
  3602. * @param initialM14 defines 4th value of 1st row
  3603. * @param initialM21 defines 1st value of 2nd row
  3604. * @param initialM22 defines 2nd value of 2nd row
  3605. * @param initialM23 defines 3rd value of 2nd row
  3606. * @param initialM24 defines 4th value of 2nd row
  3607. * @param initialM31 defines 1st value of 3rd row
  3608. * @param initialM32 defines 2nd value of 3rd row
  3609. * @param initialM33 defines 3rd value of 3rd row
  3610. * @param initialM34 defines 4th value of 3rd row
  3611. * @param initialM41 defines 1st value of 4th row
  3612. * @param initialM42 defines 2nd value of 4th row
  3613. * @param initialM43 defines 3rd value of 4th row
  3614. * @param initialM44 defines 4th value of 4th row
  3615. * @returns the new matrix
  3616. */
  3617. 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;
  3618. /**
  3619. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3620. * @param scale defines the scale vector3
  3621. * @param rotation defines the rotation quaternion
  3622. * @param translation defines the translation vector3
  3623. * @returns a new matrix
  3624. */
  3625. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3626. /**
  3627. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3628. * @param scale defines the scale vector3
  3629. * @param rotation defines the rotation quaternion
  3630. * @param translation defines the translation vector3
  3631. * @param result defines the target matrix
  3632. */
  3633. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3634. /**
  3635. * Creates a new identity matrix
  3636. * @returns a new identity matrix
  3637. */
  3638. static Identity(): Matrix;
  3639. /**
  3640. * Creates a new identity matrix and stores the result in a given matrix
  3641. * @param result defines the target matrix
  3642. */
  3643. static IdentityToRef(result: Matrix): void;
  3644. /**
  3645. * Creates a new zero matrix
  3646. * @returns a new zero matrix
  3647. */
  3648. static Zero(): Matrix;
  3649. /**
  3650. * Creates a new rotation matrix for "angle" radians around the X axis
  3651. * @param angle defines the angle (in radians) to use
  3652. * @return the new matrix
  3653. */
  3654. static RotationX(angle: number): Matrix;
  3655. /**
  3656. * Creates a new matrix as the invert of a given matrix
  3657. * @param source defines the source matrix
  3658. * @returns the new matrix
  3659. */
  3660. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3661. /**
  3662. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3663. * @param angle defines the angle (in radians) to use
  3664. * @param result defines the target matrix
  3665. */
  3666. static RotationXToRef(angle: number, result: Matrix): void;
  3667. /**
  3668. * Creates a new rotation matrix for "angle" radians around the Y axis
  3669. * @param angle defines the angle (in radians) to use
  3670. * @return the new matrix
  3671. */
  3672. static RotationY(angle: number): Matrix;
  3673. /**
  3674. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3675. * @param angle defines the angle (in radians) to use
  3676. * @param result defines the target matrix
  3677. */
  3678. static RotationYToRef(angle: number, result: Matrix): void;
  3679. /**
  3680. * Creates a new rotation matrix for "angle" radians around the Z axis
  3681. * @param angle defines the angle (in radians) to use
  3682. * @return the new matrix
  3683. */
  3684. static RotationZ(angle: number): Matrix;
  3685. /**
  3686. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3687. * @param angle defines the angle (in radians) to use
  3688. * @param result defines the target matrix
  3689. */
  3690. static RotationZToRef(angle: number, result: Matrix): void;
  3691. /**
  3692. * Creates a new rotation matrix for "angle" radians around the given axis
  3693. * @param axis defines the axis to use
  3694. * @param angle defines the angle (in radians) to use
  3695. * @return the new matrix
  3696. */
  3697. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3698. /**
  3699. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3700. * @param axis defines the axis to use
  3701. * @param angle defines the angle (in radians) to use
  3702. * @param result defines the target matrix
  3703. */
  3704. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3705. /**
  3706. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3707. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3708. * @param from defines the vector to align
  3709. * @param to defines the vector to align to
  3710. * @param result defines the target matrix
  3711. */
  3712. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3713. /**
  3714. * Creates a rotation matrix
  3715. * @param yaw defines the yaw angle in radians (Y axis)
  3716. * @param pitch defines the pitch angle in radians (X axis)
  3717. * @param roll defines the roll angle in radians (X axis)
  3718. * @returns the new rotation matrix
  3719. */
  3720. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3721. /**
  3722. * Creates a rotation matrix and stores it in a given matrix
  3723. * @param yaw defines the yaw angle in radians (Y axis)
  3724. * @param pitch defines the pitch angle in radians (X axis)
  3725. * @param roll defines the roll angle in radians (X axis)
  3726. * @param result defines the target matrix
  3727. */
  3728. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3729. /**
  3730. * Creates a scaling matrix
  3731. * @param x defines the scale factor on X axis
  3732. * @param y defines the scale factor on Y axis
  3733. * @param z defines the scale factor on Z axis
  3734. * @returns the new matrix
  3735. */
  3736. static Scaling(x: number, y: number, z: number): Matrix;
  3737. /**
  3738. * Creates a scaling matrix and stores it in a given matrix
  3739. * @param x defines the scale factor on X axis
  3740. * @param y defines the scale factor on Y axis
  3741. * @param z defines the scale factor on Z axis
  3742. * @param result defines the target matrix
  3743. */
  3744. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3745. /**
  3746. * Creates a translation matrix
  3747. * @param x defines the translation on X axis
  3748. * @param y defines the translation on Y axis
  3749. * @param z defines the translationon Z axis
  3750. * @returns the new matrix
  3751. */
  3752. static Translation(x: number, y: number, z: number): Matrix;
  3753. /**
  3754. * Creates a translation matrix and stores it in a given matrix
  3755. * @param x defines the translation on X axis
  3756. * @param y defines the translation on Y axis
  3757. * @param z defines the translationon Z axis
  3758. * @param result defines the target matrix
  3759. */
  3760. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3761. /**
  3762. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3763. * @param startValue defines the start value
  3764. * @param endValue defines the end value
  3765. * @param gradient defines the gradient factor
  3766. * @returns the new matrix
  3767. */
  3768. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3769. /**
  3770. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3771. * @param startValue defines the start value
  3772. * @param endValue defines the end value
  3773. * @param gradient defines the gradient factor
  3774. * @param result defines the Matrix object where to store data
  3775. */
  3776. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3777. /**
  3778. * Builds a new matrix whose values are computed by:
  3779. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3780. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3781. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3782. * @param startValue defines the first matrix
  3783. * @param endValue defines the second matrix
  3784. * @param gradient defines the gradient between the two matrices
  3785. * @returns the new matrix
  3786. */
  3787. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3788. /**
  3789. * Update a matrix to values which are computed by:
  3790. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3791. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3792. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3793. * @param startValue defines the first matrix
  3794. * @param endValue defines the second matrix
  3795. * @param gradient defines the gradient between the two matrices
  3796. * @param result defines the target matrix
  3797. */
  3798. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3799. /**
  3800. * 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"
  3801. * This function works in left handed mode
  3802. * @param eye defines the final position of the entity
  3803. * @param target defines where the entity should look at
  3804. * @param up defines the up vector for the entity
  3805. * @returns the new matrix
  3806. */
  3807. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3808. /**
  3809. * 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".
  3810. * This function works in left handed mode
  3811. * @param eye defines the final position of the entity
  3812. * @param target defines where the entity should look at
  3813. * @param up defines the up vector for the entity
  3814. * @param result defines the target matrix
  3815. */
  3816. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3817. /**
  3818. * 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"
  3819. * This function works in right handed mode
  3820. * @param eye defines the final position of the entity
  3821. * @param target defines where the entity should look at
  3822. * @param up defines the up vector for the entity
  3823. * @returns the new matrix
  3824. */
  3825. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3826. /**
  3827. * 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".
  3828. * This function works in right handed mode
  3829. * @param eye defines the final position of the entity
  3830. * @param target defines where the entity should look at
  3831. * @param up defines the up vector for the entity
  3832. * @param result defines the target matrix
  3833. */
  3834. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3835. /**
  3836. * Create a left-handed orthographic projection matrix
  3837. * @param width defines the viewport width
  3838. * @param height defines the viewport height
  3839. * @param znear defines the near clip plane
  3840. * @param zfar defines the far clip plane
  3841. * @returns a new matrix as a left-handed orthographic projection matrix
  3842. */
  3843. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3844. /**
  3845. * Store a left-handed orthographic projection to a given matrix
  3846. * @param width defines the viewport width
  3847. * @param height defines the viewport height
  3848. * @param znear defines the near clip plane
  3849. * @param zfar defines the far clip plane
  3850. * @param result defines the target matrix
  3851. */
  3852. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3853. /**
  3854. * Create a left-handed orthographic projection matrix
  3855. * @param left defines the viewport left coordinate
  3856. * @param right defines the viewport right coordinate
  3857. * @param bottom defines the viewport bottom coordinate
  3858. * @param top defines the viewport top coordinate
  3859. * @param znear defines the near clip plane
  3860. * @param zfar defines the far clip plane
  3861. * @returns a new matrix as a left-handed orthographic projection matrix
  3862. */
  3863. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3864. /**
  3865. * Stores a left-handed orthographic projection into a given matrix
  3866. * @param left defines the viewport left coordinate
  3867. * @param right defines the viewport right coordinate
  3868. * @param bottom defines the viewport bottom coordinate
  3869. * @param top defines the viewport top coordinate
  3870. * @param znear defines the near clip plane
  3871. * @param zfar defines the far clip plane
  3872. * @param result defines the target matrix
  3873. */
  3874. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3875. /**
  3876. * Creates a right-handed orthographic projection matrix
  3877. * @param left defines the viewport left coordinate
  3878. * @param right defines the viewport right coordinate
  3879. * @param bottom defines the viewport bottom coordinate
  3880. * @param top defines the viewport top coordinate
  3881. * @param znear defines the near clip plane
  3882. * @param zfar defines the far clip plane
  3883. * @returns a new matrix as a right-handed orthographic projection matrix
  3884. */
  3885. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3886. /**
  3887. * Stores a right-handed orthographic projection into a given matrix
  3888. * @param left defines the viewport left coordinate
  3889. * @param right defines the viewport right coordinate
  3890. * @param bottom defines the viewport bottom coordinate
  3891. * @param top defines the viewport top coordinate
  3892. * @param znear defines the near clip plane
  3893. * @param zfar defines the far clip plane
  3894. * @param result defines the target matrix
  3895. */
  3896. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3897. /**
  3898. * Creates a left-handed perspective projection matrix
  3899. * @param width defines the viewport width
  3900. * @param height defines the viewport height
  3901. * @param znear defines the near clip plane
  3902. * @param zfar defines the far clip plane
  3903. * @returns a new matrix as a left-handed perspective projection matrix
  3904. */
  3905. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3906. /**
  3907. * Creates a left-handed perspective projection matrix
  3908. * @param fov defines the horizontal field of view
  3909. * @param aspect defines the aspect ratio
  3910. * @param znear defines the near clip plane
  3911. * @param zfar defines the far clip plane
  3912. * @returns a new matrix as a left-handed perspective projection matrix
  3913. */
  3914. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3915. /**
  3916. * Stores a left-handed perspective projection into a given matrix
  3917. * @param fov defines the horizontal field of view
  3918. * @param aspect defines the aspect ratio
  3919. * @param znear defines the near clip plane
  3920. * @param zfar defines the far clip plane
  3921. * @param result defines the target matrix
  3922. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3923. */
  3924. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3925. /**
  3926. * Creates a right-handed perspective projection matrix
  3927. * @param fov defines the horizontal field of view
  3928. * @param aspect defines the aspect ratio
  3929. * @param znear defines the near clip plane
  3930. * @param zfar defines the far clip plane
  3931. * @returns a new matrix as a right-handed perspective projection matrix
  3932. */
  3933. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3934. /**
  3935. * Stores a right-handed perspective projection into a given matrix
  3936. * @param fov defines the horizontal field of view
  3937. * @param aspect defines the aspect ratio
  3938. * @param znear defines the near clip plane
  3939. * @param zfar defines the far clip plane
  3940. * @param result defines the target matrix
  3941. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3942. */
  3943. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3944. /**
  3945. * Stores a perspective projection for WebVR info a given matrix
  3946. * @param fov defines the field of view
  3947. * @param znear defines the near clip plane
  3948. * @param zfar defines the far clip plane
  3949. * @param result defines the target matrix
  3950. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3951. */
  3952. static PerspectiveFovWebVRToRef(fov: {
  3953. upDegrees: number;
  3954. downDegrees: number;
  3955. leftDegrees: number;
  3956. rightDegrees: number;
  3957. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3958. /**
  3959. * Computes a complete transformation matrix
  3960. * @param viewport defines the viewport to use
  3961. * @param world defines the world matrix
  3962. * @param view defines the view matrix
  3963. * @param projection defines the projection matrix
  3964. * @param zmin defines the near clip plane
  3965. * @param zmax defines the far clip plane
  3966. * @returns the transformation matrix
  3967. */
  3968. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3969. /**
  3970. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3971. * @param matrix defines the matrix to use
  3972. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3973. */
  3974. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3975. /**
  3976. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3977. * @param matrix defines the matrix to use
  3978. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3979. */
  3980. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3981. /**
  3982. * Compute the transpose of a given matrix
  3983. * @param matrix defines the matrix to transpose
  3984. * @returns the new matrix
  3985. */
  3986. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3987. /**
  3988. * Compute the transpose of a matrix and store it in a target matrix
  3989. * @param matrix defines the matrix to transpose
  3990. * @param result defines the target matrix
  3991. */
  3992. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3993. /**
  3994. * Computes a reflection matrix from a plane
  3995. * @param plane defines the reflection plane
  3996. * @returns a new matrix
  3997. */
  3998. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3999. /**
  4000. * Computes a reflection matrix from a plane
  4001. * @param plane defines the reflection plane
  4002. * @param result defines the target matrix
  4003. */
  4004. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4005. /**
  4006. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4007. * @param xaxis defines the value of the 1st axis
  4008. * @param yaxis defines the value of the 2nd axis
  4009. * @param zaxis defines the value of the 3rd axis
  4010. * @param result defines the target matrix
  4011. */
  4012. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4013. /**
  4014. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4015. * @param quat defines the quaternion to use
  4016. * @param result defines the target matrix
  4017. */
  4018. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4019. }
  4020. /**
  4021. * @hidden
  4022. */
  4023. export class TmpVectors {
  4024. static Vector2: Vector2[];
  4025. static Vector3: Vector3[];
  4026. static Vector4: Vector4[];
  4027. static Quaternion: Quaternion[];
  4028. static Matrix: Matrix[];
  4029. }
  4030. }
  4031. declare module BABYLON {
  4032. /** Defines the cross module used constants to avoid circular dependncies */
  4033. export class Constants {
  4034. /** Defines that alpha blending is disabled */
  4035. static readonly ALPHA_DISABLE: number;
  4036. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4037. static readonly ALPHA_ADD: number;
  4038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4039. static readonly ALPHA_COMBINE: number;
  4040. /** Defines that alpha blending to DEST - SRC * DEST */
  4041. static readonly ALPHA_SUBTRACT: number;
  4042. /** Defines that alpha blending to SRC * DEST */
  4043. static readonly ALPHA_MULTIPLY: number;
  4044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4045. static readonly ALPHA_MAXIMIZED: number;
  4046. /** Defines that alpha blending to SRC + DEST */
  4047. static readonly ALPHA_ONEONE: number;
  4048. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4049. static readonly ALPHA_PREMULTIPLIED: number;
  4050. /**
  4051. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4052. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4053. */
  4054. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4055. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4056. static readonly ALPHA_INTERPOLATE: number;
  4057. /**
  4058. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4059. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4060. */
  4061. static readonly ALPHA_SCREENMODE: number;
  4062. /** Defines that the ressource is not delayed*/
  4063. static readonly DELAYLOADSTATE_NONE: number;
  4064. /** Defines that the ressource was successfully delay loaded */
  4065. static readonly DELAYLOADSTATE_LOADED: number;
  4066. /** Defines that the ressource is currently delay loading */
  4067. static readonly DELAYLOADSTATE_LOADING: number;
  4068. /** Defines that the ressource is delayed and has not started loading */
  4069. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4071. static readonly NEVER: number;
  4072. /** 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 */
  4073. static readonly ALWAYS: number;
  4074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4075. static readonly LESS: number;
  4076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4077. static readonly EQUAL: number;
  4078. /** 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 */
  4079. static readonly LEQUAL: number;
  4080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4081. static readonly GREATER: number;
  4082. /** 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 */
  4083. static readonly GEQUAL: number;
  4084. /** 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 */
  4085. static readonly NOTEQUAL: number;
  4086. /** Passed to stencilOperation to specify that stencil value must be kept */
  4087. static readonly KEEP: number;
  4088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4089. static readonly REPLACE: number;
  4090. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4091. static readonly INCR: number;
  4092. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4093. static readonly DECR: number;
  4094. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4095. static readonly INVERT: number;
  4096. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4097. static readonly INCR_WRAP: number;
  4098. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4099. static readonly DECR_WRAP: number;
  4100. /** Texture is not repeating outside of 0..1 UVs */
  4101. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4102. /** Texture is repeating outside of 0..1 UVs */
  4103. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4104. /** Texture is repeating and mirrored */
  4105. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4106. /** ALPHA */
  4107. static readonly TEXTUREFORMAT_ALPHA: number;
  4108. /** LUMINANCE */
  4109. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4110. /** LUMINANCE_ALPHA */
  4111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4112. /** RGB */
  4113. static readonly TEXTUREFORMAT_RGB: number;
  4114. /** RGBA */
  4115. static readonly TEXTUREFORMAT_RGBA: number;
  4116. /** RED */
  4117. static readonly TEXTUREFORMAT_RED: number;
  4118. /** RED (2nd reference) */
  4119. static readonly TEXTUREFORMAT_R: number;
  4120. /** RG */
  4121. static readonly TEXTUREFORMAT_RG: number;
  4122. /** RED_INTEGER */
  4123. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4124. /** RED_INTEGER (2nd reference) */
  4125. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4126. /** RG_INTEGER */
  4127. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4128. /** RGB_INTEGER */
  4129. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4130. /** RGBA_INTEGER */
  4131. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4132. /** UNSIGNED_BYTE */
  4133. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4134. /** UNSIGNED_BYTE (2nd reference) */
  4135. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4136. /** FLOAT */
  4137. static readonly TEXTURETYPE_FLOAT: number;
  4138. /** HALF_FLOAT */
  4139. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4140. /** BYTE */
  4141. static readonly TEXTURETYPE_BYTE: number;
  4142. /** SHORT */
  4143. static readonly TEXTURETYPE_SHORT: number;
  4144. /** UNSIGNED_SHORT */
  4145. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4146. /** INT */
  4147. static readonly TEXTURETYPE_INT: number;
  4148. /** UNSIGNED_INT */
  4149. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4150. /** UNSIGNED_SHORT_4_4_4_4 */
  4151. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4152. /** UNSIGNED_SHORT_5_5_5_1 */
  4153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4154. /** UNSIGNED_SHORT_5_6_5 */
  4155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4156. /** UNSIGNED_INT_2_10_10_10_REV */
  4157. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4158. /** UNSIGNED_INT_24_8 */
  4159. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4160. /** UNSIGNED_INT_10F_11F_11F_REV */
  4161. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4162. /** UNSIGNED_INT_5_9_9_9_REV */
  4163. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4164. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4165. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4166. /** nearest is mag = nearest and min = nearest and mip = linear */
  4167. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4170. /** Trilinear is mag = linear and min = linear and mip = linear */
  4171. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4172. /** nearest is mag = nearest and min = nearest and mip = linear */
  4173. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4175. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4176. /** Trilinear is mag = linear and min = linear and mip = linear */
  4177. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4178. /** mag = nearest and min = nearest and mip = nearest */
  4179. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4180. /** mag = nearest and min = linear and mip = nearest */
  4181. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4182. /** mag = nearest and min = linear and mip = linear */
  4183. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4184. /** mag = nearest and min = linear and mip = none */
  4185. static readonly TEXTURE_NEAREST_LINEAR: number;
  4186. /** mag = nearest and min = nearest and mip = none */
  4187. static readonly TEXTURE_NEAREST_NEAREST: number;
  4188. /** mag = linear and min = nearest and mip = nearest */
  4189. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4190. /** mag = linear and min = nearest and mip = linear */
  4191. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4192. /** mag = linear and min = linear and mip = none */
  4193. static readonly TEXTURE_LINEAR_LINEAR: number;
  4194. /** mag = linear and min = nearest and mip = none */
  4195. static readonly TEXTURE_LINEAR_NEAREST: number;
  4196. /** Explicit coordinates mode */
  4197. static readonly TEXTURE_EXPLICIT_MODE: number;
  4198. /** Spherical coordinates mode */
  4199. static readonly TEXTURE_SPHERICAL_MODE: number;
  4200. /** Planar coordinates mode */
  4201. static readonly TEXTURE_PLANAR_MODE: number;
  4202. /** Cubic coordinates mode */
  4203. static readonly TEXTURE_CUBIC_MODE: number;
  4204. /** Projection coordinates mode */
  4205. static readonly TEXTURE_PROJECTION_MODE: number;
  4206. /** Skybox coordinates mode */
  4207. static readonly TEXTURE_SKYBOX_MODE: number;
  4208. /** Inverse Cubic coordinates mode */
  4209. static readonly TEXTURE_INVCUBIC_MODE: number;
  4210. /** Equirectangular coordinates mode */
  4211. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4212. /** Equirectangular Fixed coordinates mode */
  4213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4214. /** Equirectangular Fixed Mirrored coordinates mode */
  4215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4216. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4217. static readonly SCALEMODE_FLOOR: number;
  4218. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4219. static readonly SCALEMODE_NEAREST: number;
  4220. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4221. static readonly SCALEMODE_CEILING: number;
  4222. /**
  4223. * The dirty texture flag value
  4224. */
  4225. static readonly MATERIAL_TextureDirtyFlag: number;
  4226. /**
  4227. * The dirty light flag value
  4228. */
  4229. static readonly MATERIAL_LightDirtyFlag: number;
  4230. /**
  4231. * The dirty fresnel flag value
  4232. */
  4233. static readonly MATERIAL_FresnelDirtyFlag: number;
  4234. /**
  4235. * The dirty attribute flag value
  4236. */
  4237. static readonly MATERIAL_AttributesDirtyFlag: number;
  4238. /**
  4239. * The dirty misc flag value
  4240. */
  4241. static readonly MATERIAL_MiscDirtyFlag: number;
  4242. /**
  4243. * The all dirty flag value
  4244. */
  4245. static readonly MATERIAL_AllDirtyFlag: number;
  4246. /**
  4247. * Returns the triangle fill mode
  4248. */
  4249. static readonly MATERIAL_TriangleFillMode: number;
  4250. /**
  4251. * Returns the wireframe mode
  4252. */
  4253. static readonly MATERIAL_WireFrameFillMode: number;
  4254. /**
  4255. * Returns the point fill mode
  4256. */
  4257. static readonly MATERIAL_PointFillMode: number;
  4258. /**
  4259. * Returns the point list draw mode
  4260. */
  4261. static readonly MATERIAL_PointListDrawMode: number;
  4262. /**
  4263. * Returns the line list draw mode
  4264. */
  4265. static readonly MATERIAL_LineListDrawMode: number;
  4266. /**
  4267. * Returns the line loop draw mode
  4268. */
  4269. static readonly MATERIAL_LineLoopDrawMode: number;
  4270. /**
  4271. * Returns the line strip draw mode
  4272. */
  4273. static readonly MATERIAL_LineStripDrawMode: number;
  4274. /**
  4275. * Returns the triangle strip draw mode
  4276. */
  4277. static readonly MATERIAL_TriangleStripDrawMode: number;
  4278. /**
  4279. * Returns the triangle fan draw mode
  4280. */
  4281. static readonly MATERIAL_TriangleFanDrawMode: number;
  4282. /**
  4283. * Stores the clock-wise side orientation
  4284. */
  4285. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4286. /**
  4287. * Stores the counter clock-wise side orientation
  4288. */
  4289. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4290. /**
  4291. * Nothing
  4292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4293. */
  4294. static readonly ACTION_NothingTrigger: number;
  4295. /**
  4296. * On pick
  4297. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4298. */
  4299. static readonly ACTION_OnPickTrigger: number;
  4300. /**
  4301. * On left pick
  4302. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4303. */
  4304. static readonly ACTION_OnLeftPickTrigger: number;
  4305. /**
  4306. * On right pick
  4307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4308. */
  4309. static readonly ACTION_OnRightPickTrigger: number;
  4310. /**
  4311. * On center pick
  4312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4313. */
  4314. static readonly ACTION_OnCenterPickTrigger: number;
  4315. /**
  4316. * On pick down
  4317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4318. */
  4319. static readonly ACTION_OnPickDownTrigger: number;
  4320. /**
  4321. * On double pick
  4322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4323. */
  4324. static readonly ACTION_OnDoublePickTrigger: number;
  4325. /**
  4326. * On pick up
  4327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4328. */
  4329. static readonly ACTION_OnPickUpTrigger: number;
  4330. /**
  4331. * On pick out.
  4332. * This trigger will only be raised if you also declared a OnPickDown
  4333. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4334. */
  4335. static readonly ACTION_OnPickOutTrigger: number;
  4336. /**
  4337. * On long press
  4338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4339. */
  4340. static readonly ACTION_OnLongPressTrigger: number;
  4341. /**
  4342. * On pointer over
  4343. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4344. */
  4345. static readonly ACTION_OnPointerOverTrigger: number;
  4346. /**
  4347. * On pointer out
  4348. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4349. */
  4350. static readonly ACTION_OnPointerOutTrigger: number;
  4351. /**
  4352. * On every frame
  4353. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4354. */
  4355. static readonly ACTION_OnEveryFrameTrigger: number;
  4356. /**
  4357. * On intersection enter
  4358. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4359. */
  4360. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4361. /**
  4362. * On intersection exit
  4363. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4364. */
  4365. static readonly ACTION_OnIntersectionExitTrigger: number;
  4366. /**
  4367. * On key down
  4368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4369. */
  4370. static readonly ACTION_OnKeyDownTrigger: number;
  4371. /**
  4372. * On key up
  4373. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4374. */
  4375. static readonly ACTION_OnKeyUpTrigger: number;
  4376. /**
  4377. * Billboard mode will only apply to Y axis
  4378. */
  4379. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4380. /**
  4381. * Billboard mode will apply to all axes
  4382. */
  4383. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4384. /**
  4385. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4386. */
  4387. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4388. /**
  4389. * Gets or sets base Assets URL
  4390. */
  4391. static PARTICLES_BaseAssetsUrl: string;
  4392. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4393. * Test order :
  4394. * Is the bounding sphere outside the frustum ?
  4395. * If not, are the bounding box vertices outside the frustum ?
  4396. * It not, then the cullable object is in the frustum.
  4397. */
  4398. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4399. /** Culling strategy : Bounding Sphere Only.
  4400. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4401. * It's also less accurate than the standard because some not visible objects can still be selected.
  4402. * Test : is the bounding sphere outside the frustum ?
  4403. * If not, then the cullable object is in the frustum.
  4404. */
  4405. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4406. /** Culling strategy : Optimistic Inclusion.
  4407. * This in an inclusion test first, then the standard exclusion test.
  4408. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4409. * 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.
  4410. * Anyway, it's as accurate as the standard strategy.
  4411. * Test :
  4412. * Is the cullable object bounding sphere center in the frustum ?
  4413. * If not, apply the default culling strategy.
  4414. */
  4415. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4416. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4417. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4418. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4419. * 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.
  4420. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4421. * Test :
  4422. * Is the cullable object bounding sphere center in the frustum ?
  4423. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4424. */
  4425. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4426. /**
  4427. * No logging while loading
  4428. */
  4429. static readonly SCENELOADER_NO_LOGGING: number;
  4430. /**
  4431. * Minimal logging while loading
  4432. */
  4433. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4434. /**
  4435. * Summary logging while loading
  4436. */
  4437. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4438. /**
  4439. * Detailled logging while loading
  4440. */
  4441. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4442. }
  4443. }
  4444. declare module BABYLON {
  4445. /**
  4446. * Class used to store and describe the pipeline context associated with an effect
  4447. */
  4448. export interface IPipelineContext {
  4449. /**
  4450. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4451. */
  4452. isAsync: boolean;
  4453. /**
  4454. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4455. */
  4456. isReady: boolean;
  4457. /** @hidden */ private _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4458. }
  4459. }
  4460. declare module BABYLON {
  4461. /** @hidden */
  4462. export interface IShaderProcessor {
  4463. attributeProcessor?: (attribute: string) => string;
  4464. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4465. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4466. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4467. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4468. lineProcessor?: (line: string, isFragment: boolean) => string;
  4469. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4470. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4471. }
  4472. }
  4473. declare module BABYLON {
  4474. /** @hidden */
  4475. export interface ProcessingOptions {
  4476. defines: string[];
  4477. indexParameters: any;
  4478. isFragment: boolean;
  4479. shouldUseHighPrecisionShader: boolean;
  4480. supportsUniformBuffers: boolean;
  4481. shadersRepository: string;
  4482. includesShadersStore: {
  4483. [key: string]: string;
  4484. };
  4485. processor?: IShaderProcessor;
  4486. version: string;
  4487. platformName: string;
  4488. lookForClosingBracketForUniformBuffer?: boolean;
  4489. }
  4490. }
  4491. declare module BABYLON {
  4492. /**
  4493. * Helper to manipulate strings
  4494. */
  4495. export class StringTools {
  4496. /**
  4497. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4498. * @param str Source string
  4499. * @param suffix Suffix to search for in the source string
  4500. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4501. */
  4502. static EndsWith(str: string, suffix: string): boolean;
  4503. /**
  4504. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4505. * @param str Source string
  4506. * @param suffix Suffix to search for in the source string
  4507. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4508. */
  4509. static StartsWith(str: string, suffix: string): boolean;
  4510. }
  4511. }
  4512. declare module BABYLON {
  4513. /** @hidden */
  4514. export class ShaderCodeNode {
  4515. line: string;
  4516. children: ShaderCodeNode[];
  4517. additionalDefineKey?: string;
  4518. additionalDefineValue?: string;
  4519. isValid(preprocessors: {
  4520. [key: string]: string;
  4521. }): boolean;
  4522. process(preprocessors: {
  4523. [key: string]: string;
  4524. }, options: ProcessingOptions): string;
  4525. }
  4526. }
  4527. declare module BABYLON {
  4528. /** @hidden */
  4529. export class ShaderCodeCursor {
  4530. private _lines;
  4531. lineIndex: number;
  4532. readonly currentLine: string;
  4533. readonly canRead: boolean;
  4534. lines: string[];
  4535. }
  4536. }
  4537. declare module BABYLON {
  4538. /** @hidden */
  4539. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4540. process(preprocessors: {
  4541. [key: string]: string;
  4542. }, options: ProcessingOptions): string;
  4543. }
  4544. }
  4545. declare module BABYLON {
  4546. /** @hidden */
  4547. export class ShaderDefineExpression {
  4548. isTrue(preprocessors: {
  4549. [key: string]: string;
  4550. }): boolean;
  4551. }
  4552. }
  4553. declare module BABYLON {
  4554. /** @hidden */
  4555. export class ShaderCodeTestNode extends ShaderCodeNode {
  4556. testExpression: ShaderDefineExpression;
  4557. isValid(preprocessors: {
  4558. [key: string]: string;
  4559. }): boolean;
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. /** @hidden */
  4564. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4565. define: string;
  4566. not: boolean;
  4567. constructor(define: string, not?: boolean);
  4568. isTrue(preprocessors: {
  4569. [key: string]: string;
  4570. }): boolean;
  4571. }
  4572. }
  4573. declare module BABYLON {
  4574. /** @hidden */
  4575. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4576. leftOperand: ShaderDefineExpression;
  4577. rightOperand: ShaderDefineExpression;
  4578. isTrue(preprocessors: {
  4579. [key: string]: string;
  4580. }): boolean;
  4581. }
  4582. }
  4583. declare module BABYLON {
  4584. /** @hidden */
  4585. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  4586. leftOperand: ShaderDefineExpression;
  4587. rightOperand: ShaderDefineExpression;
  4588. isTrue(preprocessors: {
  4589. [key: string]: string;
  4590. }): boolean;
  4591. }
  4592. }
  4593. declare module BABYLON {
  4594. /** @hidden */
  4595. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  4596. define: string;
  4597. operand: string;
  4598. testValue: string;
  4599. constructor(define: string, operand: string, testValue: string);
  4600. isTrue(preprocessors: {
  4601. [key: string]: string;
  4602. }): boolean;
  4603. }
  4604. }
  4605. declare module BABYLON {
  4606. /**
  4607. * @ignore
  4608. * Application error to support additional information when loading a file
  4609. */
  4610. export class LoadFileError extends Error {
  4611. /** defines the optional web request */
  4612. request?: WebRequest | undefined;
  4613. private static _setPrototypeOf;
  4614. /**
  4615. * Creates a new LoadFileError
  4616. * @param message defines the message of the error
  4617. * @param request defines the optional web request
  4618. */
  4619. constructor(message: string,
  4620. /** defines the optional web request */
  4621. request?: WebRequest | undefined);
  4622. }
  4623. }
  4624. declare module BABYLON {
  4625. /**
  4626. * Class used to enable access to offline support
  4627. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4628. */
  4629. export interface IOfflineProvider {
  4630. /**
  4631. * Gets a boolean indicating if scene must be saved in the database
  4632. */
  4633. enableSceneOffline: boolean;
  4634. /**
  4635. * Gets a boolean indicating if textures must be saved in the database
  4636. */
  4637. enableTexturesOffline: boolean;
  4638. /**
  4639. * Open the offline support and make it available
  4640. * @param successCallback defines the callback to call on success
  4641. * @param errorCallback defines the callback to call on error
  4642. */
  4643. open(successCallback: () => void, errorCallback: () => void): void;
  4644. /**
  4645. * Loads an image from the offline support
  4646. * @param url defines the url to load from
  4647. * @param image defines the target DOM image
  4648. */
  4649. loadImage(url: string, image: HTMLImageElement): void;
  4650. /**
  4651. * Loads a file from offline support
  4652. * @param url defines the URL to load from
  4653. * @param sceneLoaded defines a callback to call on success
  4654. * @param progressCallBack defines a callback to call when progress changed
  4655. * @param errorCallback defines a callback to call on error
  4656. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4657. */
  4658. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4659. }
  4660. }
  4661. declare module BABYLON {
  4662. /**
  4663. * Class used to help managing file picking and drag'n'drop
  4664. * File Storage
  4665. */
  4666. export class FilesInputStore {
  4667. /**
  4668. * List of files ready to be loaded
  4669. */
  4670. static FilesToLoad: {
  4671. [key: string]: File;
  4672. };
  4673. }
  4674. }
  4675. declare module BABYLON {
  4676. /**
  4677. * Class used to define a retry strategy when error happens while loading assets
  4678. */
  4679. export class RetryStrategy {
  4680. /**
  4681. * Function used to defines an exponential back off strategy
  4682. * @param maxRetries defines the maximum number of retries (3 by default)
  4683. * @param baseInterval defines the interval between retries
  4684. * @returns the strategy function to use
  4685. */
  4686. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  4687. }
  4688. }
  4689. declare module BABYLON {
  4690. /**
  4691. * @hidden
  4692. */
  4693. export class FileTools {
  4694. /**
  4695. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  4696. */
  4697. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  4698. /**
  4699. * Gets or sets the base URL to use to load assets
  4700. */
  4701. static BaseUrl: string;
  4702. /**
  4703. * Default behaviour for cors in the application.
  4704. * It can be a string if the expected behavior is identical in the entire app.
  4705. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  4706. */
  4707. static CorsBehavior: string | ((url: string | string[]) => string);
  4708. /**
  4709. * Gets or sets a function used to pre-process url before using them to load assets
  4710. */
  4711. static PreprocessUrl: (url: string) => string;
  4712. /**
  4713. * Removes unwanted characters from an url
  4714. * @param url defines the url to clean
  4715. * @returns the cleaned url
  4716. */
  4717. private static _CleanUrl;
  4718. /**
  4719. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  4720. * @param url define the url we are trying
  4721. * @param element define the dom element where to configure the cors policy
  4722. */
  4723. static SetCorsBehavior(url: string | string[], element: {
  4724. crossOrigin: string | null;
  4725. }): void;
  4726. /**
  4727. * Loads an image as an HTMLImageElement.
  4728. * @param input url string, ArrayBuffer, or Blob to load
  4729. * @param onLoad callback called when the image successfully loads
  4730. * @param onError callback called when the image fails to load
  4731. * @param offlineProvider offline provider for caching
  4732. * @returns the HTMLImageElement of the loaded image
  4733. */
  4734. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  4735. /**
  4736. * Loads a file
  4737. * @param fileToLoad defines the file to load
  4738. * @param callback defines the callback to call when data is loaded
  4739. * @param progressCallBack defines the callback to call during loading process
  4740. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  4741. * @returns a file request object
  4742. */
  4743. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  4744. /**
  4745. * Loads a file
  4746. * @param url url string, ArrayBuffer, or Blob to load
  4747. * @param onSuccess callback called when the file successfully loads
  4748. * @param onProgress callback called while file is loading (if the server supports this mode)
  4749. * @param offlineProvider defines the offline provider for caching
  4750. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  4751. * @param onError callback called when the file fails to load
  4752. * @returns a file request object
  4753. */
  4754. 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;
  4755. /**
  4756. * Checks if the loaded document was accessed via `file:`-Protocol.
  4757. * @returns boolean
  4758. */
  4759. static IsFileURL(): boolean;
  4760. }
  4761. }
  4762. declare module BABYLON {
  4763. /** @hidden */
  4764. export class ShaderProcessor {
  4765. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  4766. private static _ProcessPrecision;
  4767. private static _ExtractOperation;
  4768. private static _BuildSubExpression;
  4769. private static _BuildExpression;
  4770. private static _MoveCursorWithinIf;
  4771. private static _MoveCursor;
  4772. private static _EvaluatePreProcessors;
  4773. private static _PreparePreProcessors;
  4774. private static _ProcessShaderConversion;
  4775. private static _ProcessIncludes;
  4776. }
  4777. }
  4778. declare module BABYLON {
  4779. /**
  4780. * Class used to hold a RBG color
  4781. */
  4782. export class Color3 {
  4783. /**
  4784. * Defines the red component (between 0 and 1, default is 0)
  4785. */
  4786. r: number;
  4787. /**
  4788. * Defines the green component (between 0 and 1, default is 0)
  4789. */
  4790. g: number;
  4791. /**
  4792. * Defines the blue component (between 0 and 1, default is 0)
  4793. */
  4794. b: number;
  4795. /**
  4796. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  4797. * @param r defines the red component (between 0 and 1, default is 0)
  4798. * @param g defines the green component (between 0 and 1, default is 0)
  4799. * @param b defines the blue component (between 0 and 1, default is 0)
  4800. */
  4801. constructor(
  4802. /**
  4803. * Defines the red component (between 0 and 1, default is 0)
  4804. */
  4805. r?: number,
  4806. /**
  4807. * Defines the green component (between 0 and 1, default is 0)
  4808. */
  4809. g?: number,
  4810. /**
  4811. * Defines the blue component (between 0 and 1, default is 0)
  4812. */
  4813. b?: number);
  4814. /**
  4815. * Creates a string with the Color3 current values
  4816. * @returns the string representation of the Color3 object
  4817. */
  4818. toString(): string;
  4819. /**
  4820. * Returns the string "Color3"
  4821. * @returns "Color3"
  4822. */
  4823. getClassName(): string;
  4824. /**
  4825. * Compute the Color3 hash code
  4826. * @returns an unique number that can be used to hash Color3 objects
  4827. */
  4828. getHashCode(): number;
  4829. /**
  4830. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  4831. * @param array defines the array where to store the r,g,b components
  4832. * @param index defines an optional index in the target array to define where to start storing values
  4833. * @returns the current Color3 object
  4834. */
  4835. toArray(array: FloatArray, index?: number): Color3;
  4836. /**
  4837. * Returns a new Color4 object from the current Color3 and the given alpha
  4838. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  4839. * @returns a new Color4 object
  4840. */
  4841. toColor4(alpha?: number): Color4;
  4842. /**
  4843. * Returns a new array populated with 3 numeric elements : red, green and blue values
  4844. * @returns the new array
  4845. */
  4846. asArray(): number[];
  4847. /**
  4848. * Returns the luminance value
  4849. * @returns a float value
  4850. */
  4851. toLuminance(): number;
  4852. /**
  4853. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  4854. * @param otherColor defines the second operand
  4855. * @returns the new Color3 object
  4856. */
  4857. multiply(otherColor: DeepImmutable<Color3>): Color3;
  4858. /**
  4859. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  4860. * @param otherColor defines the second operand
  4861. * @param result defines the Color3 object where to store the result
  4862. * @returns the current Color3
  4863. */
  4864. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4865. /**
  4866. * Determines equality between Color3 objects
  4867. * @param otherColor defines the second operand
  4868. * @returns true if the rgb values are equal to the given ones
  4869. */
  4870. equals(otherColor: DeepImmutable<Color3>): boolean;
  4871. /**
  4872. * Determines equality between the current Color3 object and a set of r,b,g values
  4873. * @param r defines the red component to check
  4874. * @param g defines the green component to check
  4875. * @param b defines the blue component to check
  4876. * @returns true if the rgb values are equal to the given ones
  4877. */
  4878. equalsFloats(r: number, g: number, b: number): boolean;
  4879. /**
  4880. * Multiplies in place each rgb value by scale
  4881. * @param scale defines the scaling factor
  4882. * @returns the updated Color3
  4883. */
  4884. scale(scale: number): Color3;
  4885. /**
  4886. * Multiplies the rgb values by scale and stores the result into "result"
  4887. * @param scale defines the scaling factor
  4888. * @param result defines the Color3 object where to store the result
  4889. * @returns the unmodified current Color3
  4890. */
  4891. scaleToRef(scale: number, result: Color3): Color3;
  4892. /**
  4893. * Scale the current Color3 values by a factor and add the result to a given Color3
  4894. * @param scale defines the scale factor
  4895. * @param result defines color to store the result into
  4896. * @returns the unmodified current Color3
  4897. */
  4898. scaleAndAddToRef(scale: number, result: Color3): Color3;
  4899. /**
  4900. * Clamps the rgb values by the min and max values and stores the result into "result"
  4901. * @param min defines minimum clamping value (default is 0)
  4902. * @param max defines maximum clamping value (default is 1)
  4903. * @param result defines color to store the result into
  4904. * @returns the original Color3
  4905. */
  4906. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  4907. /**
  4908. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  4909. * @param otherColor defines the second operand
  4910. * @returns the new Color3
  4911. */
  4912. add(otherColor: DeepImmutable<Color3>): Color3;
  4913. /**
  4914. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  4915. * @param otherColor defines the second operand
  4916. * @param result defines Color3 object to store the result into
  4917. * @returns the unmodified current Color3
  4918. */
  4919. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4920. /**
  4921. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  4922. * @param otherColor defines the second operand
  4923. * @returns the new Color3
  4924. */
  4925. subtract(otherColor: DeepImmutable<Color3>): Color3;
  4926. /**
  4927. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  4928. * @param otherColor defines the second operand
  4929. * @param result defines Color3 object to store the result into
  4930. * @returns the unmodified current Color3
  4931. */
  4932. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  4933. /**
  4934. * Copy the current object
  4935. * @returns a new Color3 copied the current one
  4936. */
  4937. clone(): Color3;
  4938. /**
  4939. * Copies the rgb values from the source in the current Color3
  4940. * @param source defines the source Color3 object
  4941. * @returns the updated Color3 object
  4942. */
  4943. copyFrom(source: DeepImmutable<Color3>): Color3;
  4944. /**
  4945. * Updates the Color3 rgb values from the given floats
  4946. * @param r defines the red component to read from
  4947. * @param g defines the green component to read from
  4948. * @param b defines the blue component to read from
  4949. * @returns the current Color3 object
  4950. */
  4951. copyFromFloats(r: number, g: number, b: number): Color3;
  4952. /**
  4953. * Updates the Color3 rgb values from the given floats
  4954. * @param r defines the red component to read from
  4955. * @param g defines the green component to read from
  4956. * @param b defines the blue component to read from
  4957. * @returns the current Color3 object
  4958. */
  4959. set(r: number, g: number, b: number): Color3;
  4960. /**
  4961. * Compute the Color3 hexadecimal code as a string
  4962. * @returns a string containing the hexadecimal representation of the Color3 object
  4963. */
  4964. toHexString(): string;
  4965. /**
  4966. * Computes a new Color3 converted from the current one to linear space
  4967. * @returns a new Color3 object
  4968. */
  4969. toLinearSpace(): Color3;
  4970. /**
  4971. * Converts current color in rgb space to HSV values
  4972. * @returns a new color3 representing the HSV values
  4973. */
  4974. toHSV(): Color3;
  4975. /**
  4976. * Converts current color in rgb space to HSV values
  4977. * @param result defines the Color3 where to store the HSV values
  4978. */
  4979. toHSVToRef(result: Color3): void;
  4980. /**
  4981. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  4982. * @param convertedColor defines the Color3 object where to store the linear space version
  4983. * @returns the unmodified Color3
  4984. */
  4985. toLinearSpaceToRef(convertedColor: Color3): Color3;
  4986. /**
  4987. * Computes a new Color3 converted from the current one to gamma space
  4988. * @returns a new Color3 object
  4989. */
  4990. toGammaSpace(): Color3;
  4991. /**
  4992. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  4993. * @param convertedColor defines the Color3 object where to store the gamma space version
  4994. * @returns the unmodified Color3
  4995. */
  4996. toGammaSpaceToRef(convertedColor: Color3): Color3;
  4997. private static _BlackReadOnly;
  4998. /**
  4999. * Convert Hue, saturation and value to a Color3 (RGB)
  5000. * @param hue defines the hue
  5001. * @param saturation defines the saturation
  5002. * @param value defines the value
  5003. * @param result defines the Color3 where to store the RGB values
  5004. */
  5005. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5006. /**
  5007. * Creates a new Color3 from the string containing valid hexadecimal values
  5008. * @param hex defines a string containing valid hexadecimal values
  5009. * @returns a new Color3 object
  5010. */
  5011. static FromHexString(hex: string): Color3;
  5012. /**
  5013. * Creates a new Color3 from the starting index of the given array
  5014. * @param array defines the source array
  5015. * @param offset defines an offset in the source array
  5016. * @returns a new Color3 object
  5017. */
  5018. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5019. /**
  5020. * Creates a new Color3 from integer values (< 256)
  5021. * @param r defines the red component to read from (value between 0 and 255)
  5022. * @param g defines the green component to read from (value between 0 and 255)
  5023. * @param b defines the blue component to read from (value between 0 and 255)
  5024. * @returns a new Color3 object
  5025. */
  5026. static FromInts(r: number, g: number, b: number): Color3;
  5027. /**
  5028. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5029. * @param start defines the start Color3 value
  5030. * @param end defines the end Color3 value
  5031. * @param amount defines the gradient value between start and end
  5032. * @returns a new Color3 object
  5033. */
  5034. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5035. /**
  5036. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5037. * @param left defines the start value
  5038. * @param right defines the end value
  5039. * @param amount defines the gradient factor
  5040. * @param result defines the Color3 object where to store the result
  5041. */
  5042. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5043. /**
  5044. * Returns a Color3 value containing a red color
  5045. * @returns a new Color3 object
  5046. */
  5047. static Red(): Color3;
  5048. /**
  5049. * Returns a Color3 value containing a green color
  5050. * @returns a new Color3 object
  5051. */
  5052. static Green(): Color3;
  5053. /**
  5054. * Returns a Color3 value containing a blue color
  5055. * @returns a new Color3 object
  5056. */
  5057. static Blue(): Color3;
  5058. /**
  5059. * Returns a Color3 value containing a black color
  5060. * @returns a new Color3 object
  5061. */
  5062. static Black(): Color3;
  5063. /**
  5064. * Gets a Color3 value containing a black color that must not be updated
  5065. */
  5066. static readonly BlackReadOnly: DeepImmutable<Color3>;
  5067. /**
  5068. * Returns a Color3 value containing a white color
  5069. * @returns a new Color3 object
  5070. */
  5071. static White(): Color3;
  5072. /**
  5073. * Returns a Color3 value containing a purple color
  5074. * @returns a new Color3 object
  5075. */
  5076. static Purple(): Color3;
  5077. /**
  5078. * Returns a Color3 value containing a magenta color
  5079. * @returns a new Color3 object
  5080. */
  5081. static Magenta(): Color3;
  5082. /**
  5083. * Returns a Color3 value containing a yellow color
  5084. * @returns a new Color3 object
  5085. */
  5086. static Yellow(): Color3;
  5087. /**
  5088. * Returns a Color3 value containing a gray color
  5089. * @returns a new Color3 object
  5090. */
  5091. static Gray(): Color3;
  5092. /**
  5093. * Returns a Color3 value containing a teal color
  5094. * @returns a new Color3 object
  5095. */
  5096. static Teal(): Color3;
  5097. /**
  5098. * Returns a Color3 value containing a random color
  5099. * @returns a new Color3 object
  5100. */
  5101. static Random(): Color3;
  5102. }
  5103. /**
  5104. * Class used to hold a RBGA color
  5105. */
  5106. export class Color4 {
  5107. /**
  5108. * Defines the red component (between 0 and 1, default is 0)
  5109. */
  5110. r: number;
  5111. /**
  5112. * Defines the green component (between 0 and 1, default is 0)
  5113. */
  5114. g: number;
  5115. /**
  5116. * Defines the blue component (between 0 and 1, default is 0)
  5117. */
  5118. b: number;
  5119. /**
  5120. * Defines the alpha component (between 0 and 1, default is 1)
  5121. */
  5122. a: number;
  5123. /**
  5124. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5125. * @param r defines the red component (between 0 and 1, default is 0)
  5126. * @param g defines the green component (between 0 and 1, default is 0)
  5127. * @param b defines the blue component (between 0 and 1, default is 0)
  5128. * @param a defines the alpha component (between 0 and 1, default is 1)
  5129. */
  5130. constructor(
  5131. /**
  5132. * Defines the red component (between 0 and 1, default is 0)
  5133. */
  5134. r?: number,
  5135. /**
  5136. * Defines the green component (between 0 and 1, default is 0)
  5137. */
  5138. g?: number,
  5139. /**
  5140. * Defines the blue component (between 0 and 1, default is 0)
  5141. */
  5142. b?: number,
  5143. /**
  5144. * Defines the alpha component (between 0 and 1, default is 1)
  5145. */
  5146. a?: number);
  5147. /**
  5148. * Adds in place the given Color4 values to the current Color4 object
  5149. * @param right defines the second operand
  5150. * @returns the current updated Color4 object
  5151. */
  5152. addInPlace(right: DeepImmutable<Color4>): Color4;
  5153. /**
  5154. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5155. * @returns the new array
  5156. */
  5157. asArray(): number[];
  5158. /**
  5159. * Stores from the starting index in the given array the Color4 successive values
  5160. * @param array defines the array where to store the r,g,b components
  5161. * @param index defines an optional index in the target array to define where to start storing values
  5162. * @returns the current Color4 object
  5163. */
  5164. toArray(array: number[], index?: number): Color4;
  5165. /**
  5166. * Determines equality between Color4 objects
  5167. * @param otherColor defines the second operand
  5168. * @returns true if the rgba values are equal to the given ones
  5169. */
  5170. equals(otherColor: DeepImmutable<Color4>): boolean;
  5171. /**
  5172. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5173. * @param right defines the second operand
  5174. * @returns a new Color4 object
  5175. */
  5176. add(right: DeepImmutable<Color4>): Color4;
  5177. /**
  5178. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5179. * @param right defines the second operand
  5180. * @returns a new Color4 object
  5181. */
  5182. subtract(right: DeepImmutable<Color4>): Color4;
  5183. /**
  5184. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5185. * @param right defines the second operand
  5186. * @param result defines the Color4 object where to store the result
  5187. * @returns the current Color4 object
  5188. */
  5189. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5190. /**
  5191. * Creates a new Color4 with the current Color4 values multiplied by scale
  5192. * @param scale defines the scaling factor to apply
  5193. * @returns a new Color4 object
  5194. */
  5195. scale(scale: number): Color4;
  5196. /**
  5197. * Multiplies the current Color4 values by scale and stores the result in "result"
  5198. * @param scale defines the scaling factor to apply
  5199. * @param result defines the Color4 object where to store the result
  5200. * @returns the current unmodified Color4
  5201. */
  5202. scaleToRef(scale: number, result: Color4): Color4;
  5203. /**
  5204. * Scale the current Color4 values by a factor and add the result to a given Color4
  5205. * @param scale defines the scale factor
  5206. * @param result defines the Color4 object where to store the result
  5207. * @returns the unmodified current Color4
  5208. */
  5209. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5210. /**
  5211. * Clamps the rgb values by the min and max values and stores the result into "result"
  5212. * @param min defines minimum clamping value (default is 0)
  5213. * @param max defines maximum clamping value (default is 1)
  5214. * @param result defines color to store the result into.
  5215. * @returns the cuurent Color4
  5216. */
  5217. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5218. /**
  5219. * Multipy an Color4 value by another and return a new Color4 object
  5220. * @param color defines the Color4 value to multiply by
  5221. * @returns a new Color4 object
  5222. */
  5223. multiply(color: Color4): Color4;
  5224. /**
  5225. * Multipy a Color4 value by another and push the result in a reference value
  5226. * @param color defines the Color4 value to multiply by
  5227. * @param result defines the Color4 to fill the result in
  5228. * @returns the result Color4
  5229. */
  5230. multiplyToRef(color: Color4, result: Color4): Color4;
  5231. /**
  5232. * Creates a string with the Color4 current values
  5233. * @returns the string representation of the Color4 object
  5234. */
  5235. toString(): string;
  5236. /**
  5237. * Returns the string "Color4"
  5238. * @returns "Color4"
  5239. */
  5240. getClassName(): string;
  5241. /**
  5242. * Compute the Color4 hash code
  5243. * @returns an unique number that can be used to hash Color4 objects
  5244. */
  5245. getHashCode(): number;
  5246. /**
  5247. * Creates a new Color4 copied from the current one
  5248. * @returns a new Color4 object
  5249. */
  5250. clone(): Color4;
  5251. /**
  5252. * Copies the given Color4 values into the current one
  5253. * @param source defines the source Color4 object
  5254. * @returns the current updated Color4 object
  5255. */
  5256. copyFrom(source: Color4): Color4;
  5257. /**
  5258. * Copies the given float values into the current one
  5259. * @param r defines the red component to read from
  5260. * @param g defines the green component to read from
  5261. * @param b defines the blue component to read from
  5262. * @param a defines the alpha component to read from
  5263. * @returns the current updated Color4 object
  5264. */
  5265. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  5266. /**
  5267. * Copies the given float values into the current one
  5268. * @param r defines the red component to read from
  5269. * @param g defines the green component to read from
  5270. * @param b defines the blue component to read from
  5271. * @param a defines the alpha component to read from
  5272. * @returns the current updated Color4 object
  5273. */
  5274. set(r: number, g: number, b: number, a: number): Color4;
  5275. /**
  5276. * Compute the Color4 hexadecimal code as a string
  5277. * @returns a string containing the hexadecimal representation of the Color4 object
  5278. */
  5279. toHexString(): string;
  5280. /**
  5281. * Computes a new Color4 converted from the current one to linear space
  5282. * @returns a new Color4 object
  5283. */
  5284. toLinearSpace(): Color4;
  5285. /**
  5286. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  5287. * @param convertedColor defines the Color4 object where to store the linear space version
  5288. * @returns the unmodified Color4
  5289. */
  5290. toLinearSpaceToRef(convertedColor: Color4): Color4;
  5291. /**
  5292. * Computes a new Color4 converted from the current one to gamma space
  5293. * @returns a new Color4 object
  5294. */
  5295. toGammaSpace(): Color4;
  5296. /**
  5297. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  5298. * @param convertedColor defines the Color4 object where to store the gamma space version
  5299. * @returns the unmodified Color4
  5300. */
  5301. toGammaSpaceToRef(convertedColor: Color4): Color4;
  5302. /**
  5303. * Creates a new Color4 from the string containing valid hexadecimal values
  5304. * @param hex defines a string containing valid hexadecimal values
  5305. * @returns a new Color4 object
  5306. */
  5307. static FromHexString(hex: string): Color4;
  5308. /**
  5309. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5310. * @param left defines the start value
  5311. * @param right defines the end value
  5312. * @param amount defines the gradient factor
  5313. * @returns a new Color4 object
  5314. */
  5315. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  5316. /**
  5317. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  5318. * @param left defines the start value
  5319. * @param right defines the end value
  5320. * @param amount defines the gradient factor
  5321. * @param result defines the Color4 object where to store data
  5322. */
  5323. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  5324. /**
  5325. * Creates a new Color4 from a Color3 and an alpha value
  5326. * @param color3 defines the source Color3 to read from
  5327. * @param alpha defines the alpha component (1.0 by default)
  5328. * @returns a new Color4 object
  5329. */
  5330. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  5331. /**
  5332. * Creates a new Color4 from the starting index element of the given array
  5333. * @param array defines the source array to read from
  5334. * @param offset defines the offset in the source array
  5335. * @returns a new Color4 object
  5336. */
  5337. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5338. /**
  5339. * Creates a new Color3 from integer values (< 256)
  5340. * @param r defines the red component to read from (value between 0 and 255)
  5341. * @param g defines the green component to read from (value between 0 and 255)
  5342. * @param b defines the blue component to read from (value between 0 and 255)
  5343. * @param a defines the alpha component to read from (value between 0 and 255)
  5344. * @returns a new Color3 object
  5345. */
  5346. static FromInts(r: number, g: number, b: number, a: number): Color4;
  5347. /**
  5348. * Check the content of a given array and convert it to an array containing RGBA data
  5349. * If the original array was already containing count * 4 values then it is returned directly
  5350. * @param colors defines the array to check
  5351. * @param count defines the number of RGBA data to expect
  5352. * @returns an array containing count * 4 values (RGBA)
  5353. */
  5354. static CheckColors4(colors: number[], count: number): number[];
  5355. }
  5356. /**
  5357. * @hidden
  5358. */
  5359. export class TmpColors {
  5360. static Color3: Color3[];
  5361. static Color4: Color4[];
  5362. }
  5363. }
  5364. declare module BABYLON {
  5365. /**
  5366. * Class representing spherical harmonics coefficients to the 3rd degree
  5367. */
  5368. export class SphericalHarmonics {
  5369. /**
  5370. * Defines whether or not the harmonics have been prescaled for rendering.
  5371. */
  5372. preScaled: boolean;
  5373. /**
  5374. * The l0,0 coefficients of the spherical harmonics
  5375. */
  5376. l00: Vector3;
  5377. /**
  5378. * The l1,-1 coefficients of the spherical harmonics
  5379. */
  5380. l1_1: Vector3;
  5381. /**
  5382. * The l1,0 coefficients of the spherical harmonics
  5383. */
  5384. l10: Vector3;
  5385. /**
  5386. * The l1,1 coefficients of the spherical harmonics
  5387. */
  5388. l11: Vector3;
  5389. /**
  5390. * The l2,-2 coefficients of the spherical harmonics
  5391. */
  5392. l2_2: Vector3;
  5393. /**
  5394. * The l2,-1 coefficients of the spherical harmonics
  5395. */
  5396. l2_1: Vector3;
  5397. /**
  5398. * The l2,0 coefficients of the spherical harmonics
  5399. */
  5400. l20: Vector3;
  5401. /**
  5402. * The l2,1 coefficients of the spherical harmonics
  5403. */
  5404. l21: Vector3;
  5405. /**
  5406. * The l2,2 coefficients of the spherical harmonics
  5407. */
  5408. l22: Vector3;
  5409. /**
  5410. * Adds a light to the spherical harmonics
  5411. * @param direction the direction of the light
  5412. * @param color the color of the light
  5413. * @param deltaSolidAngle the delta solid angle of the light
  5414. */
  5415. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5416. /**
  5417. * Scales the spherical harmonics by the given amount
  5418. * @param scale the amount to scale
  5419. */
  5420. scaleInPlace(scale: number): void;
  5421. /**
  5422. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5423. *
  5424. * ```
  5425. * E_lm = A_l * L_lm
  5426. * ```
  5427. *
  5428. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5429. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5430. * the scaling factors are given in equation 9.
  5431. */
  5432. convertIncidentRadianceToIrradiance(): void;
  5433. /**
  5434. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5435. *
  5436. * ```
  5437. * L = (1/pi) * E * rho
  5438. * ```
  5439. *
  5440. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5441. */
  5442. convertIrradianceToLambertianRadiance(): void;
  5443. /**
  5444. * Integrates the reconstruction coefficients directly in to the SH preventing further
  5445. * required operations at run time.
  5446. *
  5447. * This is simply done by scaling back the SH with Ylm constants parameter.
  5448. * The trigonometric part being applied by the shader at run time.
  5449. */
  5450. preScaleForRendering(): void;
  5451. /**
  5452. * Constructs a spherical harmonics from an array.
  5453. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5454. * @returns the spherical harmonics
  5455. */
  5456. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5457. /**
  5458. * Gets the spherical harmonics from polynomial
  5459. * @param polynomial the spherical polynomial
  5460. * @returns the spherical harmonics
  5461. */
  5462. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5463. }
  5464. /**
  5465. * Class representing spherical polynomial coefficients to the 3rd degree
  5466. */
  5467. export class SphericalPolynomial {
  5468. private _harmonics;
  5469. /**
  5470. * The spherical harmonics used to create the polynomials.
  5471. */
  5472. readonly preScaledHarmonics: SphericalHarmonics;
  5473. /**
  5474. * The x coefficients of the spherical polynomial
  5475. */
  5476. x: Vector3;
  5477. /**
  5478. * The y coefficients of the spherical polynomial
  5479. */
  5480. y: Vector3;
  5481. /**
  5482. * The z coefficients of the spherical polynomial
  5483. */
  5484. z: Vector3;
  5485. /**
  5486. * The xx coefficients of the spherical polynomial
  5487. */
  5488. xx: Vector3;
  5489. /**
  5490. * The yy coefficients of the spherical polynomial
  5491. */
  5492. yy: Vector3;
  5493. /**
  5494. * The zz coefficients of the spherical polynomial
  5495. */
  5496. zz: Vector3;
  5497. /**
  5498. * The xy coefficients of the spherical polynomial
  5499. */
  5500. xy: Vector3;
  5501. /**
  5502. * The yz coefficients of the spherical polynomial
  5503. */
  5504. yz: Vector3;
  5505. /**
  5506. * The zx coefficients of the spherical polynomial
  5507. */
  5508. zx: Vector3;
  5509. /**
  5510. * Adds an ambient color to the spherical polynomial
  5511. * @param color the color to add
  5512. */
  5513. addAmbient(color: Color3): void;
  5514. /**
  5515. * Scales the spherical polynomial by the given amount
  5516. * @param scale the amount to scale
  5517. */
  5518. scaleInPlace(scale: number): void;
  5519. /**
  5520. * Gets the spherical polynomial from harmonics
  5521. * @param harmonics the spherical harmonics
  5522. * @returns the spherical polynomial
  5523. */
  5524. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5525. /**
  5526. * Constructs a spherical polynomial from an array.
  5527. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5528. * @returns the spherical polynomial
  5529. */
  5530. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5531. }
  5532. }
  5533. declare module BABYLON {
  5534. /**
  5535. * Define options used to create a render target texture
  5536. */
  5537. export class RenderTargetCreationOptions {
  5538. /**
  5539. * Specifies is mipmaps must be generated
  5540. */
  5541. generateMipMaps?: boolean;
  5542. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  5543. generateDepthBuffer?: boolean;
  5544. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  5545. generateStencilBuffer?: boolean;
  5546. /** Defines texture type (int by default) */
  5547. type?: number;
  5548. /** Defines sampling mode (trilinear by default) */
  5549. samplingMode?: number;
  5550. /** Defines format (RGBA by default) */
  5551. format?: number;
  5552. }
  5553. }
  5554. declare module BABYLON {
  5555. /**
  5556. * @hidden
  5557. **/
  5558. export class _AlphaState {
  5559. private _isAlphaBlendDirty;
  5560. private _isBlendFunctionParametersDirty;
  5561. private _isBlendEquationParametersDirty;
  5562. private _isBlendConstantsDirty;
  5563. private _alphaBlend;
  5564. private _blendFunctionParameters;
  5565. private _blendEquationParameters;
  5566. private _blendConstants;
  5567. /**
  5568. * Initializes the state.
  5569. */
  5570. constructor();
  5571. readonly isDirty: boolean;
  5572. alphaBlend: boolean;
  5573. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  5574. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  5575. setAlphaEquationParameters(rgb: number, alpha: number): void;
  5576. reset(): void;
  5577. apply(gl: WebGLRenderingContext): void;
  5578. }
  5579. }
  5580. declare module BABYLON {
  5581. /**
  5582. * @hidden
  5583. **/
  5584. export class _DepthCullingState {
  5585. private _isDepthTestDirty;
  5586. private _isDepthMaskDirty;
  5587. private _isDepthFuncDirty;
  5588. private _isCullFaceDirty;
  5589. private _isCullDirty;
  5590. private _isZOffsetDirty;
  5591. private _isFrontFaceDirty;
  5592. private _depthTest;
  5593. private _depthMask;
  5594. private _depthFunc;
  5595. private _cull;
  5596. private _cullFace;
  5597. private _zOffset;
  5598. private _frontFace;
  5599. /**
  5600. * Initializes the state.
  5601. */
  5602. constructor();
  5603. readonly isDirty: boolean;
  5604. zOffset: number;
  5605. cullFace: Nullable<number>;
  5606. cull: Nullable<boolean>;
  5607. depthFunc: Nullable<number>;
  5608. depthMask: boolean;
  5609. depthTest: boolean;
  5610. frontFace: Nullable<number>;
  5611. reset(): void;
  5612. apply(gl: WebGLRenderingContext): void;
  5613. }
  5614. }
  5615. declare module BABYLON {
  5616. /**
  5617. * @hidden
  5618. **/
  5619. export class _StencilState {
  5620. /** 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 */
  5621. static readonly ALWAYS: number;
  5622. /** Passed to stencilOperation to specify that stencil value must be kept */
  5623. static readonly KEEP: number;
  5624. /** Passed to stencilOperation to specify that stencil value must be replaced */
  5625. static readonly REPLACE: number;
  5626. private _isStencilTestDirty;
  5627. private _isStencilMaskDirty;
  5628. private _isStencilFuncDirty;
  5629. private _isStencilOpDirty;
  5630. private _stencilTest;
  5631. private _stencilMask;
  5632. private _stencilFunc;
  5633. private _stencilFuncRef;
  5634. private _stencilFuncMask;
  5635. private _stencilOpStencilFail;
  5636. private _stencilOpDepthFail;
  5637. private _stencilOpStencilDepthPass;
  5638. readonly isDirty: boolean;
  5639. stencilFunc: number;
  5640. stencilFuncRef: number;
  5641. stencilFuncMask: number;
  5642. stencilOpStencilFail: number;
  5643. stencilOpDepthFail: number;
  5644. stencilOpStencilDepthPass: number;
  5645. stencilMask: number;
  5646. stencilTest: boolean;
  5647. constructor();
  5648. reset(): void;
  5649. apply(gl: WebGLRenderingContext): void;
  5650. }
  5651. }
  5652. declare module BABYLON {
  5653. /**
  5654. * @hidden
  5655. **/
  5656. export class _TimeToken { private _startTimeQuery: Nullable<WebGLQuery>; private _endTimeQuery: Nullable<WebGLQuery>; private _timeElapsedQuery: Nullable<WebGLQuery>; private _timeElapsedQueryEnded: boolean;
  5657. }
  5658. }
  5659. declare module BABYLON {
  5660. /**
  5661. * Class used to evalaute queries containing `and` and `or` operators
  5662. */
  5663. export class AndOrNotEvaluator {
  5664. /**
  5665. * Evaluate a query
  5666. * @param query defines the query to evaluate
  5667. * @param evaluateCallback defines the callback used to filter result
  5668. * @returns true if the query matches
  5669. */
  5670. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5671. private static _HandleParenthesisContent;
  5672. private static _SimplifyNegation;
  5673. }
  5674. }
  5675. declare module BABYLON {
  5676. /**
  5677. * Class used to store custom tags
  5678. */
  5679. export class Tags {
  5680. /**
  5681. * Adds support for tags on the given object
  5682. * @param obj defines the object to use
  5683. */
  5684. static EnableFor(obj: any): void;
  5685. /**
  5686. * Removes tags support
  5687. * @param obj defines the object to use
  5688. */
  5689. static DisableFor(obj: any): void;
  5690. /**
  5691. * Gets a boolean indicating if the given object has tags
  5692. * @param obj defines the object to use
  5693. * @returns a boolean
  5694. */
  5695. static HasTags(obj: any): boolean;
  5696. /**
  5697. * Gets the tags available on a given object
  5698. * @param obj defines the object to use
  5699. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5700. * @returns the tags
  5701. */
  5702. static GetTags(obj: any, asString?: boolean): any;
  5703. /**
  5704. * Adds tags to an object
  5705. * @param obj defines the object to use
  5706. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5707. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5708. */
  5709. static AddTagsTo(obj: any, tagsString: string): void;
  5710. /**
  5711. * @hidden
  5712. */ private static _AddTagTo(obj: any, tag: string): void;
  5713. /**
  5714. * Removes specific tags from a specific object
  5715. * @param obj defines the object to use
  5716. * @param tagsString defines the tags to remove
  5717. */
  5718. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5719. /**
  5720. * @hidden
  5721. */ private static _RemoveTagFrom(obj: any, tag: string): void;
  5722. /**
  5723. * Defines if tags hosted on an object match a given query
  5724. * @param obj defines the object to use
  5725. * @param tagsQuery defines the tag query
  5726. * @returns a boolean
  5727. */
  5728. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5729. }
  5730. }
  5731. declare module BABYLON {
  5732. /**
  5733. * Defines potential orientation for back face culling
  5734. */
  5735. export enum Orientation {
  5736. /**
  5737. * Clockwise
  5738. */
  5739. CW = 0,
  5740. /** Counter clockwise */
  5741. CCW = 1
  5742. }
  5743. /** Class used to represent a Bezier curve */
  5744. export class BezierCurve {
  5745. /**
  5746. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5747. * @param t defines the time
  5748. * @param x1 defines the left coordinate on X axis
  5749. * @param y1 defines the left coordinate on Y axis
  5750. * @param x2 defines the right coordinate on X axis
  5751. * @param y2 defines the right coordinate on Y axis
  5752. * @returns the interpolated value
  5753. */
  5754. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5755. }
  5756. /**
  5757. * Defines angle representation
  5758. */
  5759. export class Angle {
  5760. private _radians;
  5761. /**
  5762. * Creates an Angle object of "radians" radians (float).
  5763. * @param radians the angle in radians
  5764. */
  5765. constructor(radians: number);
  5766. /**
  5767. * Get value in degrees
  5768. * @returns the Angle value in degrees (float)
  5769. */
  5770. degrees(): number;
  5771. /**
  5772. * Get value in radians
  5773. * @returns the Angle value in radians (float)
  5774. */
  5775. radians(): number;
  5776. /**
  5777. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5778. * @param a defines first vector
  5779. * @param b defines second vector
  5780. * @returns a new Angle
  5781. */
  5782. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5783. /**
  5784. * Gets a new Angle object from the given float in radians
  5785. * @param radians defines the angle value in radians
  5786. * @returns a new Angle
  5787. */
  5788. static FromRadians(radians: number): Angle;
  5789. /**
  5790. * Gets a new Angle object from the given float in degrees
  5791. * @param degrees defines the angle value in degrees
  5792. * @returns a new Angle
  5793. */
  5794. static FromDegrees(degrees: number): Angle;
  5795. }
  5796. /**
  5797. * This represents an arc in a 2d space.
  5798. */
  5799. export class Arc2 {
  5800. /** Defines the start point of the arc */
  5801. startPoint: Vector2;
  5802. /** Defines the mid point of the arc */
  5803. midPoint: Vector2;
  5804. /** Defines the end point of the arc */
  5805. endPoint: Vector2;
  5806. /**
  5807. * Defines the center point of the arc.
  5808. */
  5809. centerPoint: Vector2;
  5810. /**
  5811. * Defines the radius of the arc.
  5812. */
  5813. radius: number;
  5814. /**
  5815. * Defines the angle of the arc (from mid point to end point).
  5816. */
  5817. angle: Angle;
  5818. /**
  5819. * Defines the start angle of the arc (from start point to middle point).
  5820. */
  5821. startAngle: Angle;
  5822. /**
  5823. * Defines the orientation of the arc (clock wise/counter clock wise).
  5824. */
  5825. orientation: Orientation;
  5826. /**
  5827. * Creates an Arc object from the three given points : start, middle and end.
  5828. * @param startPoint Defines the start point of the arc
  5829. * @param midPoint Defines the midlle point of the arc
  5830. * @param endPoint Defines the end point of the arc
  5831. */
  5832. constructor(
  5833. /** Defines the start point of the arc */
  5834. startPoint: Vector2,
  5835. /** Defines the mid point of the arc */
  5836. midPoint: Vector2,
  5837. /** Defines the end point of the arc */
  5838. endPoint: Vector2);
  5839. }
  5840. /**
  5841. * Represents a 2D path made up of multiple 2D points
  5842. */
  5843. export class Path2 {
  5844. private _points;
  5845. private _length;
  5846. /**
  5847. * If the path start and end point are the same
  5848. */
  5849. closed: boolean;
  5850. /**
  5851. * Creates a Path2 object from the starting 2D coordinates x and y.
  5852. * @param x the starting points x value
  5853. * @param y the starting points y value
  5854. */
  5855. constructor(x: number, y: number);
  5856. /**
  5857. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5858. * @param x the added points x value
  5859. * @param y the added points y value
  5860. * @returns the updated Path2.
  5861. */
  5862. addLineTo(x: number, y: number): Path2;
  5863. /**
  5864. * 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.
  5865. * @param midX middle point x value
  5866. * @param midY middle point y value
  5867. * @param endX end point x value
  5868. * @param endY end point y value
  5869. * @param numberOfSegments (default: 36)
  5870. * @returns the updated Path2.
  5871. */
  5872. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5873. /**
  5874. * Closes the Path2.
  5875. * @returns the Path2.
  5876. */
  5877. close(): Path2;
  5878. /**
  5879. * Gets the sum of the distance between each sequential point in the path
  5880. * @returns the Path2 total length (float).
  5881. */
  5882. length(): number;
  5883. /**
  5884. * Gets the points which construct the path
  5885. * @returns the Path2 internal array of points.
  5886. */
  5887. getPoints(): Vector2[];
  5888. /**
  5889. * Retreives the point at the distance aways from the starting point
  5890. * @param normalizedLengthPosition the length along the path to retreive the point from
  5891. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5892. */
  5893. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5894. /**
  5895. * Creates a new path starting from an x and y position
  5896. * @param x starting x value
  5897. * @param y starting y value
  5898. * @returns a new Path2 starting at the coordinates (x, y).
  5899. */
  5900. static StartingAt(x: number, y: number): Path2;
  5901. }
  5902. /**
  5903. * Represents a 3D path made up of multiple 3D points
  5904. */
  5905. export class Path3D {
  5906. /**
  5907. * an array of Vector3, the curve axis of the Path3D
  5908. */
  5909. path: Vector3[];
  5910. private _curve;
  5911. private _distances;
  5912. private _tangents;
  5913. private _normals;
  5914. private _binormals;
  5915. private _raw;
  5916. /**
  5917. * new Path3D(path, normal, raw)
  5918. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5919. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5920. * @param path an array of Vector3, the curve axis of the Path3D
  5921. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5922. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5923. */
  5924. constructor(
  5925. /**
  5926. * an array of Vector3, the curve axis of the Path3D
  5927. */
  5928. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5929. /**
  5930. * Returns the Path3D array of successive Vector3 designing its curve.
  5931. * @returns the Path3D array of successive Vector3 designing its curve.
  5932. */
  5933. getCurve(): Vector3[];
  5934. /**
  5935. * Returns an array populated with tangent vectors on each Path3D curve point.
  5936. * @returns an array populated with tangent vectors on each Path3D curve point.
  5937. */
  5938. getTangents(): Vector3[];
  5939. /**
  5940. * Returns an array populated with normal vectors on each Path3D curve point.
  5941. * @returns an array populated with normal vectors on each Path3D curve point.
  5942. */
  5943. getNormals(): Vector3[];
  5944. /**
  5945. * Returns an array populated with binormal vectors on each Path3D curve point.
  5946. * @returns an array populated with binormal vectors on each Path3D curve point.
  5947. */
  5948. getBinormals(): Vector3[];
  5949. /**
  5950. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5951. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5952. */
  5953. getDistances(): number[];
  5954. /**
  5955. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5956. * @param path path which all values are copied into the curves points
  5957. * @param firstNormal which should be projected onto the curve
  5958. * @returns the same object updated.
  5959. */
  5960. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5961. private _compute;
  5962. private _getFirstNonNullVector;
  5963. private _getLastNonNullVector;
  5964. private _normalVector;
  5965. }
  5966. /**
  5967. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5968. * A Curve3 is designed from a series of successive Vector3.
  5969. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5970. */
  5971. export class Curve3 {
  5972. private _points;
  5973. private _length;
  5974. /**
  5975. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5976. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5977. * @param v1 (Vector3) the control point
  5978. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5979. * @param nbPoints (integer) the wanted number of points in the curve
  5980. * @returns the created Curve3
  5981. */
  5982. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5983. /**
  5984. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5985. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5986. * @param v1 (Vector3) the first control point
  5987. * @param v2 (Vector3) the second control point
  5988. * @param v3 (Vector3) the end point of the Cubic Bezier
  5989. * @param nbPoints (integer) the wanted number of points in the curve
  5990. * @returns the created Curve3
  5991. */
  5992. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5993. /**
  5994. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5995. * @param p1 (Vector3) the origin point of the Hermite Spline
  5996. * @param t1 (Vector3) the tangent vector at the origin point
  5997. * @param p2 (Vector3) the end point of the Hermite Spline
  5998. * @param t2 (Vector3) the tangent vector at the end point
  5999. * @param nbPoints (integer) the wanted number of points in the curve
  6000. * @returns the created Curve3
  6001. */
  6002. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  6003. /**
  6004. * Returns a Curve3 object along a CatmullRom Spline curve :
  6005. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  6006. * @param nbPoints (integer) the wanted number of points between each curve control points
  6007. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  6008. * @returns the created Curve3
  6009. */
  6010. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  6011. /**
  6012. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  6013. * A Curve3 is designed from a series of successive Vector3.
  6014. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  6015. * @param points points which make up the curve
  6016. */
  6017. constructor(points: Vector3[]);
  6018. /**
  6019. * @returns the Curve3 stored array of successive Vector3
  6020. */
  6021. getPoints(): Vector3[];
  6022. /**
  6023. * @returns the computed length (float) of the curve.
  6024. */
  6025. length(): number;
  6026. /**
  6027. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  6028. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  6029. * curveA and curveB keep unchanged.
  6030. * @param curve the curve to continue from this curve
  6031. * @returns the newly constructed curve
  6032. */
  6033. continue(curve: DeepImmutable<Curve3>): Curve3;
  6034. private _computeLength;
  6035. }
  6036. }
  6037. declare module BABYLON {
  6038. /**
  6039. * This represents the main contract an easing function should follow.
  6040. * Easing functions are used throughout the animation system.
  6041. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6042. */
  6043. export interface IEasingFunction {
  6044. /**
  6045. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6046. * of the easing function.
  6047. * The link below provides some of the most common examples of easing functions.
  6048. * @see https://easings.net/
  6049. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6050. * @returns the corresponding value on the curve defined by the easing function
  6051. */
  6052. ease(gradient: number): number;
  6053. }
  6054. /**
  6055. * Base class used for every default easing function.
  6056. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6057. */
  6058. export class EasingFunction implements IEasingFunction {
  6059. /**
  6060. * Interpolation follows the mathematical formula associated with the easing function.
  6061. */
  6062. static readonly EASINGMODE_EASEIN: number;
  6063. /**
  6064. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6065. */
  6066. static readonly EASINGMODE_EASEOUT: number;
  6067. /**
  6068. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6069. */
  6070. static readonly EASINGMODE_EASEINOUT: number;
  6071. private _easingMode;
  6072. /**
  6073. * Sets the easing mode of the current function.
  6074. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6075. */
  6076. setEasingMode(easingMode: number): void;
  6077. /**
  6078. * Gets the current easing mode.
  6079. * @returns the easing mode
  6080. */
  6081. getEasingMode(): number;
  6082. /**
  6083. * @hidden
  6084. */
  6085. easeInCore(gradient: number): number;
  6086. /**
  6087. * Given an input gradient between 0 and 1, this returns the corresponding value
  6088. * of the easing function.
  6089. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6090. * @returns the corresponding value on the curve defined by the easing function
  6091. */
  6092. ease(gradient: number): number;
  6093. }
  6094. /**
  6095. * Easing function with a circle shape (see link below).
  6096. * @see https://easings.net/#easeInCirc
  6097. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6098. */
  6099. export class CircleEase extends EasingFunction implements IEasingFunction {
  6100. /** @hidden */
  6101. easeInCore(gradient: number): number;
  6102. }
  6103. /**
  6104. * Easing function with a ease back shape (see link below).
  6105. * @see https://easings.net/#easeInBack
  6106. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6107. */
  6108. export class BackEase extends EasingFunction implements IEasingFunction {
  6109. /** Defines the amplitude of the function */
  6110. amplitude: number;
  6111. /**
  6112. * Instantiates a back ease easing
  6113. * @see https://easings.net/#easeInBack
  6114. * @param amplitude Defines the amplitude of the function
  6115. */
  6116. constructor(
  6117. /** Defines the amplitude of the function */
  6118. amplitude?: number);
  6119. /** @hidden */
  6120. easeInCore(gradient: number): number;
  6121. }
  6122. /**
  6123. * Easing function with a bouncing shape (see link below).
  6124. * @see https://easings.net/#easeInBounce
  6125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6126. */
  6127. export class BounceEase extends EasingFunction implements IEasingFunction {
  6128. /** Defines the number of bounces */
  6129. bounces: number;
  6130. /** Defines the amplitude of the bounce */
  6131. bounciness: number;
  6132. /**
  6133. * Instantiates a bounce easing
  6134. * @see https://easings.net/#easeInBounce
  6135. * @param bounces Defines the number of bounces
  6136. * @param bounciness Defines the amplitude of the bounce
  6137. */
  6138. constructor(
  6139. /** Defines the number of bounces */
  6140. bounces?: number,
  6141. /** Defines the amplitude of the bounce */
  6142. bounciness?: number);
  6143. /** @hidden */
  6144. easeInCore(gradient: number): number;
  6145. }
  6146. /**
  6147. * Easing function with a power of 3 shape (see link below).
  6148. * @see https://easings.net/#easeInCubic
  6149. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6150. */
  6151. export class CubicEase extends EasingFunction implements IEasingFunction {
  6152. /** @hidden */
  6153. easeInCore(gradient: number): number;
  6154. }
  6155. /**
  6156. * Easing function with an elastic shape (see link below).
  6157. * @see https://easings.net/#easeInElastic
  6158. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6159. */
  6160. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6161. /** Defines the number of oscillations*/
  6162. oscillations: number;
  6163. /** Defines the amplitude of the oscillations*/
  6164. springiness: number;
  6165. /**
  6166. * Instantiates an elastic easing function
  6167. * @see https://easings.net/#easeInElastic
  6168. * @param oscillations Defines the number of oscillations
  6169. * @param springiness Defines the amplitude of the oscillations
  6170. */
  6171. constructor(
  6172. /** Defines the number of oscillations*/
  6173. oscillations?: number,
  6174. /** Defines the amplitude of the oscillations*/
  6175. springiness?: number);
  6176. /** @hidden */
  6177. easeInCore(gradient: number): number;
  6178. }
  6179. /**
  6180. * Easing function with an exponential shape (see link below).
  6181. * @see https://easings.net/#easeInExpo
  6182. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6183. */
  6184. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6185. /** Defines the exponent of the function */
  6186. exponent: number;
  6187. /**
  6188. * Instantiates an exponential easing function
  6189. * @see https://easings.net/#easeInExpo
  6190. * @param exponent Defines the exponent of the function
  6191. */
  6192. constructor(
  6193. /** Defines the exponent of the function */
  6194. exponent?: number);
  6195. /** @hidden */
  6196. easeInCore(gradient: number): number;
  6197. }
  6198. /**
  6199. * Easing function with a power shape (see link below).
  6200. * @see https://easings.net/#easeInQuad
  6201. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6202. */
  6203. export class PowerEase extends EasingFunction implements IEasingFunction {
  6204. /** Defines the power of the function */
  6205. power: number;
  6206. /**
  6207. * Instantiates an power base easing function
  6208. * @see https://easings.net/#easeInQuad
  6209. * @param power Defines the power of the function
  6210. */
  6211. constructor(
  6212. /** Defines the power of the function */
  6213. power?: number);
  6214. /** @hidden */
  6215. easeInCore(gradient: number): number;
  6216. }
  6217. /**
  6218. * Easing function with a power of 2 shape (see link below).
  6219. * @see https://easings.net/#easeInQuad
  6220. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6221. */
  6222. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6223. /** @hidden */
  6224. easeInCore(gradient: number): number;
  6225. }
  6226. /**
  6227. * Easing function with a power of 4 shape (see link below).
  6228. * @see https://easings.net/#easeInQuart
  6229. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6230. */
  6231. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6232. /** @hidden */
  6233. easeInCore(gradient: number): number;
  6234. }
  6235. /**
  6236. * Easing function with a power of 5 shape (see link below).
  6237. * @see https://easings.net/#easeInQuint
  6238. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6239. */
  6240. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6241. /** @hidden */
  6242. easeInCore(gradient: number): number;
  6243. }
  6244. /**
  6245. * Easing function with a sin shape (see link below).
  6246. * @see https://easings.net/#easeInSine
  6247. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6248. */
  6249. export class SineEase extends EasingFunction implements IEasingFunction {
  6250. /** @hidden */
  6251. easeInCore(gradient: number): number;
  6252. }
  6253. /**
  6254. * Easing function with a bezier shape (see link below).
  6255. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6256. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6257. */
  6258. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6259. /** Defines the x component of the start tangent in the bezier curve */
  6260. x1: number;
  6261. /** Defines the y component of the start tangent in the bezier curve */
  6262. y1: number;
  6263. /** Defines the x component of the end tangent in the bezier curve */
  6264. x2: number;
  6265. /** Defines the y component of the end tangent in the bezier curve */
  6266. y2: number;
  6267. /**
  6268. * Instantiates a bezier function
  6269. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6270. * @param x1 Defines the x component of the start tangent in the bezier curve
  6271. * @param y1 Defines the y component of the start tangent in the bezier curve
  6272. * @param x2 Defines the x component of the end tangent in the bezier curve
  6273. * @param y2 Defines the y component of the end tangent in the bezier curve
  6274. */
  6275. constructor(
  6276. /** Defines the x component of the start tangent in the bezier curve */
  6277. x1?: number,
  6278. /** Defines the y component of the start tangent in the bezier curve */
  6279. y1?: number,
  6280. /** Defines the x component of the end tangent in the bezier curve */
  6281. x2?: number,
  6282. /** Defines the y component of the end tangent in the bezier curve */
  6283. y2?: number);
  6284. /** @hidden */
  6285. easeInCore(gradient: number): number;
  6286. }
  6287. }
  6288. declare module BABYLON {
  6289. /**
  6290. * Defines an interface which represents an animation key frame
  6291. */
  6292. export interface IAnimationKey {
  6293. /**
  6294. * Frame of the key frame
  6295. */
  6296. frame: number;
  6297. /**
  6298. * Value at the specifies key frame
  6299. */
  6300. value: any;
  6301. /**
  6302. * The input tangent for the cubic hermite spline
  6303. */
  6304. inTangent?: any;
  6305. /**
  6306. * The output tangent for the cubic hermite spline
  6307. */
  6308. outTangent?: any;
  6309. /**
  6310. * The animation interpolation type
  6311. */
  6312. interpolation?: AnimationKeyInterpolation;
  6313. }
  6314. /**
  6315. * Enum for the animation key frame interpolation type
  6316. */
  6317. export enum AnimationKeyInterpolation {
  6318. /**
  6319. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6320. */
  6321. STEP = 1
  6322. }
  6323. }
  6324. declare module BABYLON {
  6325. /**
  6326. * Represents the range of an animation
  6327. */
  6328. export class AnimationRange {
  6329. /**The name of the animation range**/
  6330. name: string;
  6331. /**The starting frame of the animation */
  6332. from: number;
  6333. /**The ending frame of the animation*/
  6334. to: number;
  6335. /**
  6336. * Initializes the range of an animation
  6337. * @param name The name of the animation range
  6338. * @param from The starting frame of the animation
  6339. * @param to The ending frame of the animation
  6340. */
  6341. constructor(
  6342. /**The name of the animation range**/
  6343. name: string,
  6344. /**The starting frame of the animation */
  6345. from: number,
  6346. /**The ending frame of the animation*/
  6347. to: number);
  6348. /**
  6349. * Makes a copy of the animation range
  6350. * @returns A copy of the animation range
  6351. */
  6352. clone(): AnimationRange;
  6353. }
  6354. }
  6355. declare module BABYLON {
  6356. /**
  6357. * Composed of a frame, and an action function
  6358. */
  6359. export class AnimationEvent {
  6360. /** The frame for which the event is triggered **/
  6361. frame: number;
  6362. /** The event to perform when triggered **/
  6363. action: (currentFrame: number) => void;
  6364. /** Specifies if the event should be triggered only once**/
  6365. onlyOnce?: boolean | undefined;
  6366. /**
  6367. * Specifies if the animation event is done
  6368. */
  6369. isDone: boolean;
  6370. /**
  6371. * Initializes the animation event
  6372. * @param frame The frame for which the event is triggered
  6373. * @param action The event to perform when triggered
  6374. * @param onlyOnce Specifies if the event should be triggered only once
  6375. */
  6376. constructor(
  6377. /** The frame for which the event is triggered **/
  6378. frame: number,
  6379. /** The event to perform when triggered **/
  6380. action: (currentFrame: number) => void,
  6381. /** Specifies if the event should be triggered only once**/
  6382. onlyOnce?: boolean | undefined);
  6383. /** @hidden */ private _clone(): AnimationEvent;
  6384. }
  6385. }
  6386. declare module BABYLON {
  6387. /**
  6388. * Interface used to define a behavior
  6389. */
  6390. export interface Behavior<T> {
  6391. /** gets or sets behavior's name */
  6392. name: string;
  6393. /**
  6394. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6395. */
  6396. init(): void;
  6397. /**
  6398. * Called when the behavior is attached to a target
  6399. * @param target defines the target where the behavior is attached to
  6400. */
  6401. attach(target: T): void;
  6402. /**
  6403. * Called when the behavior is detached from its target
  6404. */
  6405. detach(): void;
  6406. }
  6407. /**
  6408. * Interface implemented by classes supporting behaviors
  6409. */
  6410. export interface IBehaviorAware<T> {
  6411. /**
  6412. * Attach a behavior
  6413. * @param behavior defines the behavior to attach
  6414. * @returns the current host
  6415. */
  6416. addBehavior(behavior: Behavior<T>): T;
  6417. /**
  6418. * Remove a behavior from the current object
  6419. * @param behavior defines the behavior to detach
  6420. * @returns the current host
  6421. */
  6422. removeBehavior(behavior: Behavior<T>): T;
  6423. /**
  6424. * Gets a behavior using its name to search
  6425. * @param name defines the name to search
  6426. * @returns the behavior or null if not found
  6427. */
  6428. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6429. }
  6430. }
  6431. declare module BABYLON {
  6432. /**
  6433. * Defines an array and its length.
  6434. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6435. */
  6436. export interface ISmartArrayLike<T> {
  6437. /**
  6438. * The data of the array.
  6439. */
  6440. data: Array<T>;
  6441. /**
  6442. * The active length of the array.
  6443. */
  6444. length: number;
  6445. }
  6446. /**
  6447. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6448. */
  6449. export class SmartArray<T> implements ISmartArrayLike<T> {
  6450. /**
  6451. * The full set of data from the array.
  6452. */
  6453. data: Array<T>;
  6454. /**
  6455. * The active length of the array.
  6456. */
  6457. length: number;
  6458. protected _id: number;
  6459. /**
  6460. * Instantiates a Smart Array.
  6461. * @param capacity defines the default capacity of the array.
  6462. */
  6463. constructor(capacity: number);
  6464. /**
  6465. * Pushes a value at the end of the active data.
  6466. * @param value defines the object to push in the array.
  6467. */
  6468. push(value: T): void;
  6469. /**
  6470. * Iterates over the active data and apply the lambda to them.
  6471. * @param func defines the action to apply on each value.
  6472. */
  6473. forEach(func: (content: T) => void): void;
  6474. /**
  6475. * Sorts the full sets of data.
  6476. * @param compareFn defines the comparison function to apply.
  6477. */
  6478. sort(compareFn: (a: T, b: T) => number): void;
  6479. /**
  6480. * Resets the active data to an empty array.
  6481. */
  6482. reset(): void;
  6483. /**
  6484. * Releases all the data from the array as well as the array.
  6485. */
  6486. dispose(): void;
  6487. /**
  6488. * Concats the active data with a given array.
  6489. * @param array defines the data to concatenate with.
  6490. */
  6491. concat(array: any): void;
  6492. /**
  6493. * Returns the position of a value in the active data.
  6494. * @param value defines the value to find the index for
  6495. * @returns the index if found in the active data otherwise -1
  6496. */
  6497. indexOf(value: T): number;
  6498. /**
  6499. * Returns whether an element is part of the active data.
  6500. * @param value defines the value to look for
  6501. * @returns true if found in the active data otherwise false
  6502. */
  6503. contains(value: T): boolean;
  6504. private static _GlobalId;
  6505. }
  6506. /**
  6507. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6508. * The data in this array can only be present once
  6509. */
  6510. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6511. private _duplicateId;
  6512. /**
  6513. * Pushes a value at the end of the active data.
  6514. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6515. * @param value defines the object to push in the array.
  6516. */
  6517. push(value: T): void;
  6518. /**
  6519. * Pushes a value at the end of the active data.
  6520. * If the data is already present, it won t be added again
  6521. * @param value defines the object to push in the array.
  6522. * @returns true if added false if it was already present
  6523. */
  6524. pushNoDuplicate(value: T): boolean;
  6525. /**
  6526. * Resets the active data to an empty array.
  6527. */
  6528. reset(): void;
  6529. /**
  6530. * Concats the active data with a given array.
  6531. * This ensures no dupplicate will be present in the result.
  6532. * @param array defines the data to concatenate with.
  6533. */
  6534. concatWithNoDuplicate(array: any): void;
  6535. }
  6536. }
  6537. declare module BABYLON {
  6538. /**
  6539. * @ignore
  6540. * This is a list of all the different input types that are available in the application.
  6541. * Fo instance: ArcRotateCameraGamepadInput...
  6542. */
  6543. export var CameraInputTypes: {};
  6544. /**
  6545. * This is the contract to implement in order to create a new input class.
  6546. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6547. */
  6548. export interface ICameraInput<TCamera extends Camera> {
  6549. /**
  6550. * Defines the camera the input is attached to.
  6551. */
  6552. camera: Nullable<TCamera>;
  6553. /**
  6554. * Gets the class name of the current intput.
  6555. * @returns the class name
  6556. */
  6557. getClassName(): string;
  6558. /**
  6559. * Get the friendly name associated with the input class.
  6560. * @returns the input friendly name
  6561. */
  6562. getSimpleName(): string;
  6563. /**
  6564. * Attach the input controls to a specific dom element to get the input from.
  6565. * @param element Defines the element the controls should be listened from
  6566. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6567. */
  6568. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6569. /**
  6570. * Detach the current controls from the specified dom element.
  6571. * @param element Defines the element to stop listening the inputs from
  6572. */
  6573. detachControl(element: Nullable<HTMLElement>): void;
  6574. /**
  6575. * Update the current camera state depending on the inputs that have been used this frame.
  6576. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6577. */
  6578. checkInputs?: () => void;
  6579. }
  6580. /**
  6581. * Represents a map of input types to input instance or input index to input instance.
  6582. */
  6583. export interface CameraInputsMap<TCamera extends Camera> {
  6584. /**
  6585. * Accessor to the input by input type.
  6586. */
  6587. [name: string]: ICameraInput<TCamera>;
  6588. /**
  6589. * Accessor to the input by input index.
  6590. */
  6591. [idx: number]: ICameraInput<TCamera>;
  6592. }
  6593. /**
  6594. * This represents the input manager used within a camera.
  6595. * It helps dealing with all the different kind of input attached to a camera.
  6596. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6597. */
  6598. export class CameraInputsManager<TCamera extends Camera> {
  6599. /**
  6600. * Defines the list of inputs attahed to the camera.
  6601. */
  6602. attached: CameraInputsMap<TCamera>;
  6603. /**
  6604. * Defines the dom element the camera is collecting inputs from.
  6605. * This is null if the controls have not been attached.
  6606. */
  6607. attachedElement: Nullable<HTMLElement>;
  6608. /**
  6609. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6610. */
  6611. noPreventDefault: boolean;
  6612. /**
  6613. * Defined the camera the input manager belongs to.
  6614. */
  6615. camera: TCamera;
  6616. /**
  6617. * Update the current camera state depending on the inputs that have been used this frame.
  6618. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6619. */
  6620. checkInputs: () => void;
  6621. /**
  6622. * Instantiate a new Camera Input Manager.
  6623. * @param camera Defines the camera the input manager blongs to
  6624. */
  6625. constructor(camera: TCamera);
  6626. /**
  6627. * Add an input method to a camera
  6628. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6629. * @param input camera input method
  6630. */
  6631. add(input: ICameraInput<TCamera>): void;
  6632. /**
  6633. * Remove a specific input method from a camera
  6634. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6635. * @param inputToRemove camera input method
  6636. */
  6637. remove(inputToRemove: ICameraInput<TCamera>): void;
  6638. /**
  6639. * Remove a specific input type from a camera
  6640. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6641. * @param inputType the type of the input to remove
  6642. */
  6643. removeByType(inputType: string): void;
  6644. private _addCheckInputs;
  6645. /**
  6646. * Attach the input controls to the currently attached dom element to listen the events from.
  6647. * @param input Defines the input to attach
  6648. */
  6649. attachInput(input: ICameraInput<TCamera>): void;
  6650. /**
  6651. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6652. * @param element Defines the dom element to collect the events from
  6653. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6654. */
  6655. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6656. /**
  6657. * Detach the current manager inputs controls from a specific dom element.
  6658. * @param element Defines the dom element to collect the events from
  6659. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6660. */
  6661. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6662. /**
  6663. * Rebuild the dynamic inputCheck function from the current list of
  6664. * defined inputs in the manager.
  6665. */
  6666. rebuildInputCheck(): void;
  6667. /**
  6668. * Remove all attached input methods from a camera
  6669. */
  6670. clear(): void;
  6671. /**
  6672. * Serialize the current input manager attached to a camera.
  6673. * This ensures than once parsed,
  6674. * the input associated to the camera will be identical to the current ones
  6675. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6676. */
  6677. serialize(serializedCamera: any): void;
  6678. /**
  6679. * Parses an input manager serialized JSON to restore the previous list of inputs
  6680. * and states associated to a camera.
  6681. * @param parsedCamera Defines the JSON to parse
  6682. */
  6683. parse(parsedCamera: any): void;
  6684. }
  6685. }
  6686. declare module BABYLON {
  6687. /**
  6688. * @hidden
  6689. */
  6690. export class IntersectionInfo {
  6691. bu: Nullable<number>;
  6692. bv: Nullable<number>;
  6693. distance: number;
  6694. faceId: number;
  6695. subMeshId: number;
  6696. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6697. }
  6698. }
  6699. declare module BABYLON {
  6700. /**
  6701. * Represens a plane by the equation ax + by + cz + d = 0
  6702. */
  6703. export class Plane {
  6704. private static _TmpMatrix;
  6705. /**
  6706. * Normal of the plane (a,b,c)
  6707. */
  6708. normal: Vector3;
  6709. /**
  6710. * d component of the plane
  6711. */
  6712. d: number;
  6713. /**
  6714. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6715. * @param a a component of the plane
  6716. * @param b b component of the plane
  6717. * @param c c component of the plane
  6718. * @param d d component of the plane
  6719. */
  6720. constructor(a: number, b: number, c: number, d: number);
  6721. /**
  6722. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6723. */
  6724. asArray(): number[];
  6725. /**
  6726. * @returns a new plane copied from the current Plane.
  6727. */
  6728. clone(): Plane;
  6729. /**
  6730. * @returns the string "Plane".
  6731. */
  6732. getClassName(): string;
  6733. /**
  6734. * @returns the Plane hash code.
  6735. */
  6736. getHashCode(): number;
  6737. /**
  6738. * Normalize the current Plane in place.
  6739. * @returns the updated Plane.
  6740. */
  6741. normalize(): Plane;
  6742. /**
  6743. * Applies a transformation the plane and returns the result
  6744. * @param transformation the transformation matrix to be applied to the plane
  6745. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6746. */
  6747. transform(transformation: DeepImmutable<Matrix>): Plane;
  6748. /**
  6749. * Calcualtte the dot product between the point and the plane normal
  6750. * @param point point to calculate the dot product with
  6751. * @returns the dot product (float) of the point coordinates and the plane normal.
  6752. */
  6753. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6754. /**
  6755. * Updates the current Plane from the plane defined by the three given points.
  6756. * @param point1 one of the points used to contruct the plane
  6757. * @param point2 one of the points used to contruct the plane
  6758. * @param point3 one of the points used to contruct the plane
  6759. * @returns the updated Plane.
  6760. */
  6761. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6762. /**
  6763. * Checks if the plane is facing a given direction
  6764. * @param direction the direction to check if the plane is facing
  6765. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6766. * @returns True is the vector "direction" is the same side than the plane normal.
  6767. */
  6768. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6769. /**
  6770. * Calculates the distance to a point
  6771. * @param point point to calculate distance to
  6772. * @returns the signed distance (float) from the given point to the Plane.
  6773. */
  6774. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6775. /**
  6776. * Creates a plane from an array
  6777. * @param array the array to create a plane from
  6778. * @returns a new Plane from the given array.
  6779. */
  6780. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6781. /**
  6782. * Creates a plane from three points
  6783. * @param point1 point used to create the plane
  6784. * @param point2 point used to create the plane
  6785. * @param point3 point used to create the plane
  6786. * @returns a new Plane defined by the three given points.
  6787. */
  6788. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6789. /**
  6790. * Creates a plane from an origin point and a normal
  6791. * @param origin origin of the plane to be constructed
  6792. * @param normal normal of the plane to be constructed
  6793. * @returns a new Plane the normal vector to this plane at the given origin point.
  6794. * Note : the vector "normal" is updated because normalized.
  6795. */
  6796. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6797. /**
  6798. * Calculates the distance from a plane and a point
  6799. * @param origin origin of the plane to be constructed
  6800. * @param normal normal of the plane to be constructed
  6801. * @param point point to calculate distance to
  6802. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6803. */
  6804. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6805. }
  6806. }
  6807. declare module BABYLON {
  6808. /**
  6809. * Class used to store bounding sphere information
  6810. */
  6811. export class BoundingSphere {
  6812. /**
  6813. * Gets the center of the bounding sphere in local space
  6814. */
  6815. readonly center: Vector3;
  6816. /**
  6817. * Radius of the bounding sphere in local space
  6818. */
  6819. radius: number;
  6820. /**
  6821. * Gets the center of the bounding sphere in world space
  6822. */
  6823. readonly centerWorld: Vector3;
  6824. /**
  6825. * Radius of the bounding sphere in world space
  6826. */
  6827. radiusWorld: number;
  6828. /**
  6829. * Gets the minimum vector in local space
  6830. */
  6831. readonly minimum: Vector3;
  6832. /**
  6833. * Gets the maximum vector in local space
  6834. */
  6835. readonly maximum: Vector3;
  6836. private _worldMatrix;
  6837. private static readonly TmpVector3;
  6838. /**
  6839. * Creates a new bounding sphere
  6840. * @param min defines the minimum vector (in local space)
  6841. * @param max defines the maximum vector (in local space)
  6842. * @param worldMatrix defines the new world matrix
  6843. */
  6844. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6845. /**
  6846. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6847. * @param min defines the new minimum vector (in local space)
  6848. * @param max defines the new maximum vector (in local space)
  6849. * @param worldMatrix defines the new world matrix
  6850. */
  6851. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6852. /**
  6853. * Scale the current bounding sphere by applying a scale factor
  6854. * @param factor defines the scale factor to apply
  6855. * @returns the current bounding box
  6856. */
  6857. scale(factor: number): BoundingSphere;
  6858. /**
  6859. * Gets the world matrix of the bounding box
  6860. * @returns a matrix
  6861. */
  6862. getWorldMatrix(): DeepImmutable<Matrix>;
  6863. /** @hidden */ private _update(worldMatrix: DeepImmutable<Matrix>): void;
  6864. /**
  6865. * Tests if the bounding sphere is intersecting the frustum planes
  6866. * @param frustumPlanes defines the frustum planes to test
  6867. * @returns true if there is an intersection
  6868. */
  6869. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6870. /**
  6871. * Tests if the bounding sphere center is in between the frustum planes.
  6872. * Used for optimistic fast inclusion.
  6873. * @param frustumPlanes defines the frustum planes to test
  6874. * @returns true if the sphere center is in between the frustum planes
  6875. */
  6876. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6877. /**
  6878. * Tests if a point is inside the bounding sphere
  6879. * @param point defines the point to test
  6880. * @returns true if the point is inside the bounding sphere
  6881. */
  6882. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6883. /**
  6884. * Checks if two sphere intersct
  6885. * @param sphere0 sphere 0
  6886. * @param sphere1 sphere 1
  6887. * @returns true if the speres intersect
  6888. */
  6889. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6890. }
  6891. }
  6892. declare module BABYLON {
  6893. /**
  6894. * Class used to store bounding box information
  6895. */
  6896. export class BoundingBox implements ICullable {
  6897. /**
  6898. * Gets the 8 vectors representing the bounding box in local space
  6899. */
  6900. readonly vectors: Vector3[];
  6901. /**
  6902. * Gets the center of the bounding box in local space
  6903. */
  6904. readonly center: Vector3;
  6905. /**
  6906. * Gets the center of the bounding box in world space
  6907. */
  6908. readonly centerWorld: Vector3;
  6909. /**
  6910. * Gets the extend size in local space
  6911. */
  6912. readonly extendSize: Vector3;
  6913. /**
  6914. * Gets the extend size in world space
  6915. */
  6916. readonly extendSizeWorld: Vector3;
  6917. /**
  6918. * Gets the OBB (object bounding box) directions
  6919. */
  6920. readonly directions: Vector3[];
  6921. /**
  6922. * Gets the 8 vectors representing the bounding box in world space
  6923. */
  6924. readonly vectorsWorld: Vector3[];
  6925. /**
  6926. * Gets the minimum vector in world space
  6927. */
  6928. readonly minimumWorld: Vector3;
  6929. /**
  6930. * Gets the maximum vector in world space
  6931. */
  6932. readonly maximumWorld: Vector3;
  6933. /**
  6934. * Gets the minimum vector in local space
  6935. */
  6936. readonly minimum: Vector3;
  6937. /**
  6938. * Gets the maximum vector in local space
  6939. */
  6940. readonly maximum: Vector3;
  6941. private _worldMatrix;
  6942. private static readonly TmpVector3;
  6943. /**
  6944. * @hidden
  6945. */ private _tag: number;
  6946. /**
  6947. * Creates a new bounding box
  6948. * @param min defines the minimum vector (in local space)
  6949. * @param max defines the maximum vector (in local space)
  6950. * @param worldMatrix defines the new world matrix
  6951. */
  6952. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6953. /**
  6954. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6955. * @param min defines the new minimum vector (in local space)
  6956. * @param max defines the new maximum vector (in local space)
  6957. * @param worldMatrix defines the new world matrix
  6958. */
  6959. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6960. /**
  6961. * Scale the current bounding box by applying a scale factor
  6962. * @param factor defines the scale factor to apply
  6963. * @returns the current bounding box
  6964. */
  6965. scale(factor: number): BoundingBox;
  6966. /**
  6967. * Gets the world matrix of the bounding box
  6968. * @returns a matrix
  6969. */
  6970. getWorldMatrix(): DeepImmutable<Matrix>;
  6971. /** @hidden */ private _update(world: DeepImmutable<Matrix>): void;
  6972. /**
  6973. * Tests if the bounding box is intersecting the frustum planes
  6974. * @param frustumPlanes defines the frustum planes to test
  6975. * @returns true if there is an intersection
  6976. */
  6977. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6978. /**
  6979. * Tests if the bounding box is entirely inside the frustum planes
  6980. * @param frustumPlanes defines the frustum planes to test
  6981. * @returns true if there is an inclusion
  6982. */
  6983. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6984. /**
  6985. * Tests if a point is inside the bounding box
  6986. * @param point defines the point to test
  6987. * @returns true if the point is inside the bounding box
  6988. */
  6989. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6990. /**
  6991. * Tests if the bounding box intersects with a bounding sphere
  6992. * @param sphere defines the sphere to test
  6993. * @returns true if there is an intersection
  6994. */
  6995. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6996. /**
  6997. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6998. * @param min defines the min vector to use
  6999. * @param max defines the max vector to use
  7000. * @returns true if there is an intersection
  7001. */
  7002. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7003. /**
  7004. * Tests if two bounding boxes are intersections
  7005. * @param box0 defines the first box to test
  7006. * @param box1 defines the second box to test
  7007. * @returns true if there is an intersection
  7008. */
  7009. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7010. /**
  7011. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7012. * @param minPoint defines the minimum vector of the bounding box
  7013. * @param maxPoint defines the maximum vector of the bounding box
  7014. * @param sphereCenter defines the sphere center
  7015. * @param sphereRadius defines the sphere radius
  7016. * @returns true if there is an intersection
  7017. */
  7018. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7019. /**
  7020. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7021. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7022. * @param frustumPlanes defines the frustum planes to test
  7023. * @return true if there is an inclusion
  7024. */
  7025. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7026. /**
  7027. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7028. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7029. * @param frustumPlanes defines the frustum planes to test
  7030. * @return true if there is an intersection
  7031. */
  7032. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7033. }
  7034. }
  7035. declare module BABYLON {
  7036. /** @hidden */
  7037. export class Collider {
  7038. /** Define if a collision was found */
  7039. collisionFound: boolean;
  7040. /**
  7041. * Define last intersection point in local space
  7042. */
  7043. intersectionPoint: Vector3;
  7044. /**
  7045. * Define last collided mesh
  7046. */
  7047. collidedMesh: Nullable<AbstractMesh>;
  7048. private _collisionPoint;
  7049. private _planeIntersectionPoint;
  7050. private _tempVector;
  7051. private _tempVector2;
  7052. private _tempVector3;
  7053. private _tempVector4;
  7054. private _edge;
  7055. private _baseToVertex;
  7056. private _destinationPoint;
  7057. private _slidePlaneNormal;
  7058. private _displacementVector;
  7059. /** @hidden */ private _radius: Vector3;
  7060. /** @hidden */ private _retry: number;
  7061. private _velocity;
  7062. private _basePoint;
  7063. private _epsilon;
  7064. /** @hidden */ private _velocityWorldLength: number;
  7065. /** @hidden */ private _basePointWorld: Vector3;
  7066. private _velocityWorld;
  7067. private _normalizedVelocity;
  7068. /** @hidden */ private _initialVelocity: Vector3;
  7069. /** @hidden */ private _initialPosition: Vector3;
  7070. private _nearestDistance;
  7071. private _collisionMask;
  7072. collisionMask: number;
  7073. /**
  7074. * Gets the plane normal used to compute the sliding response (in local space)
  7075. */
  7076. readonly slidePlaneNormal: Vector3;
  7077. /** @hidden */ private _initialize(source: Vector3, dir: Vector3, e: number): void;
  7078. /** @hidden */ private _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7079. /** @hidden */ private _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7080. /** @hidden */ private _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7081. /** @hidden */ private _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7082. /** @hidden */ private _getResponse(pos: Vector3, vel: Vector3): void;
  7083. }
  7084. }
  7085. declare module BABYLON {
  7086. /**
  7087. * Interface for cullable objects
  7088. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7089. */
  7090. export interface ICullable {
  7091. /**
  7092. * Checks if the object or part of the object is in the frustum
  7093. * @param frustumPlanes Camera near/planes
  7094. * @returns true if the object is in frustum otherwise false
  7095. */
  7096. isInFrustum(frustumPlanes: Plane[]): boolean;
  7097. /**
  7098. * Checks if a cullable object (mesh...) is in the camera frustum
  7099. * Unlike isInFrustum this cheks the full bounding box
  7100. * @param frustumPlanes Camera near/planes
  7101. * @returns true if the object is in frustum otherwise false
  7102. */
  7103. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7104. }
  7105. /**
  7106. * Info for a bounding data of a mesh
  7107. */
  7108. export class BoundingInfo implements ICullable {
  7109. /**
  7110. * Bounding box for the mesh
  7111. */
  7112. readonly boundingBox: BoundingBox;
  7113. /**
  7114. * Bounding sphere for the mesh
  7115. */
  7116. readonly boundingSphere: BoundingSphere;
  7117. private _isLocked;
  7118. private static readonly TmpVector3;
  7119. /**
  7120. * Constructs bounding info
  7121. * @param minimum min vector of the bounding box/sphere
  7122. * @param maximum max vector of the bounding box/sphere
  7123. * @param worldMatrix defines the new world matrix
  7124. */
  7125. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7126. /**
  7127. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7128. * @param min defines the new minimum vector (in local space)
  7129. * @param max defines the new maximum vector (in local space)
  7130. * @param worldMatrix defines the new world matrix
  7131. */
  7132. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7133. /**
  7134. * min vector of the bounding box/sphere
  7135. */
  7136. readonly minimum: Vector3;
  7137. /**
  7138. * max vector of the bounding box/sphere
  7139. */
  7140. readonly maximum: Vector3;
  7141. /**
  7142. * If the info is locked and won't be updated to avoid perf overhead
  7143. */
  7144. isLocked: boolean;
  7145. /**
  7146. * Updates the bounding sphere and box
  7147. * @param world world matrix to be used to update
  7148. */
  7149. update(world: DeepImmutable<Matrix>): void;
  7150. /**
  7151. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7152. * @param center New center of the bounding info
  7153. * @param extend New extend of the bounding info
  7154. * @returns the current bounding info
  7155. */
  7156. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7157. /**
  7158. * Scale the current bounding info by applying a scale factor
  7159. * @param factor defines the scale factor to apply
  7160. * @returns the current bounding info
  7161. */
  7162. scale(factor: number): BoundingInfo;
  7163. /**
  7164. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7165. * @param frustumPlanes defines the frustum to test
  7166. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7167. * @returns true if the bounding info is in the frustum planes
  7168. */
  7169. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7170. /**
  7171. * Gets the world distance between the min and max points of the bounding box
  7172. */
  7173. readonly diagonalLength: number;
  7174. /**
  7175. * Checks if a cullable object (mesh...) is in the camera frustum
  7176. * Unlike isInFrustum this cheks the full bounding box
  7177. * @param frustumPlanes Camera near/planes
  7178. * @returns true if the object is in frustum otherwise false
  7179. */
  7180. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7181. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  7182. /**
  7183. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7184. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7185. * @param point the point to check intersection with
  7186. * @returns if the point intersects
  7187. */
  7188. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7189. /**
  7190. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7191. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7192. * @param boundingInfo the bounding info to check intersection with
  7193. * @param precise if the intersection should be done using OBB
  7194. * @returns if the bounding info intersects
  7195. */
  7196. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7197. }
  7198. }
  7199. declare module BABYLON {
  7200. /**
  7201. * Extracts minimum and maximum values from a list of indexed positions
  7202. * @param positions defines the positions to use
  7203. * @param indices defines the indices to the positions
  7204. * @param indexStart defines the start index
  7205. * @param indexCount defines the end index
  7206. * @param bias defines bias value to add to the result
  7207. * @return minimum and maximum values
  7208. */
  7209. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7210. minimum: Vector3;
  7211. maximum: Vector3;
  7212. };
  7213. /**
  7214. * Extracts minimum and maximum values from a list of positions
  7215. * @param positions defines the positions to use
  7216. * @param start defines the start index in the positions array
  7217. * @param count defines the number of positions to handle
  7218. * @param bias defines bias value to add to the result
  7219. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7220. * @return minimum and maximum values
  7221. */
  7222. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7223. minimum: Vector3;
  7224. maximum: Vector3;
  7225. };
  7226. }
  7227. declare module BABYLON {
  7228. /**
  7229. * Enum that determines the text-wrapping mode to use.
  7230. */
  7231. export enum InspectableType {
  7232. /**
  7233. * Checkbox for booleans
  7234. */
  7235. Checkbox = 0,
  7236. /**
  7237. * Sliders for numbers
  7238. */
  7239. Slider = 1,
  7240. /**
  7241. * Vector3
  7242. */
  7243. Vector3 = 2,
  7244. /**
  7245. * Quaternions
  7246. */
  7247. Quaternion = 3,
  7248. /**
  7249. * Color3
  7250. */
  7251. Color3 = 4,
  7252. /**
  7253. * String
  7254. */
  7255. String = 5
  7256. }
  7257. /**
  7258. * Interface used to define custom inspectable properties.
  7259. * This interface is used by the inspector to display custom property grids
  7260. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7261. */
  7262. export interface IInspectable {
  7263. /**
  7264. * Gets the label to display
  7265. */
  7266. label: string;
  7267. /**
  7268. * Gets the name of the property to edit
  7269. */
  7270. propertyName: string;
  7271. /**
  7272. * Gets the type of the editor to use
  7273. */
  7274. type: InspectableType;
  7275. /**
  7276. * Gets the minimum value of the property when using in "slider" mode
  7277. */
  7278. min?: number;
  7279. /**
  7280. * Gets the maximum value of the property when using in "slider" mode
  7281. */
  7282. max?: number;
  7283. /**
  7284. * Gets the setp to use when using in "slider" mode
  7285. */
  7286. step?: number;
  7287. }
  7288. }
  7289. declare module BABYLON {
  7290. /**
  7291. * Class used to provide helper for timing
  7292. */
  7293. export class TimingTools {
  7294. /**
  7295. * Polyfill for setImmediate
  7296. * @param action defines the action to execute after the current execution block
  7297. */
  7298. static SetImmediate(action: () => void): void;
  7299. }
  7300. }
  7301. declare module BABYLON {
  7302. /**
  7303. * Class used to enable instatition of objects by class name
  7304. */
  7305. export class InstantiationTools {
  7306. /**
  7307. * Use this object to register external classes like custom textures or material
  7308. * to allow the laoders to instantiate them
  7309. */
  7310. static RegisteredExternalClasses: {
  7311. [key: string]: Object;
  7312. };
  7313. /**
  7314. * Tries to instantiate a new object from a given class name
  7315. * @param className defines the class name to instantiate
  7316. * @returns the new object or null if the system was not able to do the instantiation
  7317. */
  7318. static Instantiate(className: string): any;
  7319. }
  7320. }
  7321. declare module BABYLON {
  7322. /**
  7323. * This represents the required contract to create a new type of texture loader.
  7324. */
  7325. export interface IInternalTextureLoader {
  7326. /**
  7327. * Defines wether the loader supports cascade loading the different faces.
  7328. */
  7329. supportCascades: boolean;
  7330. /**
  7331. * This returns if the loader support the current file information.
  7332. * @param extension defines the file extension of the file being loaded
  7333. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7334. * @param fallback defines the fallback internal texture if any
  7335. * @param isBase64 defines whether the texture is encoded as a base64
  7336. * @param isBuffer defines whether the texture data are stored as a buffer
  7337. * @returns true if the loader can load the specified file
  7338. */
  7339. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  7340. /**
  7341. * Transform the url before loading if required.
  7342. * @param rootUrl the url of the texture
  7343. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7344. * @returns the transformed texture
  7345. */
  7346. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  7347. /**
  7348. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  7349. * @param rootUrl the url of the texture
  7350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  7351. * @returns the fallback texture
  7352. */
  7353. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  7354. /**
  7355. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  7356. * @param data contains the texture data
  7357. * @param texture defines the BabylonJS internal texture
  7358. * @param createPolynomials will be true if polynomials have been requested
  7359. * @param onLoad defines the callback to trigger once the texture is ready
  7360. * @param onError defines the callback to trigger in case of error
  7361. */
  7362. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  7363. /**
  7364. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  7365. * @param data contains the texture data
  7366. * @param texture defines the BabylonJS internal texture
  7367. * @param callback defines the method to call once ready to upload
  7368. */
  7369. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  7370. }
  7371. }
  7372. declare module BABYLON {
  7373. interface Engine {
  7374. /**
  7375. * Creates a depth stencil cube texture.
  7376. * This is only available in WebGL 2.
  7377. * @param size The size of face edge in the cube texture.
  7378. * @param options The options defining the cube texture.
  7379. * @returns The cube texture
  7380. */ private _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7381. /**
  7382. * Creates a cube texture
  7383. * @param rootUrl defines the url where the files to load is located
  7384. * @param scene defines the current scene
  7385. * @param files defines the list of files to load (1 per face)
  7386. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7387. * @param onLoad defines an optional callback raised when the texture is loaded
  7388. * @param onError defines an optional callback raised if there is an issue to load the texture
  7389. * @param format defines the format of the data
  7390. * @param forcedExtension defines the extension to use to pick the right loader
  7391. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7392. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7393. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7394. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7395. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7396. * @returns the cube texture as an InternalTexture
  7397. */
  7398. 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;
  7399. /**
  7400. * Creates a cube texture
  7401. * @param rootUrl defines the url where the files to load is located
  7402. * @param scene defines the current scene
  7403. * @param files defines the list of files to load (1 per face)
  7404. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7405. * @param onLoad defines an optional callback raised when the texture is loaded
  7406. * @param onError defines an optional callback raised if there is an issue to load the texture
  7407. * @param format defines the format of the data
  7408. * @param forcedExtension defines the extension to use to pick the right loader
  7409. * @returns the cube texture as an InternalTexture
  7410. */
  7411. 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;
  7412. /**
  7413. * Creates a cube texture
  7414. * @param rootUrl defines the url where the files to load is located
  7415. * @param scene defines the current scene
  7416. * @param files defines the list of files to load (1 per face)
  7417. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7418. * @param onLoad defines an optional callback raised when the texture is loaded
  7419. * @param onError defines an optional callback raised if there is an issue to load the texture
  7420. * @param format defines the format of the data
  7421. * @param forcedExtension defines the extension to use to pick the right loader
  7422. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7423. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7424. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7425. * @returns the cube texture as an InternalTexture
  7426. */
  7427. 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;
  7428. /** @hidden */ private _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7429. /** @hidden */ private _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7430. /** @hidden */ private _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7431. /** @hidden */ private _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7432. }
  7433. }
  7434. declare module BABYLON {
  7435. /**
  7436. * Class for creating a cube texture
  7437. */
  7438. export class CubeTexture extends BaseTexture {
  7439. private _delayedOnLoad;
  7440. /**
  7441. * The url of the texture
  7442. */
  7443. url: string;
  7444. /**
  7445. * Gets or sets the center of the bounding box associated with the cube texture.
  7446. * It must define where the camera used to render the texture was set
  7447. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7448. */
  7449. boundingBoxPosition: Vector3;
  7450. private _boundingBoxSize;
  7451. /**
  7452. * Gets or sets the size of the bounding box associated with the cube texture
  7453. * When defined, the cubemap will switch to local mode
  7454. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7455. * @example https://www.babylonjs-playground.com/#RNASML
  7456. */
  7457. /**
  7458. * Returns the bounding box size
  7459. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7460. */
  7461. boundingBoxSize: Vector3;
  7462. protected _rotationY: number;
  7463. /**
  7464. * Sets texture matrix rotation angle around Y axis in radians.
  7465. */
  7466. /**
  7467. * Gets texture matrix rotation angle around Y axis radians.
  7468. */
  7469. rotationY: number;
  7470. /**
  7471. * Are mip maps generated for this texture or not.
  7472. */
  7473. readonly noMipmap: boolean;
  7474. private _noMipmap;
  7475. private _files;
  7476. private _extensions;
  7477. private _textureMatrix;
  7478. private _format;
  7479. private _createPolynomials;
  7480. /** @hidden */ private _prefiltered: boolean;
  7481. /**
  7482. * Creates a cube texture from an array of image urls
  7483. * @param files defines an array of image urls
  7484. * @param scene defines the hosting scene
  7485. * @param noMipmap specifies if mip maps are not used
  7486. * @returns a cube texture
  7487. */
  7488. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7489. /**
  7490. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7491. * @param url defines the url of the prefiltered texture
  7492. * @param scene defines the scene the texture is attached to
  7493. * @param forcedExtension defines the extension of the file if different from the url
  7494. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7495. * @return the prefiltered texture
  7496. */
  7497. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7498. /**
  7499. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7500. * as prefiltered data.
  7501. * @param rootUrl defines the url of the texture or the root name of the six images
  7502. * @param scene defines the scene the texture is attached to
  7503. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7504. * @param noMipmap defines if mipmaps should be created or not
  7505. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7506. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7507. * @param onError defines a callback triggered in case of error during load
  7508. * @param format defines the internal format to use for the texture once loaded
  7509. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7510. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7511. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7512. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7513. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7514. * @return the cube texture
  7515. */
  7516. 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);
  7517. /**
  7518. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7519. */
  7520. readonly isPrefiltered: boolean;
  7521. /**
  7522. * Get the current class name of the texture useful for serialization or dynamic coding.
  7523. * @returns "CubeTexture"
  7524. */
  7525. getClassName(): string;
  7526. /**
  7527. * Update the url (and optional buffer) of this texture if url was null during construction.
  7528. * @param url the url of the texture
  7529. * @param forcedExtension defines the extension to use
  7530. * @param onLoad callback called when the texture is loaded (defaults to null)
  7531. */
  7532. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7533. /**
  7534. * Delays loading of the cube texture
  7535. * @param forcedExtension defines the extension to use
  7536. */
  7537. delayLoad(forcedExtension?: string): void;
  7538. /**
  7539. * Returns the reflection texture matrix
  7540. * @returns the reflection texture matrix
  7541. */
  7542. getReflectionTextureMatrix(): Matrix;
  7543. /**
  7544. * Sets the reflection texture matrix
  7545. * @param value Reflection texture matrix
  7546. */
  7547. setReflectionTextureMatrix(value: Matrix): void;
  7548. /**
  7549. * Parses text to create a cube texture
  7550. * @param parsedTexture define the serialized text to read from
  7551. * @param scene defines the hosting scene
  7552. * @param rootUrl defines the root url of the cube texture
  7553. * @returns a cube texture
  7554. */
  7555. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7556. /**
  7557. * Makes a clone, or deep copy, of the cube texture
  7558. * @returns a new cube texture
  7559. */
  7560. clone(): CubeTexture;
  7561. }
  7562. }
  7563. declare module BABYLON {
  7564. /**
  7565. * Manages the defines for the Material
  7566. */
  7567. export class MaterialDefines {
  7568. /** @hidden */
  7569. protected _keys: string[];
  7570. private _isDirty;
  7571. /** @hidden */ private _renderId: number;
  7572. /** @hidden */ private _areLightsDirty: boolean;
  7573. /** @hidden */ private _areAttributesDirty: boolean;
  7574. /** @hidden */ private _areTexturesDirty: boolean;
  7575. /** @hidden */ private _areFresnelDirty: boolean;
  7576. /** @hidden */ private _areMiscDirty: boolean;
  7577. /** @hidden */ private _areImageProcessingDirty: boolean;
  7578. /** @hidden */ private _normals: boolean;
  7579. /** @hidden */ private _uvs: boolean;
  7580. /** @hidden */ private _needNormals: boolean;
  7581. /** @hidden */ private _needUVs: boolean;
  7582. [id: string]: any;
  7583. /**
  7584. * Specifies if the material needs to be re-calculated
  7585. */
  7586. readonly isDirty: boolean;
  7587. /**
  7588. * Marks the material to indicate that it has been re-calculated
  7589. */
  7590. markAsProcessed(): void;
  7591. /**
  7592. * Marks the material to indicate that it needs to be re-calculated
  7593. */
  7594. markAsUnprocessed(): void;
  7595. /**
  7596. * Marks the material to indicate all of its defines need to be re-calculated
  7597. */
  7598. markAllAsDirty(): void;
  7599. /**
  7600. * Marks the material to indicate that image processing needs to be re-calculated
  7601. */
  7602. markAsImageProcessingDirty(): void;
  7603. /**
  7604. * Marks the material to indicate the lights need to be re-calculated
  7605. */
  7606. markAsLightDirty(): void;
  7607. /**
  7608. * Marks the attribute state as changed
  7609. */
  7610. markAsAttributesDirty(): void;
  7611. /**
  7612. * Marks the texture state as changed
  7613. */
  7614. markAsTexturesDirty(): void;
  7615. /**
  7616. * Marks the fresnel state as changed
  7617. */
  7618. markAsFresnelDirty(): void;
  7619. /**
  7620. * Marks the misc state as changed
  7621. */
  7622. markAsMiscDirty(): void;
  7623. /**
  7624. * Rebuilds the material defines
  7625. */
  7626. rebuild(): void;
  7627. /**
  7628. * Specifies if two material defines are equal
  7629. * @param other - A material define instance to compare to
  7630. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7631. */
  7632. isEqual(other: MaterialDefines): boolean;
  7633. /**
  7634. * Clones this instance's defines to another instance
  7635. * @param other - material defines to clone values to
  7636. */
  7637. cloneTo(other: MaterialDefines): void;
  7638. /**
  7639. * Resets the material define values
  7640. */
  7641. reset(): void;
  7642. /**
  7643. * Converts the material define values to a string
  7644. * @returns - String of material define information
  7645. */
  7646. toString(): string;
  7647. }
  7648. }
  7649. declare module BABYLON {
  7650. /**
  7651. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7652. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7653. * 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;
  7654. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7655. */
  7656. export class ColorCurves {
  7657. private _dirty;
  7658. private _tempColor;
  7659. private _globalCurve;
  7660. private _highlightsCurve;
  7661. private _midtonesCurve;
  7662. private _shadowsCurve;
  7663. private _positiveCurve;
  7664. private _negativeCurve;
  7665. private _globalHue;
  7666. private _globalDensity;
  7667. private _globalSaturation;
  7668. private _globalExposure;
  7669. /**
  7670. * Gets the global Hue value.
  7671. * 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).
  7672. */
  7673. /**
  7674. * Sets the global Hue value.
  7675. * 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).
  7676. */
  7677. globalHue: number;
  7678. /**
  7679. * Gets the global Density value.
  7680. * 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.
  7681. * Values less than zero provide a filter of opposite hue.
  7682. */
  7683. /**
  7684. * Sets the global Density value.
  7685. * 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.
  7686. * Values less than zero provide a filter of opposite hue.
  7687. */
  7688. globalDensity: number;
  7689. /**
  7690. * Gets the global Saturation value.
  7691. * 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.
  7692. */
  7693. /**
  7694. * Sets the global Saturation value.
  7695. * 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.
  7696. */
  7697. globalSaturation: number;
  7698. /**
  7699. * Gets the global Exposure value.
  7700. * 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.
  7701. */
  7702. /**
  7703. * Sets the global Exposure value.
  7704. * 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.
  7705. */
  7706. globalExposure: number;
  7707. private _highlightsHue;
  7708. private _highlightsDensity;
  7709. private _highlightsSaturation;
  7710. private _highlightsExposure;
  7711. /**
  7712. * Gets the highlights Hue value.
  7713. * 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).
  7714. */
  7715. /**
  7716. * Sets the highlights Hue value.
  7717. * 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).
  7718. */
  7719. highlightsHue: number;
  7720. /**
  7721. * Gets the highlights Density value.
  7722. * 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.
  7723. * Values less than zero provide a filter of opposite hue.
  7724. */
  7725. /**
  7726. * Sets the highlights Density value.
  7727. * 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.
  7728. * Values less than zero provide a filter of opposite hue.
  7729. */
  7730. highlightsDensity: number;
  7731. /**
  7732. * Gets the highlights Saturation value.
  7733. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7734. */
  7735. /**
  7736. * Sets the highlights Saturation value.
  7737. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7738. */
  7739. highlightsSaturation: number;
  7740. /**
  7741. * Gets the highlights Exposure value.
  7742. * 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.
  7743. */
  7744. /**
  7745. * Sets the highlights Exposure value.
  7746. * 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.
  7747. */
  7748. highlightsExposure: number;
  7749. private _midtonesHue;
  7750. private _midtonesDensity;
  7751. private _midtonesSaturation;
  7752. private _midtonesExposure;
  7753. /**
  7754. * Gets the midtones Hue value.
  7755. * 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).
  7756. */
  7757. /**
  7758. * Sets the midtones Hue value.
  7759. * 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).
  7760. */
  7761. midtonesHue: number;
  7762. /**
  7763. * Gets the midtones Density value.
  7764. * 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.
  7765. * Values less than zero provide a filter of opposite hue.
  7766. */
  7767. /**
  7768. * Sets the midtones Density value.
  7769. * 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.
  7770. * Values less than zero provide a filter of opposite hue.
  7771. */
  7772. midtonesDensity: number;
  7773. /**
  7774. * Gets the midtones Saturation value.
  7775. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7776. */
  7777. /**
  7778. * Sets the midtones Saturation value.
  7779. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7780. */
  7781. midtonesSaturation: number;
  7782. /**
  7783. * Gets the midtones Exposure value.
  7784. * 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.
  7785. */
  7786. /**
  7787. * Sets the midtones Exposure value.
  7788. * 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.
  7789. */
  7790. midtonesExposure: number;
  7791. private _shadowsHue;
  7792. private _shadowsDensity;
  7793. private _shadowsSaturation;
  7794. private _shadowsExposure;
  7795. /**
  7796. * Gets the shadows Hue value.
  7797. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7798. */
  7799. /**
  7800. * Sets the shadows Hue value.
  7801. * The hue value is a standard HSB hue in the range [0,360] where 0=red, 120=green and 240=blue. The default value is 30 degrees (orange).
  7802. */
  7803. shadowsHue: number;
  7804. /**
  7805. * Gets the shadows Density value.
  7806. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7807. * Values less than zero provide a filter of opposite hue.
  7808. */
  7809. /**
  7810. * Sets the shadows Density value.
  7811. * The density value is in range [-100,+100] where 0 means the color filter has no effect and +100 means the color filter has maximum effect.
  7812. * Values less than zero provide a filter of opposite hue.
  7813. */
  7814. shadowsDensity: number;
  7815. /**
  7816. * Gets the shadows Saturation value.
  7817. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7818. */
  7819. /**
  7820. * Sets the shadows Saturation value.
  7821. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase saturation and negative values decrease saturation.
  7822. */
  7823. shadowsSaturation: number;
  7824. /**
  7825. * Gets the shadows Exposure value.
  7826. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7827. */
  7828. /**
  7829. * Sets the shadows Exposure value.
  7830. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7831. */
  7832. shadowsExposure: number;
  7833. /**
  7834. * Returns the class name
  7835. * @returns The class name
  7836. */
  7837. getClassName(): string;
  7838. /**
  7839. * Binds the color curves to the shader.
  7840. * @param colorCurves The color curve to bind
  7841. * @param effect The effect to bind to
  7842. * @param positiveUniform The positive uniform shader parameter
  7843. * @param neutralUniform The neutral uniform shader parameter
  7844. * @param negativeUniform The negative uniform shader parameter
  7845. */
  7846. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  7847. /**
  7848. * Prepare the list of uniforms associated with the ColorCurves effects.
  7849. * @param uniformsList The list of uniforms used in the effect
  7850. */
  7851. static PrepareUniforms(uniformsList: string[]): void;
  7852. /**
  7853. * Returns color grading data based on a hue, density, saturation and exposure value.
  7854. * @param filterHue The hue of the color filter.
  7855. * @param filterDensity The density of the color filter.
  7856. * @param saturation The saturation.
  7857. * @param exposure The exposure.
  7858. * @param result The result data container.
  7859. */
  7860. private getColorGradingDataToRef;
  7861. /**
  7862. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  7863. * @param value The input slider value in range [-100,100].
  7864. * @returns Adjusted value.
  7865. */
  7866. private static applyColorGradingSliderNonlinear;
  7867. /**
  7868. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  7869. * @param hue The hue (H) input.
  7870. * @param saturation The saturation (S) input.
  7871. * @param brightness The brightness (B) input.
  7872. * @result An RGBA color represented as Vector4.
  7873. */
  7874. private static fromHSBToRef;
  7875. /**
  7876. * Returns a value clamped between min and max
  7877. * @param value The value to clamp
  7878. * @param min The minimum of value
  7879. * @param max The maximum of value
  7880. * @returns The clamped value.
  7881. */
  7882. private static clamp;
  7883. /**
  7884. * Clones the current color curve instance.
  7885. * @return The cloned curves
  7886. */
  7887. clone(): ColorCurves;
  7888. /**
  7889. * Serializes the current color curve instance to a json representation.
  7890. * @return a JSON representation
  7891. */
  7892. serialize(): any;
  7893. /**
  7894. * Parses the color curve from a json representation.
  7895. * @param source the JSON source to parse
  7896. * @return The parsed curves
  7897. */
  7898. static Parse(source: any): ColorCurves;
  7899. }
  7900. }
  7901. declare module BABYLON {
  7902. /**
  7903. * Interface to follow in your material defines to integrate easily the
  7904. * Image proccessing functions.
  7905. * @hidden
  7906. */
  7907. export interface IImageProcessingConfigurationDefines {
  7908. IMAGEPROCESSING: boolean;
  7909. VIGNETTE: boolean;
  7910. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7911. VIGNETTEBLENDMODEOPAQUE: boolean;
  7912. TONEMAPPING: boolean;
  7913. TONEMAPPING_ACES: boolean;
  7914. CONTRAST: boolean;
  7915. EXPOSURE: boolean;
  7916. COLORCURVES: boolean;
  7917. COLORGRADING: boolean;
  7918. COLORGRADING3D: boolean;
  7919. SAMPLER3DGREENDEPTH: boolean;
  7920. SAMPLER3DBGRMAP: boolean;
  7921. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7922. }
  7923. /**
  7924. * @hidden
  7925. */
  7926. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  7927. IMAGEPROCESSING: boolean;
  7928. VIGNETTE: boolean;
  7929. VIGNETTEBLENDMODEMULTIPLY: boolean;
  7930. VIGNETTEBLENDMODEOPAQUE: boolean;
  7931. TONEMAPPING: boolean;
  7932. TONEMAPPING_ACES: boolean;
  7933. CONTRAST: boolean;
  7934. COLORCURVES: boolean;
  7935. COLORGRADING: boolean;
  7936. COLORGRADING3D: boolean;
  7937. SAMPLER3DGREENDEPTH: boolean;
  7938. SAMPLER3DBGRMAP: boolean;
  7939. IMAGEPROCESSINGPOSTPROCESS: boolean;
  7940. EXPOSURE: boolean;
  7941. constructor();
  7942. }
  7943. /**
  7944. * This groups together the common properties used for image processing either in direct forward pass
  7945. * or through post processing effect depending on the use of the image processing pipeline in your scene
  7946. * or not.
  7947. */
  7948. export class ImageProcessingConfiguration {
  7949. /**
  7950. * Default tone mapping applied in BabylonJS.
  7951. */
  7952. static readonly TONEMAPPING_STANDARD: number;
  7953. /**
  7954. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  7955. * to other engines rendering to increase portability.
  7956. */
  7957. static readonly TONEMAPPING_ACES: number;
  7958. /**
  7959. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  7960. */
  7961. colorCurves: Nullable<ColorCurves>;
  7962. private _colorCurvesEnabled;
  7963. /**
  7964. * Gets wether the color curves effect is enabled.
  7965. */
  7966. /**
  7967. * Sets wether the color curves effect is enabled.
  7968. */
  7969. colorCurvesEnabled: boolean;
  7970. private _colorGradingTexture;
  7971. /**
  7972. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7973. */
  7974. /**
  7975. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  7976. */
  7977. colorGradingTexture: Nullable<BaseTexture>;
  7978. private _colorGradingEnabled;
  7979. /**
  7980. * Gets wether the color grading effect is enabled.
  7981. */
  7982. /**
  7983. * Sets wether the color grading effect is enabled.
  7984. */
  7985. colorGradingEnabled: boolean;
  7986. private _colorGradingWithGreenDepth;
  7987. /**
  7988. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  7989. */
  7990. /**
  7991. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  7992. */
  7993. colorGradingWithGreenDepth: boolean;
  7994. private _colorGradingBGR;
  7995. /**
  7996. * Gets wether the color grading texture contains BGR values.
  7997. */
  7998. /**
  7999. * Sets wether the color grading texture contains BGR values.
  8000. */
  8001. colorGradingBGR: boolean;
  8002. /** @hidden */ private _exposure: number;
  8003. /**
  8004. * Gets the Exposure used in the effect.
  8005. */
  8006. /**
  8007. * Sets the Exposure used in the effect.
  8008. */
  8009. exposure: number;
  8010. private _toneMappingEnabled;
  8011. /**
  8012. * Gets wether the tone mapping effect is enabled.
  8013. */
  8014. /**
  8015. * Sets wether the tone mapping effect is enabled.
  8016. */
  8017. toneMappingEnabled: boolean;
  8018. private _toneMappingType;
  8019. /**
  8020. * Gets the type of tone mapping effect.
  8021. */
  8022. /**
  8023. * Sets the type of tone mapping effect used in BabylonJS.
  8024. */
  8025. toneMappingType: number;
  8026. protected _contrast: number;
  8027. /**
  8028. * Gets the contrast used in the effect.
  8029. */
  8030. /**
  8031. * Sets the contrast used in the effect.
  8032. */
  8033. contrast: number;
  8034. /**
  8035. * Vignette stretch size.
  8036. */
  8037. vignetteStretch: number;
  8038. /**
  8039. * Vignette centre X Offset.
  8040. */
  8041. vignetteCentreX: number;
  8042. /**
  8043. * Vignette centre Y Offset.
  8044. */
  8045. vignetteCentreY: number;
  8046. /**
  8047. * Vignette weight or intensity of the vignette effect.
  8048. */
  8049. vignetteWeight: number;
  8050. /**
  8051. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8052. * if vignetteEnabled is set to true.
  8053. */
  8054. vignetteColor: Color4;
  8055. /**
  8056. * Camera field of view used by the Vignette effect.
  8057. */
  8058. vignetteCameraFov: number;
  8059. private _vignetteBlendMode;
  8060. /**
  8061. * Gets the vignette blend mode allowing different kind of effect.
  8062. */
  8063. /**
  8064. * Sets the vignette blend mode allowing different kind of effect.
  8065. */
  8066. vignetteBlendMode: number;
  8067. private _vignetteEnabled;
  8068. /**
  8069. * Gets wether the vignette effect is enabled.
  8070. */
  8071. /**
  8072. * Sets wether the vignette effect is enabled.
  8073. */
  8074. vignetteEnabled: boolean;
  8075. private _applyByPostProcess;
  8076. /**
  8077. * Gets wether the image processing is applied through a post process or not.
  8078. */
  8079. /**
  8080. * Sets wether the image processing is applied through a post process or not.
  8081. */
  8082. applyByPostProcess: boolean;
  8083. private _isEnabled;
  8084. /**
  8085. * Gets wether the image processing is enabled or not.
  8086. */
  8087. /**
  8088. * Sets wether the image processing is enabled or not.
  8089. */
  8090. isEnabled: boolean;
  8091. /**
  8092. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8093. */
  8094. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8095. /**
  8096. * Method called each time the image processing information changes requires to recompile the effect.
  8097. */
  8098. protected _updateParameters(): void;
  8099. /**
  8100. * Gets the current class name.
  8101. * @return "ImageProcessingConfiguration"
  8102. */
  8103. getClassName(): string;
  8104. /**
  8105. * Prepare the list of uniforms associated with the Image Processing effects.
  8106. * @param uniforms The list of uniforms used in the effect
  8107. * @param defines the list of defines currently in use
  8108. */
  8109. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8110. /**
  8111. * Prepare the list of samplers associated with the Image Processing effects.
  8112. * @param samplersList The list of uniforms used in the effect
  8113. * @param defines the list of defines currently in use
  8114. */
  8115. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8116. /**
  8117. * Prepare the list of defines associated to the shader.
  8118. * @param defines the list of defines to complete
  8119. * @param forPostProcess Define if we are currently in post process mode or not
  8120. */
  8121. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8122. /**
  8123. * Returns true if all the image processing information are ready.
  8124. * @returns True if ready, otherwise, false
  8125. */
  8126. isReady(): boolean;
  8127. /**
  8128. * Binds the image processing to the shader.
  8129. * @param effect The effect to bind to
  8130. * @param aspectRatio Define the current aspect ratio of the effect
  8131. */
  8132. bind(effect: Effect, aspectRatio?: number): void;
  8133. /**
  8134. * Clones the current image processing instance.
  8135. * @return The cloned image processing
  8136. */
  8137. clone(): ImageProcessingConfiguration;
  8138. /**
  8139. * Serializes the current image processing instance to a json representation.
  8140. * @return a JSON representation
  8141. */
  8142. serialize(): any;
  8143. /**
  8144. * Parses the image processing from a json representation.
  8145. * @param source the JSON source to parse
  8146. * @return The parsed image processing
  8147. */
  8148. static Parse(source: any): ImageProcessingConfiguration;
  8149. private static _VIGNETTEMODE_MULTIPLY;
  8150. private static _VIGNETTEMODE_OPAQUE;
  8151. /**
  8152. * Used to apply the vignette as a mix with the pixel color.
  8153. */
  8154. static readonly VIGNETTEMODE_MULTIPLY: number;
  8155. /**
  8156. * Used to apply the vignette as a replacement of the pixel color.
  8157. */
  8158. static readonly VIGNETTEMODE_OPAQUE: number;
  8159. }
  8160. }
  8161. declare module BABYLON {
  8162. /** @hidden */
  8163. export var postprocessVertexShader: {
  8164. name: string;
  8165. shader: string;
  8166. };
  8167. }
  8168. declare module BABYLON {
  8169. /** Defines supported spaces */
  8170. export enum Space {
  8171. /** Local (object) space */
  8172. LOCAL = 0,
  8173. /** World space */
  8174. WORLD = 1,
  8175. /** Bone space */
  8176. BONE = 2
  8177. }
  8178. /** Defines the 3 main axes */
  8179. export class Axis {
  8180. /** X axis */
  8181. static X: Vector3;
  8182. /** Y axis */
  8183. static Y: Vector3;
  8184. /** Z axis */
  8185. static Z: Vector3;
  8186. }
  8187. }
  8188. declare module BABYLON {
  8189. /**
  8190. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8191. * This is the base of the follow, arc rotate cameras and Free camera
  8192. * @see http://doc.babylonjs.com/features/cameras
  8193. */
  8194. export class TargetCamera extends Camera {
  8195. private static _RigCamTransformMatrix;
  8196. private static _TargetTransformMatrix;
  8197. private static _TargetFocalPoint;
  8198. /**
  8199. * Define the current direction the camera is moving to
  8200. */
  8201. cameraDirection: Vector3;
  8202. /**
  8203. * Define the current rotation the camera is rotating to
  8204. */
  8205. cameraRotation: Vector2;
  8206. /**
  8207. * When set, the up vector of the camera will be updated by the rotation of the camera
  8208. */
  8209. updateUpVectorFromRotation: boolean;
  8210. private _tmpQuaternion;
  8211. /**
  8212. * Define the current rotation of the camera
  8213. */
  8214. rotation: Vector3;
  8215. /**
  8216. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8217. */
  8218. rotationQuaternion: Quaternion;
  8219. /**
  8220. * Define the current speed of the camera
  8221. */
  8222. speed: number;
  8223. /**
  8224. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8225. * around all axis.
  8226. */
  8227. noRotationConstraint: boolean;
  8228. /**
  8229. * Define the current target of the camera as an object or a position.
  8230. */
  8231. lockedTarget: any;
  8232. /** @hidden */ private _currentTarget: Vector3;
  8233. /** @hidden */ private _initialFocalDistance: number;
  8234. /** @hidden */ private _viewMatrix: Matrix;
  8235. /** @hidden */ private _camMatrix: Matrix;
  8236. /** @hidden */ private _cameraTransformMatrix: Matrix;
  8237. /** @hidden */ private _cameraRotationMatrix: Matrix;
  8238. /** @hidden */ private _referencePoint: Vector3;
  8239. /** @hidden */ private _transformedReferencePoint: Vector3;
  8240. protected _globalCurrentTarget: Vector3;
  8241. protected _globalCurrentUpVector: Vector3;
  8242. /** @hidden */ private _reset: () => void;
  8243. private _defaultUp;
  8244. /**
  8245. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8246. * This is the base of the follow, arc rotate cameras and Free camera
  8247. * @see http://doc.babylonjs.com/features/cameras
  8248. * @param name Defines the name of the camera in the scene
  8249. * @param position Defines the start position of the camera in the scene
  8250. * @param scene Defines the scene the camera belongs to
  8251. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8252. */
  8253. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8254. /**
  8255. * Gets the position in front of the camera at a given distance.
  8256. * @param distance The distance from the camera we want the position to be
  8257. * @returns the position
  8258. */
  8259. getFrontPosition(distance: number): Vector3;
  8260. /** @hidden */ private _getLockedTargetPosition(): Nullable<Vector3>;
  8261. private _storedPosition;
  8262. private _storedRotation;
  8263. private _storedRotationQuaternion;
  8264. /**
  8265. * Store current camera state of the camera (fov, position, rotation, etc..)
  8266. * @returns the camera
  8267. */
  8268. storeState(): Camera;
  8269. /**
  8270. * Restored camera state. You must call storeState() first
  8271. * @returns whether it was successful or not
  8272. * @hidden
  8273. */ private _restoreStateValues(): boolean;
  8274. /** @hidden */ private _initCache(): void;
  8275. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  8276. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  8277. /** @hidden */ private _computeLocalCameraSpeed(): number;
  8278. /**
  8279. * Defines the target the camera should look at.
  8280. * @param target Defines the new target as a Vector or a mesh
  8281. */
  8282. setTarget(target: Vector3): void;
  8283. /**
  8284. * Return the current target position of the camera. This value is expressed in local space.
  8285. * @returns the target position
  8286. */
  8287. getTarget(): Vector3;
  8288. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  8289. /** @hidden */ private _updatePosition(): void;
  8290. /** @hidden */ private _checkInputs(): void;
  8291. protected _updateCameraRotationMatrix(): void;
  8292. /**
  8293. * 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)
  8294. * @returns the current camera
  8295. */
  8296. private _rotateUpVectorWithCameraRotationMatrix;
  8297. private _cachedRotationZ;
  8298. private _cachedQuaternionRotationZ;
  8299. /** @hidden */ private _getViewMatrix(): Matrix;
  8300. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8301. /**
  8302. * @hidden
  8303. */
  8304. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8305. /**
  8306. * @hidden
  8307. */ private _updateRigCameras(): void;
  8308. private _getRigCamPositionAndTarget;
  8309. /**
  8310. * Gets the current object class name.
  8311. * @return the class name
  8312. */
  8313. getClassName(): string;
  8314. }
  8315. }
  8316. declare module BABYLON {
  8317. /**
  8318. * Gather the list of keyboard event types as constants.
  8319. */
  8320. export class KeyboardEventTypes {
  8321. /**
  8322. * The keydown event is fired when a key becomes active (pressed).
  8323. */
  8324. static readonly KEYDOWN: number;
  8325. /**
  8326. * The keyup event is fired when a key has been released.
  8327. */
  8328. static readonly KEYUP: number;
  8329. }
  8330. /**
  8331. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8332. */
  8333. export class KeyboardInfo {
  8334. /**
  8335. * Defines the type of event (KeyboardEventTypes)
  8336. */
  8337. type: number;
  8338. /**
  8339. * Defines the related dom event
  8340. */
  8341. event: KeyboardEvent;
  8342. /**
  8343. * Instantiates a new keyboard info.
  8344. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8345. * @param type Defines the type of event (KeyboardEventTypes)
  8346. * @param event Defines the related dom event
  8347. */
  8348. constructor(
  8349. /**
  8350. * Defines the type of event (KeyboardEventTypes)
  8351. */
  8352. type: number,
  8353. /**
  8354. * Defines the related dom event
  8355. */
  8356. event: KeyboardEvent);
  8357. }
  8358. /**
  8359. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8360. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8361. */
  8362. export class KeyboardInfoPre extends KeyboardInfo {
  8363. /**
  8364. * Defines the type of event (KeyboardEventTypes)
  8365. */
  8366. type: number;
  8367. /**
  8368. * Defines the related dom event
  8369. */
  8370. event: KeyboardEvent;
  8371. /**
  8372. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8373. */
  8374. skipOnPointerObservable: boolean;
  8375. /**
  8376. * Instantiates a new keyboard pre info.
  8377. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8378. * @param type Defines the type of event (KeyboardEventTypes)
  8379. * @param event Defines the related dom event
  8380. */
  8381. constructor(
  8382. /**
  8383. * Defines the type of event (KeyboardEventTypes)
  8384. */
  8385. type: number,
  8386. /**
  8387. * Defines the related dom event
  8388. */
  8389. event: KeyboardEvent);
  8390. }
  8391. }
  8392. declare module BABYLON {
  8393. /**
  8394. * Manage the keyboard inputs to control the movement of a free camera.
  8395. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8396. */
  8397. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8398. /**
  8399. * Defines the camera the input is attached to.
  8400. */
  8401. camera: FreeCamera;
  8402. /**
  8403. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8404. */
  8405. keysUp: number[];
  8406. /**
  8407. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8408. */
  8409. keysDown: number[];
  8410. /**
  8411. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8412. */
  8413. keysLeft: number[];
  8414. /**
  8415. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8416. */
  8417. keysRight: number[];
  8418. private _keys;
  8419. private _onCanvasBlurObserver;
  8420. private _onKeyboardObserver;
  8421. private _engine;
  8422. private _scene;
  8423. /**
  8424. * Attach the input controls to a specific dom element to get the input from.
  8425. * @param element Defines the element the controls should be listened from
  8426. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8427. */
  8428. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8429. /**
  8430. * Detach the current controls from the specified dom element.
  8431. * @param element Defines the element to stop listening the inputs from
  8432. */
  8433. detachControl(element: Nullable<HTMLElement>): void;
  8434. /**
  8435. * Update the current camera state depending on the inputs that have been used this frame.
  8436. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8437. */
  8438. checkInputs(): void;
  8439. /**
  8440. * Gets the class name of the current intput.
  8441. * @returns the class name
  8442. */
  8443. getClassName(): string;
  8444. /** @hidden */ private _onLostFocus(): void;
  8445. /**
  8446. * Get the friendly name associated with the input class.
  8447. * @returns the input friendly name
  8448. */
  8449. getSimpleName(): string;
  8450. }
  8451. }
  8452. declare module BABYLON {
  8453. /**
  8454. * Interface describing all the common properties and methods a shadow light needs to implement.
  8455. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8456. * as well as binding the different shadow properties to the effects.
  8457. */
  8458. export interface IShadowLight extends Light {
  8459. /**
  8460. * The light id in the scene (used in scene.findLighById for instance)
  8461. */
  8462. id: string;
  8463. /**
  8464. * The position the shdow will be casted from.
  8465. */
  8466. position: Vector3;
  8467. /**
  8468. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8469. */
  8470. direction: Vector3;
  8471. /**
  8472. * The transformed position. Position of the light in world space taking parenting in account.
  8473. */
  8474. transformedPosition: Vector3;
  8475. /**
  8476. * The transformed direction. Direction of the light in world space taking parenting in account.
  8477. */
  8478. transformedDirection: Vector3;
  8479. /**
  8480. * The friendly name of the light in the scene.
  8481. */
  8482. name: string;
  8483. /**
  8484. * Defines the shadow projection clipping minimum z value.
  8485. */
  8486. shadowMinZ: number;
  8487. /**
  8488. * Defines the shadow projection clipping maximum z value.
  8489. */
  8490. shadowMaxZ: number;
  8491. /**
  8492. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8493. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8494. */
  8495. computeTransformedInformation(): boolean;
  8496. /**
  8497. * Gets the scene the light belongs to.
  8498. * @returns The scene
  8499. */
  8500. getScene(): Scene;
  8501. /**
  8502. * Callback defining a custom Projection Matrix Builder.
  8503. * This can be used to override the default projection matrix computation.
  8504. */
  8505. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8506. /**
  8507. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8508. * @param matrix The materix to updated with the projection information
  8509. * @param viewMatrix The transform matrix of the light
  8510. * @param renderList The list of mesh to render in the map
  8511. * @returns The current light
  8512. */
  8513. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8514. /**
  8515. * Gets the current depth scale used in ESM.
  8516. * @returns The scale
  8517. */
  8518. getDepthScale(): number;
  8519. /**
  8520. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8521. * @returns true if a cube texture needs to be use
  8522. */
  8523. needCube(): boolean;
  8524. /**
  8525. * Detects if the projection matrix requires to be recomputed this frame.
  8526. * @returns true if it requires to be recomputed otherwise, false.
  8527. */
  8528. needProjectionMatrixCompute(): boolean;
  8529. /**
  8530. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8531. */
  8532. forceProjectionMatrixCompute(): void;
  8533. /**
  8534. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8535. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8536. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8537. */
  8538. getShadowDirection(faceIndex?: number): Vector3;
  8539. /**
  8540. * Gets the minZ used for shadow according to both the scene and the light.
  8541. * @param activeCamera The camera we are returning the min for
  8542. * @returns the depth min z
  8543. */
  8544. getDepthMinZ(activeCamera: Camera): number;
  8545. /**
  8546. * Gets the maxZ used for shadow according to both the scene and the light.
  8547. * @param activeCamera The camera we are returning the max for
  8548. * @returns the depth max z
  8549. */
  8550. getDepthMaxZ(activeCamera: Camera): number;
  8551. }
  8552. /**
  8553. * Base implementation IShadowLight
  8554. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8555. */
  8556. export abstract class ShadowLight extends Light implements IShadowLight {
  8557. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8558. protected _position: Vector3;
  8559. protected _setPosition(value: Vector3): void;
  8560. /**
  8561. * Sets the position the shadow will be casted from. Also use as the light position for both
  8562. * point and spot lights.
  8563. */
  8564. /**
  8565. * Sets the position the shadow will be casted from. Also use as the light position for both
  8566. * point and spot lights.
  8567. */
  8568. position: Vector3;
  8569. protected _direction: Vector3;
  8570. protected _setDirection(value: Vector3): void;
  8571. /**
  8572. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8573. * Also use as the light direction on spot and directional lights.
  8574. */
  8575. /**
  8576. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8577. * Also use as the light direction on spot and directional lights.
  8578. */
  8579. direction: Vector3;
  8580. private _shadowMinZ;
  8581. /**
  8582. * Gets the shadow projection clipping minimum z value.
  8583. */
  8584. /**
  8585. * Sets the shadow projection clipping minimum z value.
  8586. */
  8587. shadowMinZ: number;
  8588. private _shadowMaxZ;
  8589. /**
  8590. * Sets the shadow projection clipping maximum z value.
  8591. */
  8592. /**
  8593. * Gets the shadow projection clipping maximum z value.
  8594. */
  8595. shadowMaxZ: number;
  8596. /**
  8597. * Callback defining a custom Projection Matrix Builder.
  8598. * This can be used to override the default projection matrix computation.
  8599. */
  8600. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8601. /**
  8602. * The transformed position. Position of the light in world space taking parenting in account.
  8603. */
  8604. transformedPosition: Vector3;
  8605. /**
  8606. * The transformed direction. Direction of the light in world space taking parenting in account.
  8607. */
  8608. transformedDirection: Vector3;
  8609. private _needProjectionMatrixCompute;
  8610. /**
  8611. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8612. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8613. */
  8614. computeTransformedInformation(): boolean;
  8615. /**
  8616. * Return the depth scale used for the shadow map.
  8617. * @returns the depth scale.
  8618. */
  8619. getDepthScale(): number;
  8620. /**
  8621. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8622. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8623. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8624. */
  8625. getShadowDirection(faceIndex?: number): Vector3;
  8626. /**
  8627. * Returns the ShadowLight absolute position in the World.
  8628. * @returns the position vector in world space
  8629. */
  8630. getAbsolutePosition(): Vector3;
  8631. /**
  8632. * Sets the ShadowLight direction toward the passed target.
  8633. * @param target The point to target in local space
  8634. * @returns the updated ShadowLight direction
  8635. */
  8636. setDirectionToTarget(target: Vector3): Vector3;
  8637. /**
  8638. * Returns the light rotation in euler definition.
  8639. * @returns the x y z rotation in local space.
  8640. */
  8641. getRotation(): Vector3;
  8642. /**
  8643. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8644. * @returns true if a cube texture needs to be use
  8645. */
  8646. needCube(): boolean;
  8647. /**
  8648. * Detects if the projection matrix requires to be recomputed this frame.
  8649. * @returns true if it requires to be recomputed otherwise, false.
  8650. */
  8651. needProjectionMatrixCompute(): boolean;
  8652. /**
  8653. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8654. */
  8655. forceProjectionMatrixCompute(): void;
  8656. /** @hidden */ private _initCache(): void;
  8657. /** @hidden */ private _isSynchronized(): boolean;
  8658. /**
  8659. * Computes the world matrix of the node
  8660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8661. * @returns the world matrix
  8662. */
  8663. computeWorldMatrix(force?: boolean): Matrix;
  8664. /**
  8665. * Gets the minZ used for shadow according to both the scene and the light.
  8666. * @param activeCamera The camera we are returning the min for
  8667. * @returns the depth min z
  8668. */
  8669. getDepthMinZ(activeCamera: Camera): number;
  8670. /**
  8671. * Gets the maxZ used for shadow according to both the scene and the light.
  8672. * @param activeCamera The camera we are returning the max for
  8673. * @returns the depth max z
  8674. */
  8675. getDepthMaxZ(activeCamera: Camera): number;
  8676. /**
  8677. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8678. * @param matrix The materix to updated with the projection information
  8679. * @param viewMatrix The transform matrix of the light
  8680. * @param renderList The list of mesh to render in the map
  8681. * @returns The current light
  8682. */
  8683. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8684. }
  8685. }
  8686. declare module BABYLON {
  8687. /**
  8688. * "Static Class" containing the most commonly used helper while dealing with material for
  8689. * rendering purpose.
  8690. *
  8691. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  8692. *
  8693. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  8694. */
  8695. export class MaterialHelper {
  8696. /**
  8697. * Bind the current view position to an effect.
  8698. * @param effect The effect to be bound
  8699. * @param scene The scene the eyes position is used from
  8700. */
  8701. static BindEyePosition(effect: Effect, scene: Scene): void;
  8702. /**
  8703. * Helps preparing the defines values about the UVs in used in the effect.
  8704. * UVs are shared as much as we can accross channels in the shaders.
  8705. * @param texture The texture we are preparing the UVs for
  8706. * @param defines The defines to update
  8707. * @param key The channel key "diffuse", "specular"... used in the shader
  8708. */
  8709. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  8710. /**
  8711. * Binds a texture matrix value to its corrsponding uniform
  8712. * @param texture The texture to bind the matrix for
  8713. * @param uniformBuffer The uniform buffer receivin the data
  8714. * @param key The channel key "diffuse", "specular"... used in the shader
  8715. */
  8716. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  8717. /**
  8718. * Gets the current status of the fog (should it be enabled?)
  8719. * @param mesh defines the mesh to evaluate for fog support
  8720. * @param scene defines the hosting scene
  8721. * @returns true if fog must be enabled
  8722. */
  8723. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  8724. /**
  8725. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  8726. * @param mesh defines the current mesh
  8727. * @param scene defines the current scene
  8728. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  8729. * @param pointsCloud defines if point cloud rendering has to be turned on
  8730. * @param fogEnabled defines if fog has to be turned on
  8731. * @param alphaTest defines if alpha testing has to be turned on
  8732. * @param defines defines the current list of defines
  8733. */
  8734. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  8735. /**
  8736. * Helper used to prepare the list of defines associated with frame values for shader compilation
  8737. * @param scene defines the current scene
  8738. * @param engine defines the current engine
  8739. * @param defines specifies the list of active defines
  8740. * @param useInstances defines if instances have to be turned on
  8741. * @param useClipPlane defines if clip plane have to be turned on
  8742. */
  8743. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  8744. /**
  8745. * Prepares the defines for bones
  8746. * @param mesh The mesh containing the geometry data we will draw
  8747. * @param defines The defines to update
  8748. */
  8749. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  8750. /**
  8751. * Prepares the defines for morph targets
  8752. * @param mesh The mesh containing the geometry data we will draw
  8753. * @param defines The defines to update
  8754. */
  8755. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  8756. /**
  8757. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  8758. * @param mesh The mesh containing the geometry data we will draw
  8759. * @param defines The defines to update
  8760. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  8761. * @param useBones Precise whether bones should be used or not (override mesh info)
  8762. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  8763. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  8764. * @returns false if defines are considered not dirty and have not been checked
  8765. */
  8766. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  8767. /**
  8768. * Prepares the defines related to multiview
  8769. * @param scene The scene we are intending to draw
  8770. * @param defines The defines to update
  8771. */
  8772. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  8773. /**
  8774. * Prepares the defines related to the light information passed in parameter
  8775. * @param scene The scene we are intending to draw
  8776. * @param mesh The mesh the effect is compiling for
  8777. * @param light The light the effect is compiling for
  8778. * @param lightIndex The index of the light
  8779. * @param defines The defines to update
  8780. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8781. * @param state Defines the current state regarding what is needed (normals, etc...)
  8782. */
  8783. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  8784. needNormals: boolean;
  8785. needRebuild: boolean;
  8786. shadowEnabled: boolean;
  8787. specularEnabled: boolean;
  8788. lightmapMode: boolean;
  8789. }): void;
  8790. /**
  8791. * Prepares the defines related to the light information passed in parameter
  8792. * @param scene The scene we are intending to draw
  8793. * @param mesh The mesh the effect is compiling for
  8794. * @param defines The defines to update
  8795. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  8796. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  8797. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  8798. * @returns true if normals will be required for the rest of the effect
  8799. */
  8800. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  8801. /**
  8802. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  8803. * @param lightIndex defines the light index
  8804. * @param uniformsList The uniform list
  8805. * @param samplersList The sampler list
  8806. * @param projectedLightTexture defines if projected texture must be used
  8807. * @param uniformBuffersList defines an optional list of uniform buffers
  8808. */
  8809. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  8810. /**
  8811. * Prepares the uniforms and samplers list to be used in the effect
  8812. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  8813. * @param samplersList The sampler list
  8814. * @param defines The defines helping in the list generation
  8815. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  8816. */
  8817. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  8818. /**
  8819. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  8820. * @param defines The defines to update while falling back
  8821. * @param fallbacks The authorized effect fallbacks
  8822. * @param maxSimultaneousLights The maximum number of lights allowed
  8823. * @param rank the current rank of the Effect
  8824. * @returns The newly affected rank
  8825. */
  8826. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  8827. private static _TmpMorphInfluencers;
  8828. /**
  8829. * Prepares the list of attributes required for morph targets according to the effect defines.
  8830. * @param attribs The current list of supported attribs
  8831. * @param mesh The mesh to prepare the morph targets attributes for
  8832. * @param influencers The number of influencers
  8833. */
  8834. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  8835. /**
  8836. * Prepares the list of attributes required for morph targets according to the effect defines.
  8837. * @param attribs The current list of supported attribs
  8838. * @param mesh The mesh to prepare the morph targets attributes for
  8839. * @param defines The current Defines of the effect
  8840. */
  8841. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  8842. /**
  8843. * Prepares the list of attributes required for bones according to the effect defines.
  8844. * @param attribs The current list of supported attribs
  8845. * @param mesh The mesh to prepare the bones attributes for
  8846. * @param defines The current Defines of the effect
  8847. * @param fallbacks The current efffect fallback strategy
  8848. */
  8849. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  8850. /**
  8851. * Check and prepare the list of attributes required for instances according to the effect defines.
  8852. * @param attribs The current list of supported attribs
  8853. * @param defines The current MaterialDefines of the effect
  8854. */
  8855. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  8856. /**
  8857. * Add the list of attributes required for instances to the attribs array.
  8858. * @param attribs The current list of supported attribs
  8859. */
  8860. static PushAttributesForInstances(attribs: string[]): void;
  8861. /**
  8862. * Binds the light shadow information to the effect for the given mesh.
  8863. * @param light The light containing the generator
  8864. * @param scene The scene the lights belongs to
  8865. * @param mesh The mesh we are binding the information to render
  8866. * @param lightIndex The light index in the effect used to render the mesh
  8867. * @param effect The effect we are binding the data to
  8868. */
  8869. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  8870. /**
  8871. * Binds the light information to the effect.
  8872. * @param light The light containing the generator
  8873. * @param effect The effect we are binding the data to
  8874. * @param lightIndex The light index in the effect used to render
  8875. */
  8876. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  8877. /**
  8878. * Binds the lights information from the scene to the effect for the given mesh.
  8879. * @param light Light to bind
  8880. * @param lightIndex Light index
  8881. * @param scene The scene where the light belongs to
  8882. * @param mesh The mesh we are binding the information to render
  8883. * @param effect The effect we are binding the data to
  8884. * @param useSpecular Defines if specular is supported
  8885. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8886. */
  8887. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean): void;
  8888. /**
  8889. * Binds the lights information from the scene to the effect for the given mesh.
  8890. * @param scene The scene the lights belongs to
  8891. * @param mesh The mesh we are binding the information to render
  8892. * @param effect The effect we are binding the data to
  8893. * @param defines The generated defines for the effect
  8894. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  8895. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  8896. */
  8897. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  8898. private static _tempFogColor;
  8899. /**
  8900. * Binds the fog information from the scene to the effect for the given mesh.
  8901. * @param scene The scene the lights belongs to
  8902. * @param mesh The mesh we are binding the information to render
  8903. * @param effect The effect we are binding the data to
  8904. * @param linearSpace Defines if the fog effect is applied in linear space
  8905. */
  8906. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  8907. /**
  8908. * Binds the bones information from the mesh to the effect.
  8909. * @param mesh The mesh we are binding the information to render
  8910. * @param effect The effect we are binding the data to
  8911. */
  8912. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  8913. /**
  8914. * Binds the morph targets information from the mesh to the effect.
  8915. * @param abstractMesh The mesh we are binding the information to render
  8916. * @param effect The effect we are binding the data to
  8917. */
  8918. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  8919. /**
  8920. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  8921. * @param defines The generated defines used in the effect
  8922. * @param effect The effect we are binding the data to
  8923. * @param scene The scene we are willing to render with logarithmic scale for
  8924. */
  8925. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  8926. /**
  8927. * Binds the clip plane information from the scene to the effect.
  8928. * @param scene The scene the clip plane information are extracted from
  8929. * @param effect The effect we are binding the data to
  8930. */
  8931. static BindClipPlane(effect: Effect, scene: Scene): void;
  8932. }
  8933. }
  8934. declare module BABYLON {
  8935. /** @hidden */
  8936. export var packingFunctions: {
  8937. name: string;
  8938. shader: string;
  8939. };
  8940. }
  8941. declare module BABYLON {
  8942. /** @hidden */
  8943. export var shadowMapPixelShader: {
  8944. name: string;
  8945. shader: string;
  8946. };
  8947. }
  8948. declare module BABYLON {
  8949. /** @hidden */
  8950. export var bonesDeclaration: {
  8951. name: string;
  8952. shader: string;
  8953. };
  8954. }
  8955. declare module BABYLON {
  8956. /** @hidden */
  8957. export var morphTargetsVertexGlobalDeclaration: {
  8958. name: string;
  8959. shader: string;
  8960. };
  8961. }
  8962. declare module BABYLON {
  8963. /** @hidden */
  8964. export var morphTargetsVertexDeclaration: {
  8965. name: string;
  8966. shader: string;
  8967. };
  8968. }
  8969. declare module BABYLON {
  8970. /** @hidden */
  8971. export var instancesDeclaration: {
  8972. name: string;
  8973. shader: string;
  8974. };
  8975. }
  8976. declare module BABYLON {
  8977. /** @hidden */
  8978. export var helperFunctions: {
  8979. name: string;
  8980. shader: string;
  8981. };
  8982. }
  8983. declare module BABYLON {
  8984. /** @hidden */
  8985. export var morphTargetsVertex: {
  8986. name: string;
  8987. shader: string;
  8988. };
  8989. }
  8990. declare module BABYLON {
  8991. /** @hidden */
  8992. export var instancesVertex: {
  8993. name: string;
  8994. shader: string;
  8995. };
  8996. }
  8997. declare module BABYLON {
  8998. /** @hidden */
  8999. export var bonesVertex: {
  9000. name: string;
  9001. shader: string;
  9002. };
  9003. }
  9004. declare module BABYLON {
  9005. /** @hidden */
  9006. export var shadowMapVertexShader: {
  9007. name: string;
  9008. shader: string;
  9009. };
  9010. }
  9011. declare module BABYLON {
  9012. /** @hidden */
  9013. export var depthBoxBlurPixelShader: {
  9014. name: string;
  9015. shader: string;
  9016. };
  9017. }
  9018. declare module BABYLON {
  9019. /**
  9020. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9021. */
  9022. export interface ICustomShaderOptions {
  9023. /**
  9024. * Gets or sets the custom shader name to use
  9025. */
  9026. shaderName: string;
  9027. /**
  9028. * The list of attribute names used in the shader
  9029. */
  9030. attributes?: string[];
  9031. /**
  9032. * The list of unifrom names used in the shader
  9033. */
  9034. uniforms?: string[];
  9035. /**
  9036. * The list of sampler names used in the shader
  9037. */
  9038. samplers?: string[];
  9039. /**
  9040. * The list of defines used in the shader
  9041. */
  9042. defines?: string[];
  9043. }
  9044. /**
  9045. * Interface to implement to create a shadow generator compatible with BJS.
  9046. */
  9047. export interface IShadowGenerator {
  9048. /**
  9049. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9050. * @returns The render target texture if present otherwise, null
  9051. */
  9052. getShadowMap(): Nullable<RenderTargetTexture>;
  9053. /**
  9054. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9055. * @returns The render target texture if the shadow map is present otherwise, null
  9056. */
  9057. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9058. /**
  9059. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9060. * @param subMesh The submesh we want to render in the shadow map
  9061. * @param useInstances Defines wether will draw in the map using instances
  9062. * @returns true if ready otherwise, false
  9063. */
  9064. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9065. /**
  9066. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9067. * @param defines Defines of the material we want to update
  9068. * @param lightIndex Index of the light in the enabled light list of the material
  9069. */
  9070. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9071. /**
  9072. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9073. * defined in the generator but impacting the effect).
  9074. * It implies the unifroms available on the materials are the standard BJS ones.
  9075. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9076. * @param effect The effect we are binfing the information for
  9077. */
  9078. bindShadowLight(lightIndex: string, effect: Effect): void;
  9079. /**
  9080. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9081. * (eq to shadow prjection matrix * light transform matrix)
  9082. * @returns The transform matrix used to create the shadow map
  9083. */
  9084. getTransformMatrix(): Matrix;
  9085. /**
  9086. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9087. * Cube and 2D textures for instance.
  9088. */
  9089. recreateShadowMap(): void;
  9090. /**
  9091. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9092. * @param onCompiled Callback triggered at the and of the effects compilation
  9093. * @param options Sets of optional options forcing the compilation with different modes
  9094. */
  9095. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9096. useInstances: boolean;
  9097. }>): void;
  9098. /**
  9099. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9100. * @param options Sets of optional options forcing the compilation with different modes
  9101. * @returns A promise that resolves when the compilation completes
  9102. */
  9103. forceCompilationAsync(options?: Partial<{
  9104. useInstances: boolean;
  9105. }>): Promise<void>;
  9106. /**
  9107. * Serializes the shadow generator setup to a json object.
  9108. * @returns The serialized JSON object
  9109. */
  9110. serialize(): any;
  9111. /**
  9112. * Disposes the Shadow map and related Textures and effects.
  9113. */
  9114. dispose(): void;
  9115. }
  9116. /**
  9117. * Default implementation IShadowGenerator.
  9118. * This is the main object responsible of generating shadows in the framework.
  9119. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9120. */
  9121. export class ShadowGenerator implements IShadowGenerator {
  9122. /**
  9123. * Shadow generator mode None: no filtering applied.
  9124. */
  9125. static readonly FILTER_NONE: number;
  9126. /**
  9127. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9128. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9129. */
  9130. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9131. /**
  9132. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9133. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9134. */
  9135. static readonly FILTER_POISSONSAMPLING: number;
  9136. /**
  9137. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9138. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9139. */
  9140. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9141. /**
  9142. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9143. * edge artifacts on steep falloff.
  9144. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9145. */
  9146. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9147. /**
  9148. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9149. * edge artifacts on steep falloff.
  9150. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9151. */
  9152. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9153. /**
  9154. * Shadow generator mode PCF: Percentage Closer Filtering
  9155. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9156. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9157. */
  9158. static readonly FILTER_PCF: number;
  9159. /**
  9160. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9161. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9162. * Contact Hardening
  9163. */
  9164. static readonly FILTER_PCSS: number;
  9165. /**
  9166. * Reserved for PCF and PCSS
  9167. * Highest Quality.
  9168. *
  9169. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9170. *
  9171. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9172. */
  9173. static readonly QUALITY_HIGH: number;
  9174. /**
  9175. * Reserved for PCF and PCSS
  9176. * Good tradeoff for quality/perf cross devices
  9177. *
  9178. * Execute PCF on a 3*3 kernel.
  9179. *
  9180. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9181. */
  9182. static readonly QUALITY_MEDIUM: number;
  9183. /**
  9184. * Reserved for PCF and PCSS
  9185. * The lowest quality but the fastest.
  9186. *
  9187. * Execute PCF on a 1*1 kernel.
  9188. *
  9189. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9190. */
  9191. static readonly QUALITY_LOW: number;
  9192. /** Gets or sets the custom shader name to use */
  9193. customShaderOptions: ICustomShaderOptions;
  9194. /**
  9195. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9196. */
  9197. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9198. /**
  9199. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9200. */
  9201. onAfterShadowMapRenderObservable: Observable<Effect>;
  9202. /**
  9203. * Observable triggered before a mesh is rendered in the shadow map.
  9204. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9205. */
  9206. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9207. /**
  9208. * Observable triggered after a mesh is rendered in the shadow map.
  9209. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9210. */
  9211. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9212. private _bias;
  9213. /**
  9214. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9215. */
  9216. /**
  9217. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9218. */
  9219. bias: number;
  9220. private _normalBias;
  9221. /**
  9222. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9223. */
  9224. /**
  9225. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9226. */
  9227. normalBias: number;
  9228. private _blurBoxOffset;
  9229. /**
  9230. * Gets the blur box offset: offset applied during the blur pass.
  9231. * Only useful if useKernelBlur = false
  9232. */
  9233. /**
  9234. * Sets the blur box offset: offset applied during the blur pass.
  9235. * Only useful if useKernelBlur = false
  9236. */
  9237. blurBoxOffset: number;
  9238. private _blurScale;
  9239. /**
  9240. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9241. * 2 means half of the size.
  9242. */
  9243. /**
  9244. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9245. * 2 means half of the size.
  9246. */
  9247. blurScale: number;
  9248. private _blurKernel;
  9249. /**
  9250. * Gets the blur kernel: kernel size of the blur pass.
  9251. * Only useful if useKernelBlur = true
  9252. */
  9253. /**
  9254. * Sets the blur kernel: kernel size of the blur pass.
  9255. * Only useful if useKernelBlur = true
  9256. */
  9257. blurKernel: number;
  9258. private _useKernelBlur;
  9259. /**
  9260. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9261. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9262. */
  9263. /**
  9264. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9265. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9266. */
  9267. useKernelBlur: boolean;
  9268. private _depthScale;
  9269. /**
  9270. * Gets the depth scale used in ESM mode.
  9271. */
  9272. /**
  9273. * Sets the depth scale used in ESM mode.
  9274. * This can override the scale stored on the light.
  9275. */
  9276. depthScale: number;
  9277. private _filter;
  9278. /**
  9279. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9280. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9281. */
  9282. /**
  9283. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9284. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9285. */
  9286. filter: number;
  9287. /**
  9288. * Gets if the current filter is set to Poisson Sampling.
  9289. */
  9290. /**
  9291. * Sets the current filter to Poisson Sampling.
  9292. */
  9293. usePoissonSampling: boolean;
  9294. /**
  9295. * Gets if the current filter is set to ESM.
  9296. */
  9297. /**
  9298. * Sets the current filter is to ESM.
  9299. */
  9300. useExponentialShadowMap: boolean;
  9301. /**
  9302. * Gets if the current filter is set to filtered ESM.
  9303. */
  9304. /**
  9305. * Gets if the current filter is set to filtered ESM.
  9306. */
  9307. useBlurExponentialShadowMap: boolean;
  9308. /**
  9309. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9310. * exponential to prevent steep falloff artifacts).
  9311. */
  9312. /**
  9313. * Sets the current filter to "close ESM" (using the inverse of the
  9314. * exponential to prevent steep falloff artifacts).
  9315. */
  9316. useCloseExponentialShadowMap: boolean;
  9317. /**
  9318. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9319. * exponential to prevent steep falloff artifacts).
  9320. */
  9321. /**
  9322. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9323. * exponential to prevent steep falloff artifacts).
  9324. */
  9325. useBlurCloseExponentialShadowMap: boolean;
  9326. /**
  9327. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9328. */
  9329. /**
  9330. * Sets the current filter to "PCF" (percentage closer filtering).
  9331. */
  9332. usePercentageCloserFiltering: boolean;
  9333. private _filteringQuality;
  9334. /**
  9335. * Gets the PCF or PCSS Quality.
  9336. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9337. */
  9338. /**
  9339. * Sets the PCF or PCSS Quality.
  9340. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9341. */
  9342. filteringQuality: number;
  9343. /**
  9344. * Gets if the current filter is set to "PCSS" (contact hardening).
  9345. */
  9346. /**
  9347. * Sets the current filter to "PCSS" (contact hardening).
  9348. */
  9349. useContactHardeningShadow: boolean;
  9350. private _contactHardeningLightSizeUVRatio;
  9351. /**
  9352. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9353. * Using a ratio helps keeping shape stability independently of the map size.
  9354. *
  9355. * It does not account for the light projection as it was having too much
  9356. * instability during the light setup or during light position changes.
  9357. *
  9358. * Only valid if useContactHardeningShadow is true.
  9359. */
  9360. /**
  9361. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9362. * Using a ratio helps keeping shape stability independently of the map size.
  9363. *
  9364. * It does not account for the light projection as it was having too much
  9365. * instability during the light setup or during light position changes.
  9366. *
  9367. * Only valid if useContactHardeningShadow is true.
  9368. */
  9369. contactHardeningLightSizeUVRatio: number;
  9370. private _darkness;
  9371. /** Gets or sets the actual darkness of a shadow */
  9372. darkness: number;
  9373. /**
  9374. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9375. * 0 means strongest and 1 would means no shadow.
  9376. * @returns the darkness.
  9377. */
  9378. getDarkness(): number;
  9379. /**
  9380. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9381. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9382. * @returns the shadow generator allowing fluent coding.
  9383. */
  9384. setDarkness(darkness: number): ShadowGenerator;
  9385. private _transparencyShadow;
  9386. /** Gets or sets the ability to have transparent shadow */
  9387. transparencyShadow: boolean;
  9388. /**
  9389. * Sets the ability to have transparent shadow (boolean).
  9390. * @param transparent True if transparent else False
  9391. * @returns the shadow generator allowing fluent coding
  9392. */
  9393. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9394. private _shadowMap;
  9395. private _shadowMap2;
  9396. /**
  9397. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9398. * @returns The render target texture if present otherwise, null
  9399. */
  9400. getShadowMap(): Nullable<RenderTargetTexture>;
  9401. /**
  9402. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9403. * @returns The render target texture if the shadow map is present otherwise, null
  9404. */
  9405. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9406. /**
  9407. * Gets the class name of that object
  9408. * @returns "ShadowGenerator"
  9409. */
  9410. getClassName(): string;
  9411. /**
  9412. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9413. * @param mesh Mesh to add
  9414. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9415. * @returns the Shadow Generator itself
  9416. */
  9417. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9418. /**
  9419. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9420. * @param mesh Mesh to remove
  9421. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9422. * @returns the Shadow Generator itself
  9423. */
  9424. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9425. /**
  9426. * Controls the extent to which the shadows fade out at the edge of the frustum
  9427. * Used only by directionals and spots
  9428. */
  9429. frustumEdgeFalloff: number;
  9430. private _light;
  9431. /**
  9432. * Returns the associated light object.
  9433. * @returns the light generating the shadow
  9434. */
  9435. getLight(): IShadowLight;
  9436. /**
  9437. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9438. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9439. * It might on the other hand introduce peter panning.
  9440. */
  9441. forceBackFacesOnly: boolean;
  9442. private _scene;
  9443. private _lightDirection;
  9444. private _effect;
  9445. private _viewMatrix;
  9446. private _projectionMatrix;
  9447. private _transformMatrix;
  9448. private _cachedPosition;
  9449. private _cachedDirection;
  9450. private _cachedDefines;
  9451. private _currentRenderID;
  9452. private _boxBlurPostprocess;
  9453. private _kernelBlurXPostprocess;
  9454. private _kernelBlurYPostprocess;
  9455. private _blurPostProcesses;
  9456. private _mapSize;
  9457. private _currentFaceIndex;
  9458. private _currentFaceIndexCache;
  9459. private _textureType;
  9460. private _defaultTextureMatrix;
  9461. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  9462. /**
  9463. * Creates a ShadowGenerator object.
  9464. * A ShadowGenerator is the required tool to use the shadows.
  9465. * Each light casting shadows needs to use its own ShadowGenerator.
  9466. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9467. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9468. * @param light The light object generating the shadows.
  9469. * @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.
  9470. */
  9471. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9472. private _initializeGenerator;
  9473. private _initializeShadowMap;
  9474. private _initializeBlurRTTAndPostProcesses;
  9475. private _renderForShadowMap;
  9476. private _renderSubMeshForShadowMap;
  9477. private _applyFilterValues;
  9478. /**
  9479. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9480. * @param onCompiled Callback triggered at the and of the effects compilation
  9481. * @param options Sets of optional options forcing the compilation with different modes
  9482. */
  9483. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9484. useInstances: boolean;
  9485. }>): void;
  9486. /**
  9487. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9488. * @param options Sets of optional options forcing the compilation with different modes
  9489. * @returns A promise that resolves when the compilation completes
  9490. */
  9491. forceCompilationAsync(options?: Partial<{
  9492. useInstances: boolean;
  9493. }>): Promise<void>;
  9494. /**
  9495. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9496. * @param subMesh The submesh we want to render in the shadow map
  9497. * @param useInstances Defines wether will draw in the map using instances
  9498. * @returns true if ready otherwise, false
  9499. */
  9500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9501. /**
  9502. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9503. * @param defines Defines of the material we want to update
  9504. * @param lightIndex Index of the light in the enabled light list of the material
  9505. */
  9506. prepareDefines(defines: any, lightIndex: number): void;
  9507. /**
  9508. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9509. * defined in the generator but impacting the effect).
  9510. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9511. * @param effect The effect we are binfing the information for
  9512. */
  9513. bindShadowLight(lightIndex: string, effect: Effect): void;
  9514. /**
  9515. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9516. * (eq to shadow prjection matrix * light transform matrix)
  9517. * @returns The transform matrix used to create the shadow map
  9518. */
  9519. getTransformMatrix(): Matrix;
  9520. /**
  9521. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9522. * Cube and 2D textures for instance.
  9523. */
  9524. recreateShadowMap(): void;
  9525. private _disposeBlurPostProcesses;
  9526. private _disposeRTTandPostProcesses;
  9527. /**
  9528. * Disposes the ShadowGenerator.
  9529. * Returns nothing.
  9530. */
  9531. dispose(): void;
  9532. /**
  9533. * Serializes the shadow generator setup to a json object.
  9534. * @returns The serialized JSON object
  9535. */
  9536. serialize(): any;
  9537. /**
  9538. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9539. * @param parsedShadowGenerator The JSON object to parse
  9540. * @param scene The scene to create the shadow map for
  9541. * @returns The parsed shadow generator
  9542. */
  9543. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9544. }
  9545. }
  9546. declare module BABYLON {
  9547. /**
  9548. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9549. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9550. * 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.
  9551. */
  9552. export abstract class Light extends Node {
  9553. /**
  9554. * Falloff Default: light is falling off following the material specification:
  9555. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9556. */
  9557. static readonly FALLOFF_DEFAULT: number;
  9558. /**
  9559. * Falloff Physical: light is falling off following the inverse squared distance law.
  9560. */
  9561. static readonly FALLOFF_PHYSICAL: number;
  9562. /**
  9563. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9564. * to enhance interoperability with other engines.
  9565. */
  9566. static readonly FALLOFF_GLTF: number;
  9567. /**
  9568. * Falloff Standard: light is falling off like in the standard material
  9569. * to enhance interoperability with other materials.
  9570. */
  9571. static readonly FALLOFF_STANDARD: number;
  9572. /**
  9573. * If every light affecting the material is in this lightmapMode,
  9574. * material.lightmapTexture adds or multiplies
  9575. * (depends on material.useLightmapAsShadowmap)
  9576. * after every other light calculations.
  9577. */
  9578. static readonly LIGHTMAP_DEFAULT: number;
  9579. /**
  9580. * material.lightmapTexture as only diffuse lighting from this light
  9581. * adds only specular lighting from this light
  9582. * adds dynamic shadows
  9583. */
  9584. static readonly LIGHTMAP_SPECULAR: number;
  9585. /**
  9586. * material.lightmapTexture as only lighting
  9587. * no light calculation from this light
  9588. * only adds dynamic shadows from this light
  9589. */
  9590. static readonly LIGHTMAP_SHADOWSONLY: number;
  9591. /**
  9592. * Each light type uses the default quantity according to its type:
  9593. * point/spot lights use luminous intensity
  9594. * directional lights use illuminance
  9595. */
  9596. static readonly INTENSITYMODE_AUTOMATIC: number;
  9597. /**
  9598. * lumen (lm)
  9599. */
  9600. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  9601. /**
  9602. * candela (lm/sr)
  9603. */
  9604. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  9605. /**
  9606. * lux (lm/m^2)
  9607. */
  9608. static readonly INTENSITYMODE_ILLUMINANCE: number;
  9609. /**
  9610. * nit (cd/m^2)
  9611. */
  9612. static readonly INTENSITYMODE_LUMINANCE: number;
  9613. /**
  9614. * Light type const id of the point light.
  9615. */
  9616. static readonly LIGHTTYPEID_POINTLIGHT: number;
  9617. /**
  9618. * Light type const id of the directional light.
  9619. */
  9620. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  9621. /**
  9622. * Light type const id of the spot light.
  9623. */
  9624. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  9625. /**
  9626. * Light type const id of the hemispheric light.
  9627. */
  9628. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  9629. /**
  9630. * Diffuse gives the basic color to an object.
  9631. */
  9632. diffuse: Color3;
  9633. /**
  9634. * Specular produces a highlight color on an object.
  9635. * Note: This is note affecting PBR materials.
  9636. */
  9637. specular: Color3;
  9638. /**
  9639. * Defines the falloff type for this light. This lets overrriding how punctual light are
  9640. * falling off base on range or angle.
  9641. * This can be set to any values in Light.FALLOFF_x.
  9642. *
  9643. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  9644. * other types of materials.
  9645. */
  9646. falloffType: number;
  9647. /**
  9648. * Strength of the light.
  9649. * Note: By default it is define in the framework own unit.
  9650. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  9651. */
  9652. intensity: number;
  9653. private _range;
  9654. protected _inverseSquaredRange: number;
  9655. /**
  9656. * Defines how far from the source the light is impacting in scene units.
  9657. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9658. */
  9659. /**
  9660. * Defines how far from the source the light is impacting in scene units.
  9661. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  9662. */
  9663. range: number;
  9664. /**
  9665. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  9666. * of light.
  9667. */
  9668. private _photometricScale;
  9669. private _intensityMode;
  9670. /**
  9671. * Gets the photometric scale used to interpret the intensity.
  9672. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9673. */
  9674. /**
  9675. * Sets the photometric scale used to interpret the intensity.
  9676. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  9677. */
  9678. intensityMode: number;
  9679. private _radius;
  9680. /**
  9681. * Gets the light radius used by PBR Materials to simulate soft area lights.
  9682. */
  9683. /**
  9684. * sets the light radius used by PBR Materials to simulate soft area lights.
  9685. */
  9686. radius: number;
  9687. private _renderPriority;
  9688. /**
  9689. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  9690. * exceeding the number allowed of the materials.
  9691. */
  9692. renderPriority: number;
  9693. private _shadowEnabled;
  9694. /**
  9695. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9696. * the current shadow generator.
  9697. */
  9698. /**
  9699. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  9700. * the current shadow generator.
  9701. */
  9702. shadowEnabled: boolean;
  9703. private _includedOnlyMeshes;
  9704. /**
  9705. * Gets the only meshes impacted by this light.
  9706. */
  9707. /**
  9708. * Sets the only meshes impacted by this light.
  9709. */
  9710. includedOnlyMeshes: AbstractMesh[];
  9711. private _excludedMeshes;
  9712. /**
  9713. * Gets the meshes not impacted by this light.
  9714. */
  9715. /**
  9716. * Sets the meshes not impacted by this light.
  9717. */
  9718. excludedMeshes: AbstractMesh[];
  9719. private _excludeWithLayerMask;
  9720. /**
  9721. * Gets the layer id use to find what meshes are not impacted by the light.
  9722. * Inactive if 0
  9723. */
  9724. /**
  9725. * Sets the layer id use to find what meshes are not impacted by the light.
  9726. * Inactive if 0
  9727. */
  9728. excludeWithLayerMask: number;
  9729. private _includeOnlyWithLayerMask;
  9730. /**
  9731. * Gets the layer id use to find what meshes are impacted by the light.
  9732. * Inactive if 0
  9733. */
  9734. /**
  9735. * Sets the layer id use to find what meshes are impacted by the light.
  9736. * Inactive if 0
  9737. */
  9738. includeOnlyWithLayerMask: number;
  9739. private _lightmapMode;
  9740. /**
  9741. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9742. */
  9743. /**
  9744. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  9745. */
  9746. lightmapMode: number;
  9747. /**
  9748. * Shadow generator associted to the light.
  9749. * @hidden Internal use only.
  9750. */ private _shadowGenerator: Nullable<IShadowGenerator>;
  9751. /**
  9752. * @hidden Internal use only.
  9753. */ private _excludedMeshesIds: string[];
  9754. /**
  9755. * @hidden Internal use only.
  9756. */ private _includedOnlyMeshesIds: string[];
  9757. /**
  9758. * The current light unifom buffer.
  9759. * @hidden Internal use only.
  9760. */ private _uniformBuffer: UniformBuffer;
  9761. /**
  9762. * Creates a Light object in the scene.
  9763. * Documentation : https://doc.babylonjs.com/babylon101/lights
  9764. * @param name The firendly name of the light
  9765. * @param scene The scene the light belongs too
  9766. */
  9767. constructor(name: string, scene: Scene);
  9768. protected abstract _buildUniformLayout(): void;
  9769. /**
  9770. * Sets the passed Effect "effect" with the Light information.
  9771. * @param effect The effect to update
  9772. * @param lightIndex The index of the light in the effect to update
  9773. * @returns The light
  9774. */
  9775. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  9776. /**
  9777. * Returns the string "Light".
  9778. * @returns the class name
  9779. */
  9780. getClassName(): string;
  9781. /** @hidden */ protected readonly _isLight: boolean;
  9782. /**
  9783. * Converts the light information to a readable string for debug purpose.
  9784. * @param fullDetails Supports for multiple levels of logging within scene loading
  9785. * @returns the human readable light info
  9786. */
  9787. toString(fullDetails?: boolean): string;
  9788. /** @hidden */
  9789. protected _syncParentEnabledState(): void;
  9790. /**
  9791. * Set the enabled state of this node.
  9792. * @param value - the new enabled state
  9793. */
  9794. setEnabled(value: boolean): void;
  9795. /**
  9796. * Returns the Light associated shadow generator if any.
  9797. * @return the associated shadow generator.
  9798. */
  9799. getShadowGenerator(): Nullable<IShadowGenerator>;
  9800. /**
  9801. * Returns a Vector3, the absolute light position in the World.
  9802. * @returns the world space position of the light
  9803. */
  9804. getAbsolutePosition(): Vector3;
  9805. /**
  9806. * Specifies if the light will affect the passed mesh.
  9807. * @param mesh The mesh to test against the light
  9808. * @return true the mesh is affected otherwise, false.
  9809. */
  9810. canAffectMesh(mesh: AbstractMesh): boolean;
  9811. /**
  9812. * Sort function to order lights for rendering.
  9813. * @param a First Light object to compare to second.
  9814. * @param b Second Light object to compare first.
  9815. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  9816. */
  9817. static CompareLightsPriority(a: Light, b: Light): number;
  9818. /**
  9819. * Releases resources associated with this node.
  9820. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  9821. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  9822. */
  9823. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  9824. /**
  9825. * Returns the light type ID (integer).
  9826. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  9827. */
  9828. getTypeID(): number;
  9829. /**
  9830. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  9831. * @returns the scaled intensity in intensity mode unit
  9832. */
  9833. getScaledIntensity(): number;
  9834. /**
  9835. * Returns a new Light object, named "name", from the current one.
  9836. * @param name The name of the cloned light
  9837. * @returns the new created light
  9838. */
  9839. clone(name: string): Nullable<Light>;
  9840. /**
  9841. * Serializes the current light into a Serialization object.
  9842. * @returns the serialized object.
  9843. */
  9844. serialize(): any;
  9845. /**
  9846. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  9847. * This new light is named "name" and added to the passed scene.
  9848. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  9849. * @param name The friendly name of the light
  9850. * @param scene The scene the new light will belong to
  9851. * @returns the constructor function
  9852. */
  9853. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  9854. /**
  9855. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  9856. * @param parsedLight The JSON representation of the light
  9857. * @param scene The scene to create the parsed light in
  9858. * @returns the created light after parsing
  9859. */
  9860. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  9861. private _hookArrayForExcluded;
  9862. private _hookArrayForIncludedOnly;
  9863. private _resyncMeshes;
  9864. /**
  9865. * Forces the meshes to update their light related information in their rendering used effects
  9866. * @hidden Internal Use Only
  9867. */ private _markMeshesAsLightDirty(): void;
  9868. /**
  9869. * Recomputes the cached photometric scale if needed.
  9870. */
  9871. private _computePhotometricScale;
  9872. /**
  9873. * Returns the Photometric Scale according to the light type and intensity mode.
  9874. */
  9875. private _getPhotometricScale;
  9876. /**
  9877. * Reorder the light in the scene according to their defined priority.
  9878. * @hidden Internal Use Only
  9879. */ private _reorderLightsInScene(): void;
  9880. /**
  9881. * Prepares the list of defines specific to the light type.
  9882. * @param defines the list of defines
  9883. * @param lightIndex defines the index of the light for the effect
  9884. */
  9885. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  9886. }
  9887. }
  9888. declare module BABYLON {
  9889. /**
  9890. * Interface used to define Action
  9891. */
  9892. export interface IAction {
  9893. /**
  9894. * Trigger for the action
  9895. */
  9896. trigger: number;
  9897. /** Options of the trigger */
  9898. triggerOptions: any;
  9899. /**
  9900. * Gets the trigger parameters
  9901. * @returns the trigger parameters
  9902. */
  9903. getTriggerParameter(): any;
  9904. /**
  9905. * Internal only - executes current action event
  9906. * @hidden
  9907. */ private _executeCurrent(evt?: ActionEvent): void;
  9908. /**
  9909. * Serialize placeholder for child classes
  9910. * @param parent of child
  9911. * @returns the serialized object
  9912. */
  9913. serialize(parent: any): any;
  9914. /**
  9915. * Internal only
  9916. * @hidden
  9917. */ private _prepare(): void;
  9918. /**
  9919. * Internal only - manager for action
  9920. * @hidden
  9921. */ private _actionManager: AbstractActionManager;
  9922. /**
  9923. * Adds action to chain of actions, may be a DoNothingAction
  9924. * @param action defines the next action to execute
  9925. * @returns The action passed in
  9926. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9927. */
  9928. then(action: IAction): IAction;
  9929. }
  9930. /**
  9931. * The action to be carried out following a trigger
  9932. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9933. */
  9934. export class Action implements IAction {
  9935. /** the trigger, with or without parameters, for the action */
  9936. triggerOptions: any;
  9937. /**
  9938. * Trigger for the action
  9939. */
  9940. trigger: number;
  9941. /**
  9942. * Internal only - manager for action
  9943. * @hidden
  9944. */ private _actionManager: ActionManager;
  9945. private _nextActiveAction;
  9946. private _child;
  9947. private _condition?;
  9948. private _triggerParameter;
  9949. /**
  9950. * An event triggered prior to action being executed.
  9951. */
  9952. onBeforeExecuteObservable: Observable<Action>;
  9953. /**
  9954. * Creates a new Action
  9955. * @param triggerOptions the trigger, with or without parameters, for the action
  9956. * @param condition an optional determinant of action
  9957. */
  9958. constructor(
  9959. /** the trigger, with or without parameters, for the action */
  9960. triggerOptions: any, condition?: Condition);
  9961. /**
  9962. * Internal only
  9963. * @hidden
  9964. */ private _prepare(): void;
  9965. /**
  9966. * Gets the trigger parameters
  9967. * @returns the trigger parameters
  9968. */
  9969. getTriggerParameter(): any;
  9970. /**
  9971. * Internal only - executes current action event
  9972. * @hidden
  9973. */ private _executeCurrent(evt?: ActionEvent): void;
  9974. /**
  9975. * Execute placeholder for child classes
  9976. * @param evt optional action event
  9977. */
  9978. execute(evt?: ActionEvent): void;
  9979. /**
  9980. * Skips to next active action
  9981. */
  9982. skipToNextActiveAction(): void;
  9983. /**
  9984. * Adds action to chain of actions, may be a DoNothingAction
  9985. * @param action defines the next action to execute
  9986. * @returns The action passed in
  9987. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9988. */
  9989. then(action: Action): Action;
  9990. /**
  9991. * Internal only
  9992. * @hidden
  9993. */ private _getProperty(propertyPath: string): string;
  9994. /**
  9995. * Internal only
  9996. * @hidden
  9997. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  9998. /**
  9999. * Serialize placeholder for child classes
  10000. * @param parent of child
  10001. * @returns the serialized object
  10002. */
  10003. serialize(parent: any): any;
  10004. /**
  10005. * Internal only called by serialize
  10006. * @hidden
  10007. */
  10008. protected _serialize(serializedAction: any, parent?: any): any;
  10009. /**
  10010. * Internal only
  10011. * @hidden
  10012. */ private static _SerializeValueAsString: (value: any) => string;
  10013. /**
  10014. * Internal only
  10015. * @hidden
  10016. */ private static _GetTargetProperty: (target: Node | Scene) => {
  10017. name: string;
  10018. targetType: string;
  10019. value: string;
  10020. };
  10021. }
  10022. }
  10023. declare module BABYLON {
  10024. /**
  10025. * A Condition applied to an Action
  10026. */
  10027. export class Condition {
  10028. /**
  10029. * Internal only - manager for action
  10030. * @hidden
  10031. */ private _actionManager: ActionManager;
  10032. /**
  10033. * Internal only
  10034. * @hidden
  10035. */ private _evaluationId: number;
  10036. /**
  10037. * Internal only
  10038. * @hidden
  10039. */ private _currentResult: boolean;
  10040. /**
  10041. * Creates a new Condition
  10042. * @param actionManager the manager of the action the condition is applied to
  10043. */
  10044. constructor(actionManager: ActionManager);
  10045. /**
  10046. * Check if the current condition is valid
  10047. * @returns a boolean
  10048. */
  10049. isValid(): boolean;
  10050. /**
  10051. * Internal only
  10052. * @hidden
  10053. */ private _getProperty(propertyPath: string): string;
  10054. /**
  10055. * Internal only
  10056. * @hidden
  10057. */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10058. /**
  10059. * Serialize placeholder for child classes
  10060. * @returns the serialized object
  10061. */
  10062. serialize(): any;
  10063. /**
  10064. * Internal only
  10065. * @hidden
  10066. */
  10067. protected _serialize(serializedCondition: any): any;
  10068. }
  10069. /**
  10070. * Defines specific conditional operators as extensions of Condition
  10071. */
  10072. export class ValueCondition extends Condition {
  10073. /** path to specify the property of the target the conditional operator uses */
  10074. propertyPath: string;
  10075. /** the value compared by the conditional operator against the current value of the property */
  10076. value: any;
  10077. /** the conditional operator, default ValueCondition.IsEqual */
  10078. operator: number;
  10079. /**
  10080. * Internal only
  10081. * @hidden
  10082. */
  10083. private static _IsEqual;
  10084. /**
  10085. * Internal only
  10086. * @hidden
  10087. */
  10088. private static _IsDifferent;
  10089. /**
  10090. * Internal only
  10091. * @hidden
  10092. */
  10093. private static _IsGreater;
  10094. /**
  10095. * Internal only
  10096. * @hidden
  10097. */
  10098. private static _IsLesser;
  10099. /**
  10100. * returns the number for IsEqual
  10101. */
  10102. static readonly IsEqual: number;
  10103. /**
  10104. * Returns the number for IsDifferent
  10105. */
  10106. static readonly IsDifferent: number;
  10107. /**
  10108. * Returns the number for IsGreater
  10109. */
  10110. static readonly IsGreater: number;
  10111. /**
  10112. * Returns the number for IsLesser
  10113. */
  10114. static readonly IsLesser: number;
  10115. /**
  10116. * Internal only The action manager for the condition
  10117. * @hidden
  10118. */ private _actionManager: ActionManager;
  10119. /**
  10120. * Internal only
  10121. * @hidden
  10122. */
  10123. private _target;
  10124. /**
  10125. * Internal only
  10126. * @hidden
  10127. */
  10128. private _effectiveTarget;
  10129. /**
  10130. * Internal only
  10131. * @hidden
  10132. */
  10133. private _property;
  10134. /**
  10135. * Creates a new ValueCondition
  10136. * @param actionManager manager for the action the condition applies to
  10137. * @param target for the action
  10138. * @param propertyPath path to specify the property of the target the conditional operator uses
  10139. * @param value the value compared by the conditional operator against the current value of the property
  10140. * @param operator the conditional operator, default ValueCondition.IsEqual
  10141. */
  10142. constructor(actionManager: ActionManager, target: any,
  10143. /** path to specify the property of the target the conditional operator uses */
  10144. propertyPath: string,
  10145. /** the value compared by the conditional operator against the current value of the property */
  10146. value: any,
  10147. /** the conditional operator, default ValueCondition.IsEqual */
  10148. operator?: number);
  10149. /**
  10150. * Compares the given value with the property value for the specified conditional operator
  10151. * @returns the result of the comparison
  10152. */
  10153. isValid(): boolean;
  10154. /**
  10155. * Serialize the ValueCondition into a JSON compatible object
  10156. * @returns serialization object
  10157. */
  10158. serialize(): any;
  10159. /**
  10160. * Gets the name of the conditional operator for the ValueCondition
  10161. * @param operator the conditional operator
  10162. * @returns the name
  10163. */
  10164. static GetOperatorName(operator: number): string;
  10165. }
  10166. /**
  10167. * Defines a predicate condition as an extension of Condition
  10168. */
  10169. export class PredicateCondition extends Condition {
  10170. /** defines the predicate function used to validate the condition */
  10171. predicate: () => boolean;
  10172. /**
  10173. * Internal only - manager for action
  10174. * @hidden
  10175. */ private _actionManager: ActionManager;
  10176. /**
  10177. * Creates a new PredicateCondition
  10178. * @param actionManager manager for the action the condition applies to
  10179. * @param predicate defines the predicate function used to validate the condition
  10180. */
  10181. constructor(actionManager: ActionManager,
  10182. /** defines the predicate function used to validate the condition */
  10183. predicate: () => boolean);
  10184. /**
  10185. * @returns the validity of the predicate condition
  10186. */
  10187. isValid(): boolean;
  10188. }
  10189. /**
  10190. * Defines a state condition as an extension of Condition
  10191. */
  10192. export class StateCondition extends Condition {
  10193. /** Value to compare with target state */
  10194. value: string;
  10195. /**
  10196. * Internal only - manager for action
  10197. * @hidden
  10198. */ private _actionManager: ActionManager;
  10199. /**
  10200. * Internal only
  10201. * @hidden
  10202. */
  10203. private _target;
  10204. /**
  10205. * Creates a new StateCondition
  10206. * @param actionManager manager for the action the condition applies to
  10207. * @param target of the condition
  10208. * @param value to compare with target state
  10209. */
  10210. constructor(actionManager: ActionManager, target: any,
  10211. /** Value to compare with target state */
  10212. value: string);
  10213. /**
  10214. * Gets a boolean indicating if the current condition is met
  10215. * @returns the validity of the state
  10216. */
  10217. isValid(): boolean;
  10218. /**
  10219. * Serialize the StateCondition into a JSON compatible object
  10220. * @returns serialization object
  10221. */
  10222. serialize(): any;
  10223. }
  10224. }
  10225. declare module BABYLON {
  10226. /**
  10227. * This defines an action responsible to toggle a boolean once triggered.
  10228. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class SwitchBooleanAction extends Action {
  10231. /**
  10232. * The path to the boolean property in the target object
  10233. */
  10234. propertyPath: string;
  10235. private _target;
  10236. private _effectiveTarget;
  10237. private _property;
  10238. /**
  10239. * Instantiate the action
  10240. * @param triggerOptions defines the trigger options
  10241. * @param target defines the object containing the boolean
  10242. * @param propertyPath defines the path to the boolean property in the target object
  10243. * @param condition defines the trigger related conditions
  10244. */
  10245. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10246. /** @hidden */ private _prepare(): void;
  10247. /**
  10248. * Execute the action toggle the boolean value.
  10249. */
  10250. execute(): void;
  10251. /**
  10252. * Serializes the actions and its related information.
  10253. * @param parent defines the object to serialize in
  10254. * @returns the serialized object
  10255. */
  10256. serialize(parent: any): any;
  10257. }
  10258. /**
  10259. * This defines an action responsible to set a the state field of the target
  10260. * to a desired value once triggered.
  10261. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10262. */
  10263. export class SetStateAction extends Action {
  10264. /**
  10265. * The value to store in the state field.
  10266. */
  10267. value: string;
  10268. private _target;
  10269. /**
  10270. * Instantiate the action
  10271. * @param triggerOptions defines the trigger options
  10272. * @param target defines the object containing the state property
  10273. * @param value defines the value to store in the state field
  10274. * @param condition defines the trigger related conditions
  10275. */
  10276. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10277. /**
  10278. * Execute the action and store the value on the target state property.
  10279. */
  10280. execute(): void;
  10281. /**
  10282. * Serializes the actions and its related information.
  10283. * @param parent defines the object to serialize in
  10284. * @returns the serialized object
  10285. */
  10286. serialize(parent: any): any;
  10287. }
  10288. /**
  10289. * This defines an action responsible to set a property of the target
  10290. * to a desired value once triggered.
  10291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10292. */
  10293. export class SetValueAction extends Action {
  10294. /**
  10295. * The path of the property to set in the target.
  10296. */
  10297. propertyPath: string;
  10298. /**
  10299. * The value to set in the property
  10300. */
  10301. value: any;
  10302. private _target;
  10303. private _effectiveTarget;
  10304. private _property;
  10305. /**
  10306. * Instantiate the action
  10307. * @param triggerOptions defines the trigger options
  10308. * @param target defines the object containing the property
  10309. * @param propertyPath defines the path of the property to set in the target
  10310. * @param value defines the value to set in the property
  10311. * @param condition defines the trigger related conditions
  10312. */
  10313. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10314. /** @hidden */ private _prepare(): void;
  10315. /**
  10316. * Execute the action and set the targetted property to the desired value.
  10317. */
  10318. execute(): void;
  10319. /**
  10320. * Serializes the actions and its related information.
  10321. * @param parent defines the object to serialize in
  10322. * @returns the serialized object
  10323. */
  10324. serialize(parent: any): any;
  10325. }
  10326. /**
  10327. * This defines an action responsible to increment the target value
  10328. * to a desired value once triggered.
  10329. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10330. */
  10331. export class IncrementValueAction extends Action {
  10332. /**
  10333. * The path of the property to increment in the target.
  10334. */
  10335. propertyPath: string;
  10336. /**
  10337. * The value we should increment the property by.
  10338. */
  10339. value: any;
  10340. private _target;
  10341. private _effectiveTarget;
  10342. private _property;
  10343. /**
  10344. * Instantiate the action
  10345. * @param triggerOptions defines the trigger options
  10346. * @param target defines the object containing the property
  10347. * @param propertyPath defines the path of the property to increment in the target
  10348. * @param value defines the value value we should increment the property by
  10349. * @param condition defines the trigger related conditions
  10350. */
  10351. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10352. /** @hidden */ private _prepare(): void;
  10353. /**
  10354. * Execute the action and increment the target of the value amount.
  10355. */
  10356. execute(): void;
  10357. /**
  10358. * Serializes the actions and its related information.
  10359. * @param parent defines the object to serialize in
  10360. * @returns the serialized object
  10361. */
  10362. serialize(parent: any): any;
  10363. }
  10364. /**
  10365. * This defines an action responsible to start an animation once triggered.
  10366. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10367. */
  10368. export class PlayAnimationAction extends Action {
  10369. /**
  10370. * Where the animation should start (animation frame)
  10371. */
  10372. from: number;
  10373. /**
  10374. * Where the animation should stop (animation frame)
  10375. */
  10376. to: number;
  10377. /**
  10378. * Define if the animation should loop or stop after the first play.
  10379. */
  10380. loop?: boolean;
  10381. private _target;
  10382. /**
  10383. * Instantiate the action
  10384. * @param triggerOptions defines the trigger options
  10385. * @param target defines the target animation or animation name
  10386. * @param from defines from where the animation should start (animation frame)
  10387. * @param end defines where the animation should stop (animation frame)
  10388. * @param loop defines if the animation should loop or stop after the first play
  10389. * @param condition defines the trigger related conditions
  10390. */
  10391. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10392. /** @hidden */ private _prepare(): void;
  10393. /**
  10394. * Execute the action and play the animation.
  10395. */
  10396. execute(): void;
  10397. /**
  10398. * Serializes the actions and its related information.
  10399. * @param parent defines the object to serialize in
  10400. * @returns the serialized object
  10401. */
  10402. serialize(parent: any): any;
  10403. }
  10404. /**
  10405. * This defines an action responsible to stop an animation once triggered.
  10406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10407. */
  10408. export class StopAnimationAction extends Action {
  10409. private _target;
  10410. /**
  10411. * Instantiate the action
  10412. * @param triggerOptions defines the trigger options
  10413. * @param target defines the target animation or animation name
  10414. * @param condition defines the trigger related conditions
  10415. */
  10416. constructor(triggerOptions: any, target: any, condition?: Condition);
  10417. /** @hidden */ private _prepare(): void;
  10418. /**
  10419. * Execute the action and stop the animation.
  10420. */
  10421. execute(): void;
  10422. /**
  10423. * Serializes the actions and its related information.
  10424. * @param parent defines the object to serialize in
  10425. * @returns the serialized object
  10426. */
  10427. serialize(parent: any): any;
  10428. }
  10429. /**
  10430. * This defines an action responsible that does nothing once triggered.
  10431. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10432. */
  10433. export class DoNothingAction extends Action {
  10434. /**
  10435. * Instantiate the action
  10436. * @param triggerOptions defines the trigger options
  10437. * @param condition defines the trigger related conditions
  10438. */
  10439. constructor(triggerOptions?: any, condition?: Condition);
  10440. /**
  10441. * Execute the action and do nothing.
  10442. */
  10443. execute(): void;
  10444. /**
  10445. * Serializes the actions and its related information.
  10446. * @param parent defines the object to serialize in
  10447. * @returns the serialized object
  10448. */
  10449. serialize(parent: any): any;
  10450. }
  10451. /**
  10452. * This defines an action responsible to trigger several actions once triggered.
  10453. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10454. */
  10455. export class CombineAction extends Action {
  10456. /**
  10457. * The list of aggregated animations to run.
  10458. */
  10459. children: Action[];
  10460. /**
  10461. * Instantiate the action
  10462. * @param triggerOptions defines the trigger options
  10463. * @param children defines the list of aggregated animations to run
  10464. * @param condition defines the trigger related conditions
  10465. */
  10466. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10467. /** @hidden */ private _prepare(): void;
  10468. /**
  10469. * Execute the action and executes all the aggregated actions.
  10470. */
  10471. execute(evt: ActionEvent): void;
  10472. /**
  10473. * Serializes the actions and its related information.
  10474. * @param parent defines the object to serialize in
  10475. * @returns the serialized object
  10476. */
  10477. serialize(parent: any): any;
  10478. }
  10479. /**
  10480. * This defines an action responsible to run code (external event) once triggered.
  10481. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10482. */
  10483. export class ExecuteCodeAction extends Action {
  10484. /**
  10485. * The callback function to run.
  10486. */
  10487. func: (evt: ActionEvent) => void;
  10488. /**
  10489. * Instantiate the action
  10490. * @param triggerOptions defines the trigger options
  10491. * @param func defines the callback function to run
  10492. * @param condition defines the trigger related conditions
  10493. */
  10494. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10495. /**
  10496. * Execute the action and run the attached code.
  10497. */
  10498. execute(evt: ActionEvent): void;
  10499. }
  10500. /**
  10501. * This defines an action responsible to set the parent property of the target once triggered.
  10502. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10503. */
  10504. export class SetParentAction extends Action {
  10505. private _parent;
  10506. private _target;
  10507. /**
  10508. * Instantiate the action
  10509. * @param triggerOptions defines the trigger options
  10510. * @param target defines the target containing the parent property
  10511. * @param parent defines from where the animation should start (animation frame)
  10512. * @param condition defines the trigger related conditions
  10513. */
  10514. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10515. /** @hidden */ private _prepare(): void;
  10516. /**
  10517. * Execute the action and set the parent property.
  10518. */
  10519. execute(): void;
  10520. /**
  10521. * Serializes the actions and its related information.
  10522. * @param parent defines the object to serialize in
  10523. * @returns the serialized object
  10524. */
  10525. serialize(parent: any): any;
  10526. }
  10527. }
  10528. declare module BABYLON {
  10529. /**
  10530. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10531. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10532. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10533. */
  10534. export class ActionManager extends AbstractActionManager {
  10535. /**
  10536. * Nothing
  10537. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10538. */
  10539. static readonly NothingTrigger: number;
  10540. /**
  10541. * On pick
  10542. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10543. */
  10544. static readonly OnPickTrigger: number;
  10545. /**
  10546. * On left pick
  10547. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10548. */
  10549. static readonly OnLeftPickTrigger: number;
  10550. /**
  10551. * On right pick
  10552. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10553. */
  10554. static readonly OnRightPickTrigger: number;
  10555. /**
  10556. * On center pick
  10557. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10558. */
  10559. static readonly OnCenterPickTrigger: number;
  10560. /**
  10561. * On pick down
  10562. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10563. */
  10564. static readonly OnPickDownTrigger: number;
  10565. /**
  10566. * On double pick
  10567. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10568. */
  10569. static readonly OnDoublePickTrigger: number;
  10570. /**
  10571. * On pick up
  10572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10573. */
  10574. static readonly OnPickUpTrigger: number;
  10575. /**
  10576. * On pick out.
  10577. * This trigger will only be raised if you also declared a OnPickDown
  10578. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10579. */
  10580. static readonly OnPickOutTrigger: number;
  10581. /**
  10582. * On long press
  10583. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10584. */
  10585. static readonly OnLongPressTrigger: number;
  10586. /**
  10587. * On pointer over
  10588. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10589. */
  10590. static readonly OnPointerOverTrigger: number;
  10591. /**
  10592. * On pointer out
  10593. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10594. */
  10595. static readonly OnPointerOutTrigger: number;
  10596. /**
  10597. * On every frame
  10598. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10599. */
  10600. static readonly OnEveryFrameTrigger: number;
  10601. /**
  10602. * On intersection enter
  10603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10604. */
  10605. static readonly OnIntersectionEnterTrigger: number;
  10606. /**
  10607. * On intersection exit
  10608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10609. */
  10610. static readonly OnIntersectionExitTrigger: number;
  10611. /**
  10612. * On key down
  10613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10614. */
  10615. static readonly OnKeyDownTrigger: number;
  10616. /**
  10617. * On key up
  10618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10619. */
  10620. static readonly OnKeyUpTrigger: number;
  10621. private _scene;
  10622. /**
  10623. * Creates a new action manager
  10624. * @param scene defines the hosting scene
  10625. */
  10626. constructor(scene: Scene);
  10627. /**
  10628. * Releases all associated resources
  10629. */
  10630. dispose(): void;
  10631. /**
  10632. * Gets hosting scene
  10633. * @returns the hosting scene
  10634. */
  10635. getScene(): Scene;
  10636. /**
  10637. * Does this action manager handles actions of any of the given triggers
  10638. * @param triggers defines the triggers to be tested
  10639. * @return a boolean indicating whether one (or more) of the triggers is handled
  10640. */
  10641. hasSpecificTriggers(triggers: number[]): boolean;
  10642. /**
  10643. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10644. * speed.
  10645. * @param triggerA defines the trigger to be tested
  10646. * @param triggerB defines the trigger to be tested
  10647. * @return a boolean indicating whether one (or more) of the triggers is handled
  10648. */
  10649. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10650. /**
  10651. * Does this action manager handles actions of a given trigger
  10652. * @param trigger defines the trigger to be tested
  10653. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10654. * @return whether the trigger is handled
  10655. */
  10656. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10657. /**
  10658. * Does this action manager has pointer triggers
  10659. */
  10660. readonly hasPointerTriggers: boolean;
  10661. /**
  10662. * Does this action manager has pick triggers
  10663. */
  10664. readonly hasPickTriggers: boolean;
  10665. /**
  10666. * Registers an action to this action manager
  10667. * @param action defines the action to be registered
  10668. * @return the action amended (prepared) after registration
  10669. */
  10670. registerAction(action: IAction): Nullable<IAction>;
  10671. /**
  10672. * Unregisters an action to this action manager
  10673. * @param action defines the action to be unregistered
  10674. * @return a boolean indicating whether the action has been unregistered
  10675. */
  10676. unregisterAction(action: IAction): Boolean;
  10677. /**
  10678. * Process a specific trigger
  10679. * @param trigger defines the trigger to process
  10680. * @param evt defines the event details to be processed
  10681. */
  10682. processTrigger(trigger: number, evt?: IActionEvent): void;
  10683. /** @hidden */ private _getEffectiveTarget(target: any, propertyPath: string): any;
  10684. /** @hidden */ private _getProperty(propertyPath: string): string;
  10685. /**
  10686. * Serialize this manager to a JSON object
  10687. * @param name defines the property name to store this manager
  10688. * @returns a JSON representation of this manager
  10689. */
  10690. serialize(name: string): any;
  10691. /**
  10692. * Creates a new ActionManager from a JSON data
  10693. * @param parsedActions defines the JSON data to read from
  10694. * @param object defines the hosting mesh
  10695. * @param scene defines the hosting scene
  10696. */
  10697. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10698. /**
  10699. * Get a trigger name by index
  10700. * @param trigger defines the trigger index
  10701. * @returns a trigger name
  10702. */
  10703. static GetTriggerName(trigger: number): string;
  10704. }
  10705. }
  10706. declare module BABYLON {
  10707. /**
  10708. * Class representing a ray with position and direction
  10709. */
  10710. export class Ray {
  10711. /** origin point */
  10712. origin: Vector3;
  10713. /** direction */
  10714. direction: Vector3;
  10715. /** length of the ray */
  10716. length: number;
  10717. private static readonly TmpVector3;
  10718. private _tmpRay;
  10719. /**
  10720. * Creates a new ray
  10721. * @param origin origin point
  10722. * @param direction direction
  10723. * @param length length of the ray
  10724. */
  10725. constructor(
  10726. /** origin point */
  10727. origin: Vector3,
  10728. /** direction */
  10729. direction: Vector3,
  10730. /** length of the ray */
  10731. length?: number);
  10732. /**
  10733. * Checks if the ray intersects a box
  10734. * @param minimum bound of the box
  10735. * @param maximum bound of the box
  10736. * @param intersectionTreshold extra extend to be added to the box in all direction
  10737. * @returns if the box was hit
  10738. */
  10739. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10740. /**
  10741. * Checks if the ray intersects a box
  10742. * @param box the bounding box to check
  10743. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10744. * @returns if the box was hit
  10745. */
  10746. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10747. /**
  10748. * If the ray hits a sphere
  10749. * @param sphere the bounding sphere to check
  10750. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10751. * @returns true if it hits the sphere
  10752. */
  10753. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10754. /**
  10755. * If the ray hits a triange
  10756. * @param vertex0 triangle vertex
  10757. * @param vertex1 triangle vertex
  10758. * @param vertex2 triangle vertex
  10759. * @returns intersection information if hit
  10760. */
  10761. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10762. /**
  10763. * Checks if ray intersects a plane
  10764. * @param plane the plane to check
  10765. * @returns the distance away it was hit
  10766. */
  10767. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10768. /**
  10769. * Calculate the intercept of a ray on a given axis
  10770. * @param axis to check 'x' | 'y' | 'z'
  10771. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10772. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10773. */
  10774. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10775. /**
  10776. * Checks if ray intersects a mesh
  10777. * @param mesh the mesh to check
  10778. * @param fastCheck if only the bounding box should checked
  10779. * @returns picking info of the intersecton
  10780. */
  10781. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10782. /**
  10783. * Checks if ray intersects a mesh
  10784. * @param meshes the meshes to check
  10785. * @param fastCheck if only the bounding box should checked
  10786. * @param results array to store result in
  10787. * @returns Array of picking infos
  10788. */
  10789. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10790. private _comparePickingInfo;
  10791. private static smallnum;
  10792. private static rayl;
  10793. /**
  10794. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10795. * @param sega the first point of the segment to test the intersection against
  10796. * @param segb the second point of the segment to test the intersection against
  10797. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10798. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10799. */
  10800. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10801. /**
  10802. * Update the ray from viewport position
  10803. * @param x position
  10804. * @param y y position
  10805. * @param viewportWidth viewport width
  10806. * @param viewportHeight viewport height
  10807. * @param world world matrix
  10808. * @param view view matrix
  10809. * @param projection projection matrix
  10810. * @returns this ray updated
  10811. */
  10812. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10813. /**
  10814. * Creates a ray with origin and direction of 0,0,0
  10815. * @returns the new ray
  10816. */
  10817. static Zero(): Ray;
  10818. /**
  10819. * Creates a new ray from screen space and viewport
  10820. * @param x position
  10821. * @param y y position
  10822. * @param viewportWidth viewport width
  10823. * @param viewportHeight viewport height
  10824. * @param world world matrix
  10825. * @param view view matrix
  10826. * @param projection projection matrix
  10827. * @returns new ray
  10828. */
  10829. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10830. /**
  10831. * 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
  10832. * transformed to the given world matrix.
  10833. * @param origin The origin point
  10834. * @param end The end point
  10835. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10836. * @returns the new ray
  10837. */
  10838. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  10839. /**
  10840. * Transforms a ray by a matrix
  10841. * @param ray ray to transform
  10842. * @param matrix matrix to apply
  10843. * @returns the resulting new ray
  10844. */
  10845. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10846. /**
  10847. * Transforms a ray by a matrix
  10848. * @param ray ray to transform
  10849. * @param matrix matrix to apply
  10850. * @param result ray to store result in
  10851. */
  10852. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10853. /**
  10854. * Unproject a ray from screen space to object space
  10855. * @param sourceX defines the screen space x coordinate to use
  10856. * @param sourceY defines the screen space y coordinate to use
  10857. * @param viewportWidth defines the current width of the viewport
  10858. * @param viewportHeight defines the current height of the viewport
  10859. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10860. * @param view defines the view matrix to use
  10861. * @param projection defines the projection matrix to use
  10862. */
  10863. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10864. }
  10865. /**
  10866. * Type used to define predicate used to select faces when a mesh intersection is detected
  10867. */
  10868. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10869. interface Scene {
  10870. /** @hidden */ private _tempPickingRay: Nullable<Ray>;
  10871. /** @hidden */ private _cachedRayForTransform: Ray;
  10872. /** @hidden */ private _pickWithRayInverseMatrix: Matrix;
  10873. /** @hidden */ private _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10874. /** @hidden */ private _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10875. }
  10876. }
  10877. declare module BABYLON {
  10878. /**
  10879. * Groups all the scene component constants in one place to ease maintenance.
  10880. * @hidden
  10881. */
  10882. export class SceneComponentConstants {
  10883. static readonly NAME_EFFECTLAYER: string;
  10884. static readonly NAME_LAYER: string;
  10885. static readonly NAME_LENSFLARESYSTEM: string;
  10886. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10887. static readonly NAME_PARTICLESYSTEM: string;
  10888. static readonly NAME_GAMEPAD: string;
  10889. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10890. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10891. static readonly NAME_DEPTHRENDERER: string;
  10892. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10893. static readonly NAME_SPRITE: string;
  10894. static readonly NAME_OUTLINERENDERER: string;
  10895. static readonly NAME_PROCEDURALTEXTURE: string;
  10896. static readonly NAME_SHADOWGENERATOR: string;
  10897. static readonly NAME_OCTREE: string;
  10898. static readonly NAME_PHYSICSENGINE: string;
  10899. static readonly NAME_AUDIO: string;
  10900. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10901. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10902. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10903. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10904. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10905. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10906. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10907. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10908. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10909. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10910. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10911. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10912. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10913. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10914. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10915. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10917. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10918. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10919. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10920. static readonly STEP_AFTERRENDER_AUDIO: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10922. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10923. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10924. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10925. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10926. static readonly STEP_POINTERMOVE_SPRITE: number;
  10927. static readonly STEP_POINTERDOWN_SPRITE: number;
  10928. static readonly STEP_POINTERUP_SPRITE: number;
  10929. }
  10930. /**
  10931. * This represents a scene component.
  10932. *
  10933. * This is used to decouple the dependency the scene is having on the different workloads like
  10934. * layers, post processes...
  10935. */
  10936. export interface ISceneComponent {
  10937. /**
  10938. * The name of the component. Each component must have a unique name.
  10939. */
  10940. name: string;
  10941. /**
  10942. * The scene the component belongs to.
  10943. */
  10944. scene: Scene;
  10945. /**
  10946. * Register the component to one instance of a scene.
  10947. */
  10948. register(): void;
  10949. /**
  10950. * Rebuilds the elements related to this component in case of
  10951. * context lost for instance.
  10952. */
  10953. rebuild(): void;
  10954. /**
  10955. * Disposes the component and the associated ressources.
  10956. */
  10957. dispose(): void;
  10958. }
  10959. /**
  10960. * This represents a SERIALIZABLE scene component.
  10961. *
  10962. * This extends Scene Component to add Serialization methods on top.
  10963. */
  10964. export interface ISceneSerializableComponent extends ISceneComponent {
  10965. /**
  10966. * Adds all the elements from the container to the scene
  10967. * @param container the container holding the elements
  10968. */
  10969. addFromContainer(container: AbstractScene): void;
  10970. /**
  10971. * Removes all the elements in the container from the scene
  10972. * @param container contains the elements to remove
  10973. * @param dispose if the removed element should be disposed (default: false)
  10974. */
  10975. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10976. /**
  10977. * Serializes the component data to the specified json object
  10978. * @param serializationObject The object to serialize to
  10979. */
  10980. serialize(serializationObject: any): void;
  10981. }
  10982. /**
  10983. * Strong typing of a Mesh related stage step action
  10984. */
  10985. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10986. /**
  10987. * Strong typing of a Evaluate Sub Mesh related stage step action
  10988. */
  10989. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10990. /**
  10991. * Strong typing of a Active Mesh related stage step action
  10992. */
  10993. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10994. /**
  10995. * Strong typing of a Camera related stage step action
  10996. */
  10997. export type CameraStageAction = (camera: Camera) => void;
  10998. /**
  10999. * Strong typing of a Camera Frame buffer related stage step action
  11000. */
  11001. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11002. /**
  11003. * Strong typing of a Render Target related stage step action
  11004. */
  11005. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11006. /**
  11007. * Strong typing of a RenderingGroup related stage step action
  11008. */
  11009. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11010. /**
  11011. * Strong typing of a Mesh Render related stage step action
  11012. */
  11013. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11014. /**
  11015. * Strong typing of a simple stage step action
  11016. */
  11017. export type SimpleStageAction = () => void;
  11018. /**
  11019. * Strong typing of a render target action.
  11020. */
  11021. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11022. /**
  11023. * Strong typing of a pointer move action.
  11024. */
  11025. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11026. /**
  11027. * Strong typing of a pointer up/down action.
  11028. */
  11029. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11030. /**
  11031. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11032. * @hidden
  11033. */
  11034. export class Stage<T extends Function> extends Array<{
  11035. index: number;
  11036. component: ISceneComponent;
  11037. action: T;
  11038. }> {
  11039. /**
  11040. * Hide ctor from the rest of the world.
  11041. * @param items The items to add.
  11042. */
  11043. private constructor();
  11044. /**
  11045. * Creates a new Stage.
  11046. * @returns A new instance of a Stage
  11047. */
  11048. static Create<T extends Function>(): Stage<T>;
  11049. /**
  11050. * Registers a step in an ordered way in the targeted stage.
  11051. * @param index Defines the position to register the step in
  11052. * @param component Defines the component attached to the step
  11053. * @param action Defines the action to launch during the step
  11054. */
  11055. registerStep(index: number, component: ISceneComponent, action: T): void;
  11056. /**
  11057. * Clears all the steps from the stage.
  11058. */
  11059. clear(): void;
  11060. }
  11061. }
  11062. declare module BABYLON {
  11063. interface Scene {
  11064. /** @hidden */ private _pointerOverSprite: Nullable<Sprite>;
  11065. /** @hidden */ private _pickedDownSprite: Nullable<Sprite>;
  11066. /** @hidden */ private _tempSpritePickingRay: Nullable<Ray>;
  11067. /**
  11068. * All of the sprite managers added to this scene
  11069. * @see http://doc.babylonjs.com/babylon101/sprites
  11070. */
  11071. spriteManagers: Array<ISpriteManager>;
  11072. /**
  11073. * An event triggered when sprites rendering is about to start
  11074. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11075. */
  11076. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11077. /**
  11078. * An event triggered when sprites rendering is done
  11079. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11080. */
  11081. onAfterSpritesRenderingObservable: Observable<Scene>;
  11082. /** @hidden */ private _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11083. /** Launch a ray to try to pick a sprite in the scene
  11084. * @param x position on screen
  11085. * @param y position on screen
  11086. * @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
  11087. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11088. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11089. * @returns a PickingInfo
  11090. */
  11091. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11092. /** Use the given ray to pick a sprite in the scene
  11093. * @param ray The ray (in world space) to use to pick meshes
  11094. * @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
  11095. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11096. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11097. * @returns a PickingInfo
  11098. */
  11099. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11100. /**
  11101. * Force the sprite under the pointer
  11102. * @param sprite defines the sprite to use
  11103. */
  11104. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11105. /**
  11106. * Gets the sprite under the pointer
  11107. * @returns a Sprite or null if no sprite is under the pointer
  11108. */
  11109. getPointerOverSprite(): Nullable<Sprite>;
  11110. }
  11111. /**
  11112. * Defines the sprite scene component responsible to manage sprites
  11113. * in a given scene.
  11114. */
  11115. export class SpriteSceneComponent implements ISceneComponent {
  11116. /**
  11117. * The component name helpfull to identify the component in the list of scene components.
  11118. */
  11119. readonly name: string;
  11120. /**
  11121. * The scene the component belongs to.
  11122. */
  11123. scene: Scene;
  11124. /** @hidden */
  11125. private _spritePredicate;
  11126. /**
  11127. * Creates a new instance of the component for the given scene
  11128. * @param scene Defines the scene to register the component in
  11129. */
  11130. constructor(scene: Scene);
  11131. /**
  11132. * Registers the component in a given scene
  11133. */
  11134. register(): void;
  11135. /**
  11136. * Rebuilds the elements related to this component in case of
  11137. * context lost for instance.
  11138. */
  11139. rebuild(): void;
  11140. /**
  11141. * Disposes the component and the associated ressources.
  11142. */
  11143. dispose(): void;
  11144. private _pickSpriteButKeepRay;
  11145. private _pointerMove;
  11146. private _pointerDown;
  11147. private _pointerUp;
  11148. }
  11149. }
  11150. declare module BABYLON {
  11151. /** @hidden */
  11152. export var fogFragmentDeclaration: {
  11153. name: string;
  11154. shader: string;
  11155. };
  11156. }
  11157. declare module BABYLON {
  11158. /** @hidden */
  11159. export var fogFragment: {
  11160. name: string;
  11161. shader: string;
  11162. };
  11163. }
  11164. declare module BABYLON {
  11165. /** @hidden */
  11166. export var spritesPixelShader: {
  11167. name: string;
  11168. shader: string;
  11169. };
  11170. }
  11171. declare module BABYLON {
  11172. /** @hidden */
  11173. export var fogVertexDeclaration: {
  11174. name: string;
  11175. shader: string;
  11176. };
  11177. }
  11178. declare module BABYLON {
  11179. /** @hidden */
  11180. export var spritesVertexShader: {
  11181. name: string;
  11182. shader: string;
  11183. };
  11184. }
  11185. declare module BABYLON {
  11186. /**
  11187. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11188. */
  11189. export interface ISpriteManager extends IDisposable {
  11190. /**
  11191. * Restricts the camera to viewing objects with the same layerMask.
  11192. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11193. */
  11194. layerMask: number;
  11195. /**
  11196. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11197. */
  11198. isPickable: boolean;
  11199. /**
  11200. * Specifies the rendering group id for this mesh (0 by default)
  11201. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11202. */
  11203. renderingGroupId: number;
  11204. /**
  11205. * Defines the list of sprites managed by the manager.
  11206. */
  11207. sprites: Array<Sprite>;
  11208. /**
  11209. * Tests the intersection of a sprite with a specific ray.
  11210. * @param ray The ray we are sending to test the collision
  11211. * @param camera The camera space we are sending rays in
  11212. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11213. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11214. * @returns picking info or null.
  11215. */
  11216. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11217. /**
  11218. * Renders the list of sprites on screen.
  11219. */
  11220. render(): void;
  11221. }
  11222. /**
  11223. * Class used to manage multiple sprites on the same spritesheet
  11224. * @see http://doc.babylonjs.com/babylon101/sprites
  11225. */
  11226. export class SpriteManager implements ISpriteManager {
  11227. /** defines the manager's name */
  11228. name: string;
  11229. /** Gets the list of sprites */
  11230. sprites: Sprite[];
  11231. /** Gets or sets the rendering group id (0 by default) */
  11232. renderingGroupId: number;
  11233. /** Gets or sets camera layer mask */
  11234. layerMask: number;
  11235. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11236. fogEnabled: boolean;
  11237. /** Gets or sets a boolean indicating if the sprites are pickable */
  11238. isPickable: boolean;
  11239. /** Defines the default width of a cell in the spritesheet */
  11240. cellWidth: number;
  11241. /** Defines the default height of a cell in the spritesheet */
  11242. cellHeight: number;
  11243. /** Associative array from JSON sprite data file */
  11244. private _cellData;
  11245. /** Array of sprite names from JSON sprite data file */
  11246. private _spriteMap;
  11247. /** True when packed cell data from JSON file is ready*/
  11248. private _packedAndReady;
  11249. /**
  11250. * An event triggered when the manager is disposed.
  11251. */
  11252. onDisposeObservable: Observable<SpriteManager>;
  11253. private _onDisposeObserver;
  11254. /**
  11255. * Callback called when the manager is disposed
  11256. */
  11257. onDispose: () => void;
  11258. private _capacity;
  11259. private _fromPacked;
  11260. private _spriteTexture;
  11261. private _epsilon;
  11262. private _scene;
  11263. private _vertexData;
  11264. private _buffer;
  11265. private _vertexBuffers;
  11266. private _indexBuffer;
  11267. private _effectBase;
  11268. private _effectFog;
  11269. /**
  11270. * Gets or sets the spritesheet texture
  11271. */
  11272. texture: Texture;
  11273. /**
  11274. * Creates a new sprite manager
  11275. * @param name defines the manager's name
  11276. * @param imgUrl defines the sprite sheet url
  11277. * @param capacity defines the maximum allowed number of sprites
  11278. * @param cellSize defines the size of a sprite cell
  11279. * @param scene defines the hosting scene
  11280. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11281. * @param samplingMode defines the smapling mode to use with spritesheet
  11282. * @param fromPacked set to false; do not alter
  11283. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11284. */
  11285. constructor(
  11286. /** defines the manager's name */
  11287. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11288. private _makePacked;
  11289. private _appendSpriteVertex;
  11290. /**
  11291. * Intersects the sprites with a ray
  11292. * @param ray defines the ray to intersect with
  11293. * @param camera defines the current active camera
  11294. * @param predicate defines a predicate used to select candidate sprites
  11295. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11296. * @returns null if no hit or a PickingInfo
  11297. */
  11298. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11299. /**
  11300. * Render all child sprites
  11301. */
  11302. render(): void;
  11303. /**
  11304. * Release associated resources
  11305. */
  11306. dispose(): void;
  11307. }
  11308. }
  11309. declare module BABYLON {
  11310. /**
  11311. * Class used to represent a sprite
  11312. * @see http://doc.babylonjs.com/babylon101/sprites
  11313. */
  11314. export class Sprite {
  11315. /** defines the name */
  11316. name: string;
  11317. /** Gets or sets the current world position */
  11318. position: Vector3;
  11319. /** Gets or sets the main color */
  11320. color: Color4;
  11321. /** Gets or sets the width */
  11322. width: number;
  11323. /** Gets or sets the height */
  11324. height: number;
  11325. /** Gets or sets rotation angle */
  11326. angle: number;
  11327. /** Gets or sets the cell index in the sprite sheet */
  11328. cellIndex: number;
  11329. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11330. cellRef: string;
  11331. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11332. invertU: number;
  11333. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11334. invertV: number;
  11335. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11336. disposeWhenFinishedAnimating: boolean;
  11337. /** Gets the list of attached animations */
  11338. animations: Animation[];
  11339. /** Gets or sets a boolean indicating if the sprite can be picked */
  11340. isPickable: boolean;
  11341. /**
  11342. * Gets or sets the associated action manager
  11343. */
  11344. actionManager: Nullable<ActionManager>;
  11345. private _animationStarted;
  11346. private _loopAnimation;
  11347. private _fromIndex;
  11348. private _toIndex;
  11349. private _delay;
  11350. private _direction;
  11351. private _manager;
  11352. private _time;
  11353. private _onAnimationEnd;
  11354. /**
  11355. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11356. */
  11357. isVisible: boolean;
  11358. /**
  11359. * Gets or sets the sprite size
  11360. */
  11361. size: number;
  11362. /**
  11363. * Creates a new Sprite
  11364. * @param name defines the name
  11365. * @param manager defines the manager
  11366. */
  11367. constructor(
  11368. /** defines the name */
  11369. name: string, manager: ISpriteManager);
  11370. /**
  11371. * Starts an animation
  11372. * @param from defines the initial key
  11373. * @param to defines the end key
  11374. * @param loop defines if the animation must loop
  11375. * @param delay defines the start delay (in ms)
  11376. * @param onAnimationEnd defines a callback to call when animation ends
  11377. */
  11378. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11379. /** Stops current animation (if any) */
  11380. stopAnimation(): void;
  11381. /** @hidden */ private _animate(deltaTime: number): void;
  11382. /** Release associated resources */
  11383. dispose(): void;
  11384. }
  11385. }
  11386. declare module BABYLON {
  11387. /**
  11388. * Information about the result of picking within a scene
  11389. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11390. */
  11391. export class PickingInfo {
  11392. /** @hidden */ private _pickingUnavailable: boolean;
  11393. /**
  11394. * If the pick collided with an object
  11395. */
  11396. hit: boolean;
  11397. /**
  11398. * Distance away where the pick collided
  11399. */
  11400. distance: number;
  11401. /**
  11402. * The location of pick collision
  11403. */
  11404. pickedPoint: Nullable<Vector3>;
  11405. /**
  11406. * The mesh corresponding the the pick collision
  11407. */
  11408. pickedMesh: Nullable<AbstractMesh>;
  11409. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11410. bu: number;
  11411. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11412. bv: number;
  11413. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11414. faceId: number;
  11415. /** Id of the the submesh that was picked */
  11416. subMeshId: number;
  11417. /** If a sprite was picked, this will be the sprite the pick collided with */
  11418. pickedSprite: Nullable<Sprite>;
  11419. /**
  11420. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11421. */
  11422. originMesh: Nullable<AbstractMesh>;
  11423. /**
  11424. * The ray that was used to perform the picking.
  11425. */
  11426. ray: Nullable<Ray>;
  11427. /**
  11428. * Gets the normal correspodning to the face the pick collided with
  11429. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11430. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11431. * @returns The normal correspodning to the face the pick collided with
  11432. */
  11433. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  11434. /**
  11435. * Gets the texture coordinates of where the pick occured
  11436. * @returns the vector containing the coordnates of the texture
  11437. */
  11438. getTextureCoordinates(): Nullable<Vector2>;
  11439. }
  11440. }
  11441. declare module BABYLON {
  11442. /**
  11443. * Gather the list of pointer event types as constants.
  11444. */
  11445. export class PointerEventTypes {
  11446. /**
  11447. * 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.
  11448. */
  11449. static readonly POINTERDOWN: number;
  11450. /**
  11451. * The pointerup event is fired when a pointer is no longer active.
  11452. */
  11453. static readonly POINTERUP: number;
  11454. /**
  11455. * The pointermove event is fired when a pointer changes coordinates.
  11456. */
  11457. static readonly POINTERMOVE: number;
  11458. /**
  11459. * The pointerwheel event is fired when a mouse wheel has been rotated.
  11460. */
  11461. static readonly POINTERWHEEL: number;
  11462. /**
  11463. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  11464. */
  11465. static readonly POINTERPICK: number;
  11466. /**
  11467. * The pointertap event is fired when a the object has been touched and released without drag.
  11468. */
  11469. static readonly POINTERTAP: number;
  11470. /**
  11471. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  11472. */
  11473. static readonly POINTERDOUBLETAP: number;
  11474. }
  11475. /**
  11476. * Base class of pointer info types.
  11477. */
  11478. export class PointerInfoBase {
  11479. /**
  11480. * Defines the type of event (PointerEventTypes)
  11481. */
  11482. type: number;
  11483. /**
  11484. * Defines the related dom event
  11485. */
  11486. event: PointerEvent | MouseWheelEvent;
  11487. /**
  11488. * Instantiates the base class of pointers info.
  11489. * @param type Defines the type of event (PointerEventTypes)
  11490. * @param event Defines the related dom event
  11491. */
  11492. constructor(
  11493. /**
  11494. * Defines the type of event (PointerEventTypes)
  11495. */
  11496. type: number,
  11497. /**
  11498. * Defines the related dom event
  11499. */
  11500. event: PointerEvent | MouseWheelEvent);
  11501. }
  11502. /**
  11503. * This class is used to store pointer related info for the onPrePointerObservable event.
  11504. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  11505. */
  11506. export class PointerInfoPre extends PointerInfoBase {
  11507. /**
  11508. * Ray from a pointer if availible (eg. 6dof controller)
  11509. */
  11510. ray: Nullable<Ray>;
  11511. /**
  11512. * Defines the local position of the pointer on the canvas.
  11513. */
  11514. localPosition: Vector2;
  11515. /**
  11516. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  11517. */
  11518. skipOnPointerObservable: boolean;
  11519. /**
  11520. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  11521. * @param type Defines the type of event (PointerEventTypes)
  11522. * @param event Defines the related dom event
  11523. * @param localX Defines the local x coordinates of the pointer when the event occured
  11524. * @param localY Defines the local y coordinates of the pointer when the event occured
  11525. */
  11526. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  11527. }
  11528. /**
  11529. * This type contains all the data related to a pointer event in Babylon.js.
  11530. * 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.
  11531. */
  11532. export class PointerInfo extends PointerInfoBase {
  11533. /**
  11534. * Defines the picking info associated to the info (if any)\
  11535. */
  11536. pickInfo: Nullable<PickingInfo>;
  11537. /**
  11538. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  11539. * @param type Defines the type of event (PointerEventTypes)
  11540. * @param event Defines the related dom event
  11541. * @param pickInfo Defines the picking info associated to the info (if any)\
  11542. */
  11543. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  11544. /**
  11545. * Defines the picking info associated to the info (if any)\
  11546. */
  11547. pickInfo: Nullable<PickingInfo>);
  11548. }
  11549. /**
  11550. * Data relating to a touch event on the screen.
  11551. */
  11552. export interface PointerTouch {
  11553. /**
  11554. * X coordinate of touch.
  11555. */
  11556. x: number;
  11557. /**
  11558. * Y coordinate of touch.
  11559. */
  11560. y: number;
  11561. /**
  11562. * Id of touch. Unique for each finger.
  11563. */
  11564. pointerId: number;
  11565. /**
  11566. * Event type passed from DOM.
  11567. */
  11568. type: any;
  11569. }
  11570. }
  11571. declare module BABYLON {
  11572. /**
  11573. * Manage the mouse inputs to control the movement of a free camera.
  11574. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11575. */
  11576. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  11577. /**
  11578. * Define if touch is enabled in the mouse input
  11579. */
  11580. touchEnabled: boolean;
  11581. /**
  11582. * Defines the camera the input is attached to.
  11583. */
  11584. camera: FreeCamera;
  11585. /**
  11586. * Defines the buttons associated with the input to handle camera move.
  11587. */
  11588. buttons: number[];
  11589. /**
  11590. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  11591. */
  11592. angularSensibility: number;
  11593. private _pointerInput;
  11594. private _onMouseMove;
  11595. private _observer;
  11596. private previousPosition;
  11597. /**
  11598. * Observable for when a pointer move event occurs containing the move offset
  11599. */
  11600. onPointerMovedObservable: Observable<{
  11601. offsetX: number;
  11602. offsetY: number;
  11603. }>;
  11604. /**
  11605. * @hidden
  11606. * If the camera should be rotated automatically based on pointer movement
  11607. */ private _allowCameraRotation: boolean;
  11608. /**
  11609. * Manage the mouse inputs to control the movement of a free camera.
  11610. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11611. * @param touchEnabled Defines if touch is enabled or not
  11612. */
  11613. constructor(
  11614. /**
  11615. * Define if touch is enabled in the mouse input
  11616. */
  11617. touchEnabled?: boolean);
  11618. /**
  11619. * Attach the input controls to a specific dom element to get the input from.
  11620. * @param element Defines the element the controls should be listened from
  11621. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11622. */
  11623. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11624. /**
  11625. * Called on JS contextmenu event.
  11626. * Override this method to provide functionality.
  11627. */
  11628. protected onContextMenu(evt: PointerEvent): void;
  11629. /**
  11630. * Detach the current controls from the specified dom element.
  11631. * @param element Defines the element to stop listening the inputs from
  11632. */
  11633. detachControl(element: Nullable<HTMLElement>): void;
  11634. /**
  11635. * Gets the class name of the current intput.
  11636. * @returns the class name
  11637. */
  11638. getClassName(): string;
  11639. /**
  11640. * Get the friendly name associated with the input class.
  11641. * @returns the input friendly name
  11642. */
  11643. getSimpleName(): string;
  11644. }
  11645. }
  11646. declare module BABYLON {
  11647. /**
  11648. * Manage the touch inputs to control the movement of a free camera.
  11649. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11650. */
  11651. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  11652. /**
  11653. * Defines the camera the input is attached to.
  11654. */
  11655. camera: FreeCamera;
  11656. /**
  11657. * Defines the touch sensibility for rotation.
  11658. * The higher the faster.
  11659. */
  11660. touchAngularSensibility: number;
  11661. /**
  11662. * Defines the touch sensibility for move.
  11663. * The higher the faster.
  11664. */
  11665. touchMoveSensibility: number;
  11666. private _offsetX;
  11667. private _offsetY;
  11668. private _pointerPressed;
  11669. private _pointerInput;
  11670. private _observer;
  11671. private _onLostFocus;
  11672. /**
  11673. * Attach the input controls to a specific dom element to get the input from.
  11674. * @param element Defines the element the controls should be listened from
  11675. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11676. */
  11677. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11678. /**
  11679. * Detach the current controls from the specified dom element.
  11680. * @param element Defines the element to stop listening the inputs from
  11681. */
  11682. detachControl(element: Nullable<HTMLElement>): void;
  11683. /**
  11684. * Update the current camera state depending on the inputs that have been used this frame.
  11685. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  11686. */
  11687. checkInputs(): void;
  11688. /**
  11689. * Gets the class name of the current intput.
  11690. * @returns the class name
  11691. */
  11692. getClassName(): string;
  11693. /**
  11694. * Get the friendly name associated with the input class.
  11695. * @returns the input friendly name
  11696. */
  11697. getSimpleName(): string;
  11698. }
  11699. }
  11700. declare module BABYLON {
  11701. /**
  11702. * Default Inputs manager for the FreeCamera.
  11703. * It groups all the default supported inputs for ease of use.
  11704. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  11705. */
  11706. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  11707. /**
  11708. * @hidden
  11709. */ private _mouseInput: Nullable<FreeCameraMouseInput>;
  11710. /**
  11711. * Instantiates a new FreeCameraInputsManager.
  11712. * @param camera Defines the camera the inputs belong to
  11713. */
  11714. constructor(camera: FreeCamera);
  11715. /**
  11716. * Add keyboard input support to the input manager.
  11717. * @returns the current input manager
  11718. */
  11719. addKeyboard(): FreeCameraInputsManager;
  11720. /**
  11721. * Add mouse input support to the input manager.
  11722. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  11723. * @returns the current input manager
  11724. */
  11725. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  11726. /**
  11727. * Removes the mouse input support from the manager
  11728. * @returns the current input manager
  11729. */
  11730. removeMouse(): FreeCameraInputsManager;
  11731. /**
  11732. * Add touch input support to the input manager.
  11733. * @returns the current input manager
  11734. */
  11735. addTouch(): FreeCameraInputsManager;
  11736. /**
  11737. * Remove all attached input methods from a camera
  11738. */
  11739. clear(): void;
  11740. }
  11741. }
  11742. declare module BABYLON {
  11743. /**
  11744. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11745. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  11746. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11747. */
  11748. export class FreeCamera extends TargetCamera {
  11749. /**
  11750. * Define the collision ellipsoid of the camera.
  11751. * This is helpful to simulate a camera body like the player body around the camera
  11752. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  11753. */
  11754. ellipsoid: Vector3;
  11755. /**
  11756. * Define an offset for the position of the ellipsoid around the camera.
  11757. * This can be helpful to determine the center of the body near the gravity center of the body
  11758. * instead of its head.
  11759. */
  11760. ellipsoidOffset: Vector3;
  11761. /**
  11762. * Enable or disable collisions of the camera with the rest of the scene objects.
  11763. */
  11764. checkCollisions: boolean;
  11765. /**
  11766. * Enable or disable gravity on the camera.
  11767. */
  11768. applyGravity: boolean;
  11769. /**
  11770. * Define the input manager associated to the camera.
  11771. */
  11772. inputs: FreeCameraInputsManager;
  11773. /**
  11774. * Gets the input sensibility for a mouse input. (default is 2000.0)
  11775. * Higher values reduce sensitivity.
  11776. */
  11777. /**
  11778. * Sets the input sensibility for a mouse input. (default is 2000.0)
  11779. * Higher values reduce sensitivity.
  11780. */
  11781. angularSensibility: number;
  11782. /**
  11783. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  11784. */
  11785. keysUp: number[];
  11786. /**
  11787. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  11788. */
  11789. keysDown: number[];
  11790. /**
  11791. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  11792. */
  11793. keysLeft: number[];
  11794. /**
  11795. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  11796. */
  11797. keysRight: number[];
  11798. /**
  11799. * Event raised when the camera collide with a mesh in the scene.
  11800. */
  11801. onCollide: (collidedMesh: AbstractMesh) => void;
  11802. private _collider;
  11803. private _needMoveForGravity;
  11804. private _oldPosition;
  11805. private _diffPosition;
  11806. private _newPosition;
  11807. /** @hidden */ private _localDirection: Vector3;
  11808. /** @hidden */ private _transformedDirection: Vector3;
  11809. /**
  11810. * Instantiates a Free Camera.
  11811. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  11812. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  11813. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  11814. * @param name Define the name of the camera in the scene
  11815. * @param position Define the start position of the camera in the scene
  11816. * @param scene Define the scene the camera belongs to
  11817. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  11818. */
  11819. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  11820. /**
  11821. * Attached controls to the current camera.
  11822. * @param element Defines the element the controls should be listened from
  11823. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  11824. */
  11825. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  11826. /**
  11827. * Detach the current controls from the camera.
  11828. * The camera will stop reacting to inputs.
  11829. * @param element Defines the element to stop listening the inputs from
  11830. */
  11831. detachControl(element: HTMLElement): void;
  11832. private _collisionMask;
  11833. /**
  11834. * Define a collision mask to limit the list of object the camera can collide with
  11835. */
  11836. collisionMask: number;
  11837. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  11838. private _onCollisionPositionChange;
  11839. /** @hidden */ private _checkInputs(): void;
  11840. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  11841. /** @hidden */ private _updatePosition(): void;
  11842. /**
  11843. * Destroy the camera and release the current resources hold by it.
  11844. */
  11845. dispose(): void;
  11846. /**
  11847. * Gets the current object class name.
  11848. * @return the class name
  11849. */
  11850. getClassName(): string;
  11851. }
  11852. }
  11853. declare module BABYLON {
  11854. /**
  11855. * Represents a gamepad control stick position
  11856. */
  11857. export class StickValues {
  11858. /**
  11859. * The x component of the control stick
  11860. */
  11861. x: number;
  11862. /**
  11863. * The y component of the control stick
  11864. */
  11865. y: number;
  11866. /**
  11867. * Initializes the gamepad x and y control stick values
  11868. * @param x The x component of the gamepad control stick value
  11869. * @param y The y component of the gamepad control stick value
  11870. */
  11871. constructor(
  11872. /**
  11873. * The x component of the control stick
  11874. */
  11875. x: number,
  11876. /**
  11877. * The y component of the control stick
  11878. */
  11879. y: number);
  11880. }
  11881. /**
  11882. * An interface which manages callbacks for gamepad button changes
  11883. */
  11884. export interface GamepadButtonChanges {
  11885. /**
  11886. * Called when a gamepad has been changed
  11887. */
  11888. changed: boolean;
  11889. /**
  11890. * Called when a gamepad press event has been triggered
  11891. */
  11892. pressChanged: boolean;
  11893. /**
  11894. * Called when a touch event has been triggered
  11895. */
  11896. touchChanged: boolean;
  11897. /**
  11898. * Called when a value has changed
  11899. */
  11900. valueChanged: boolean;
  11901. }
  11902. /**
  11903. * Represents a gamepad
  11904. */
  11905. export class Gamepad {
  11906. /**
  11907. * The id of the gamepad
  11908. */
  11909. id: string;
  11910. /**
  11911. * The index of the gamepad
  11912. */
  11913. index: number;
  11914. /**
  11915. * The browser gamepad
  11916. */
  11917. browserGamepad: any;
  11918. /**
  11919. * Specifies what type of gamepad this represents
  11920. */
  11921. type: number;
  11922. private _leftStick;
  11923. private _rightStick;
  11924. /** @hidden */ private _isConnected: boolean;
  11925. private _leftStickAxisX;
  11926. private _leftStickAxisY;
  11927. private _rightStickAxisX;
  11928. private _rightStickAxisY;
  11929. /**
  11930. * Triggered when the left control stick has been changed
  11931. */
  11932. private _onleftstickchanged;
  11933. /**
  11934. * Triggered when the right control stick has been changed
  11935. */
  11936. private _onrightstickchanged;
  11937. /**
  11938. * Represents a gamepad controller
  11939. */
  11940. static GAMEPAD: number;
  11941. /**
  11942. * Represents a generic controller
  11943. */
  11944. static GENERIC: number;
  11945. /**
  11946. * Represents an XBox controller
  11947. */
  11948. static XBOX: number;
  11949. /**
  11950. * Represents a pose-enabled controller
  11951. */
  11952. static POSE_ENABLED: number;
  11953. /**
  11954. * Represents an Dual Shock controller
  11955. */
  11956. static DUALSHOCK: number;
  11957. /**
  11958. * Specifies whether the left control stick should be Y-inverted
  11959. */
  11960. protected _invertLeftStickY: boolean;
  11961. /**
  11962. * Specifies if the gamepad has been connected
  11963. */
  11964. readonly isConnected: boolean;
  11965. /**
  11966. * Initializes the gamepad
  11967. * @param id The id of the gamepad
  11968. * @param index The index of the gamepad
  11969. * @param browserGamepad The browser gamepad
  11970. * @param leftStickX The x component of the left joystick
  11971. * @param leftStickY The y component of the left joystick
  11972. * @param rightStickX The x component of the right joystick
  11973. * @param rightStickY The y component of the right joystick
  11974. */
  11975. constructor(
  11976. /**
  11977. * The id of the gamepad
  11978. */
  11979. id: string,
  11980. /**
  11981. * The index of the gamepad
  11982. */
  11983. index: number,
  11984. /**
  11985. * The browser gamepad
  11986. */
  11987. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  11988. /**
  11989. * Callback triggered when the left joystick has changed
  11990. * @param callback
  11991. */
  11992. onleftstickchanged(callback: (values: StickValues) => void): void;
  11993. /**
  11994. * Callback triggered when the right joystick has changed
  11995. * @param callback
  11996. */
  11997. onrightstickchanged(callback: (values: StickValues) => void): void;
  11998. /**
  11999. * Gets the left joystick
  12000. */
  12001. /**
  12002. * Sets the left joystick values
  12003. */
  12004. leftStick: StickValues;
  12005. /**
  12006. * Gets the right joystick
  12007. */
  12008. /**
  12009. * Sets the right joystick value
  12010. */
  12011. rightStick: StickValues;
  12012. /**
  12013. * Updates the gamepad joystick positions
  12014. */
  12015. update(): void;
  12016. /**
  12017. * Disposes the gamepad
  12018. */
  12019. dispose(): void;
  12020. }
  12021. /**
  12022. * Represents a generic gamepad
  12023. */
  12024. export class GenericPad extends Gamepad {
  12025. private _buttons;
  12026. private _onbuttondown;
  12027. private _onbuttonup;
  12028. /**
  12029. * Observable triggered when a button has been pressed
  12030. */
  12031. onButtonDownObservable: Observable<number>;
  12032. /**
  12033. * Observable triggered when a button has been released
  12034. */
  12035. onButtonUpObservable: Observable<number>;
  12036. /**
  12037. * Callback triggered when a button has been pressed
  12038. * @param callback Called when a button has been pressed
  12039. */
  12040. onbuttondown(callback: (buttonPressed: number) => void): void;
  12041. /**
  12042. * Callback triggered when a button has been released
  12043. * @param callback Called when a button has been released
  12044. */
  12045. onbuttonup(callback: (buttonReleased: number) => void): void;
  12046. /**
  12047. * Initializes the generic gamepad
  12048. * @param id The id of the generic gamepad
  12049. * @param index The index of the generic gamepad
  12050. * @param browserGamepad The browser gamepad
  12051. */
  12052. constructor(id: string, index: number, browserGamepad: any);
  12053. private _setButtonValue;
  12054. /**
  12055. * Updates the generic gamepad
  12056. */
  12057. update(): void;
  12058. /**
  12059. * Disposes the generic gamepad
  12060. */
  12061. dispose(): void;
  12062. }
  12063. }
  12064. declare module BABYLON {
  12065. interface Engine {
  12066. /**
  12067. * Creates a raw texture
  12068. * @param data defines the data to store in the texture
  12069. * @param width defines the width of the texture
  12070. * @param height defines the height of the texture
  12071. * @param format defines the format of the data
  12072. * @param generateMipMaps defines if the engine should generate the mip levels
  12073. * @param invertY defines if data must be stored with Y axis inverted
  12074. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12075. * @param compression defines the compression used (null by default)
  12076. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12077. * @returns the raw texture inside an InternalTexture
  12078. */
  12079. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12080. /**
  12081. * Update a raw texture
  12082. * @param texture defines the texture to update
  12083. * @param data defines the data to store in the texture
  12084. * @param format defines the format of the data
  12085. * @param invertY defines if data must be stored with Y axis inverted
  12086. */
  12087. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12088. /**
  12089. * Update a raw texture
  12090. * @param texture defines the texture to update
  12091. * @param data defines the data to store in the texture
  12092. * @param format defines the format of the data
  12093. * @param invertY defines if data must be stored with Y axis inverted
  12094. * @param compression defines the compression used (null by default)
  12095. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12096. */
  12097. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12098. /**
  12099. * Creates a new raw cube texture
  12100. * @param data defines the array of data to use to create each face
  12101. * @param size defines the size of the textures
  12102. * @param format defines the format of the data
  12103. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12104. * @param generateMipMaps defines if the engine should generate the mip levels
  12105. * @param invertY defines if data must be stored with Y axis inverted
  12106. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12107. * @param compression defines the compression used (null by default)
  12108. * @returns the cube texture as an InternalTexture
  12109. */
  12110. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12111. /**
  12112. * Update a raw cube texture
  12113. * @param texture defines the texture to udpdate
  12114. * @param data defines the data to store
  12115. * @param format defines the data format
  12116. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12117. * @param invertY defines if data must be stored with Y axis inverted
  12118. */
  12119. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12120. /**
  12121. * Update a raw cube texture
  12122. * @param texture defines the texture to udpdate
  12123. * @param data defines the data to store
  12124. * @param format defines the data format
  12125. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12126. * @param invertY defines if data must be stored with Y axis inverted
  12127. * @param compression defines the compression used (null by default)
  12128. */
  12129. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12130. /**
  12131. * Update a raw cube texture
  12132. * @param texture defines the texture to udpdate
  12133. * @param data defines the data to store
  12134. * @param format defines the data format
  12135. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12136. * @param invertY defines if data must be stored with Y axis inverted
  12137. * @param compression defines the compression used (null by default)
  12138. * @param level defines which level of the texture to update
  12139. */
  12140. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12141. /**
  12142. * Creates a new raw cube texture from a specified url
  12143. * @param url defines the url where the data is located
  12144. * @param scene defines the current scene
  12145. * @param size defines the size of the textures
  12146. * @param format defines the format of the data
  12147. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12148. * @param noMipmap defines if the engine should avoid generating the mip levels
  12149. * @param callback defines a callback used to extract texture data from loaded data
  12150. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12151. * @param onLoad defines a callback called when texture is loaded
  12152. * @param onError defines a callback called if there is an error
  12153. * @returns the cube texture as an InternalTexture
  12154. */
  12155. 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;
  12156. /**
  12157. * Creates a new raw cube texture from a specified url
  12158. * @param url defines the url where the data is located
  12159. * @param scene defines the current scene
  12160. * @param size defines the size of the textures
  12161. * @param format defines the format of the data
  12162. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12163. * @param noMipmap defines if the engine should avoid generating the mip levels
  12164. * @param callback defines a callback used to extract texture data from loaded data
  12165. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12166. * @param onLoad defines a callback called when texture is loaded
  12167. * @param onError defines a callback called if there is an error
  12168. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12169. * @param invertY defines if data must be stored with Y axis inverted
  12170. * @returns the cube texture as an InternalTexture
  12171. */
  12172. 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;
  12173. /**
  12174. * Creates a new raw 3D texture
  12175. * @param data defines the data used to create the texture
  12176. * @param width defines the width of the texture
  12177. * @param height defines the height of the texture
  12178. * @param depth defines the depth of the texture
  12179. * @param format defines the format of the texture
  12180. * @param generateMipMaps defines if the engine must generate mip levels
  12181. * @param invertY defines if data must be stored with Y axis inverted
  12182. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12183. * @param compression defines the compressed used (can be null)
  12184. * @param textureType defines the compressed used (can be null)
  12185. * @returns a new raw 3D texture (stored in an InternalTexture)
  12186. */
  12187. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12188. /**
  12189. * Update a raw 3D texture
  12190. * @param texture defines the texture to update
  12191. * @param data defines the data to store
  12192. * @param format defines the data format
  12193. * @param invertY defines if data must be stored with Y axis inverted
  12194. */
  12195. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12196. /**
  12197. * Update a raw 3D texture
  12198. * @param texture defines the texture to update
  12199. * @param data defines the data to store
  12200. * @param format defines the data format
  12201. * @param invertY defines if data must be stored with Y axis inverted
  12202. * @param compression defines the used compression (can be null)
  12203. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12204. */
  12205. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12206. }
  12207. }
  12208. declare module BABYLON {
  12209. /**
  12210. * Raw texture can help creating a texture directly from an array of data.
  12211. * This can be super useful if you either get the data from an uncompressed source or
  12212. * if you wish to create your texture pixel by pixel.
  12213. */
  12214. export class RawTexture extends Texture {
  12215. /**
  12216. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12217. */
  12218. format: number;
  12219. private _engine;
  12220. /**
  12221. * Instantiates a new RawTexture.
  12222. * Raw texture can help creating a texture directly from an array of data.
  12223. * This can be super useful if you either get the data from an uncompressed source or
  12224. * if you wish to create your texture pixel by pixel.
  12225. * @param data define the array of data to use to create the texture
  12226. * @param width define the width of the texture
  12227. * @param height define the height of the texture
  12228. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12229. * @param scene define the scene the texture belongs to
  12230. * @param generateMipMaps define whether mip maps should be generated or not
  12231. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12232. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12233. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12234. */
  12235. constructor(data: ArrayBufferView, width: number, height: number,
  12236. /**
  12237. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12238. */
  12239. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12240. /**
  12241. * Updates the texture underlying data.
  12242. * @param data Define the new data of the texture
  12243. */
  12244. update(data: ArrayBufferView): void;
  12245. /**
  12246. * Creates a luminance texture from some data.
  12247. * @param data Define the texture data
  12248. * @param width Define the width of the texture
  12249. * @param height Define the height of the texture
  12250. * @param scene Define the scene the texture belongs to
  12251. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12252. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12253. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12254. * @returns the luminance texture
  12255. */
  12256. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12257. /**
  12258. * Creates a luminance alpha texture from some data.
  12259. * @param data Define the texture data
  12260. * @param width Define the width of the texture
  12261. * @param height Define the height of the texture
  12262. * @param scene Define the scene the texture belongs to
  12263. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12264. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12265. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12266. * @returns the luminance alpha texture
  12267. */
  12268. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12269. /**
  12270. * Creates an alpha texture from some data.
  12271. * @param data Define the texture data
  12272. * @param width Define the width of the texture
  12273. * @param height Define the height of the texture
  12274. * @param scene Define the scene the texture belongs to
  12275. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12276. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12277. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12278. * @returns the alpha texture
  12279. */
  12280. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12281. /**
  12282. * Creates a RGB texture from some data.
  12283. * @param data Define the texture data
  12284. * @param width Define the width of the texture
  12285. * @param height Define the height of the texture
  12286. * @param scene Define the scene the texture belongs to
  12287. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12288. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12289. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12290. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12291. * @returns the RGB alpha texture
  12292. */
  12293. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12294. /**
  12295. * Creates a RGBA texture from some data.
  12296. * @param data Define the texture data
  12297. * @param width Define the width of the texture
  12298. * @param height Define the height of the texture
  12299. * @param scene Define the scene the texture belongs to
  12300. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12301. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12302. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12303. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12304. * @returns the RGBA texture
  12305. */
  12306. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12307. /**
  12308. * Creates a R texture from some data.
  12309. * @param data Define the texture data
  12310. * @param width Define the width of the texture
  12311. * @param height Define the height of the texture
  12312. * @param scene Define the scene the texture belongs to
  12313. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12314. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12315. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12316. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12317. * @returns the R texture
  12318. */
  12319. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12320. }
  12321. }
  12322. declare module BABYLON {
  12323. /**
  12324. * Interface for the size containing width and height
  12325. */
  12326. export interface ISize {
  12327. /**
  12328. * Width
  12329. */
  12330. width: number;
  12331. /**
  12332. * Heighht
  12333. */
  12334. height: number;
  12335. }
  12336. /**
  12337. * Size containing widht and height
  12338. */
  12339. export class Size implements ISize {
  12340. /**
  12341. * Width
  12342. */
  12343. width: number;
  12344. /**
  12345. * Height
  12346. */
  12347. height: number;
  12348. /**
  12349. * Creates a Size object from the given width and height (floats).
  12350. * @param width width of the new size
  12351. * @param height height of the new size
  12352. */
  12353. constructor(width: number, height: number);
  12354. /**
  12355. * Returns a string with the Size width and height
  12356. * @returns a string with the Size width and height
  12357. */
  12358. toString(): string;
  12359. /**
  12360. * "Size"
  12361. * @returns the string "Size"
  12362. */
  12363. getClassName(): string;
  12364. /**
  12365. * Returns the Size hash code.
  12366. * @returns a hash code for a unique width and height
  12367. */
  12368. getHashCode(): number;
  12369. /**
  12370. * Updates the current size from the given one.
  12371. * @param src the given size
  12372. */
  12373. copyFrom(src: Size): void;
  12374. /**
  12375. * Updates in place the current Size from the given floats.
  12376. * @param width width of the new size
  12377. * @param height height of the new size
  12378. * @returns the updated Size.
  12379. */
  12380. copyFromFloats(width: number, height: number): Size;
  12381. /**
  12382. * Updates in place the current Size from the given floats.
  12383. * @param width width to set
  12384. * @param height height to set
  12385. * @returns the updated Size.
  12386. */
  12387. set(width: number, height: number): Size;
  12388. /**
  12389. * Multiplies the width and height by numbers
  12390. * @param w factor to multiple the width by
  12391. * @param h factor to multiple the height by
  12392. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12393. */
  12394. multiplyByFloats(w: number, h: number): Size;
  12395. /**
  12396. * Clones the size
  12397. * @returns a new Size copied from the given one.
  12398. */
  12399. clone(): Size;
  12400. /**
  12401. * True if the current Size and the given one width and height are strictly equal.
  12402. * @param other the other size to compare against
  12403. * @returns True if the current Size and the given one width and height are strictly equal.
  12404. */
  12405. equals(other: Size): boolean;
  12406. /**
  12407. * The surface of the Size : width * height (float).
  12408. */
  12409. readonly surface: number;
  12410. /**
  12411. * Create a new size of zero
  12412. * @returns a new Size set to (0.0, 0.0)
  12413. */
  12414. static Zero(): Size;
  12415. /**
  12416. * Sums the width and height of two sizes
  12417. * @param otherSize size to add to this size
  12418. * @returns a new Size set as the addition result of the current Size and the given one.
  12419. */
  12420. add(otherSize: Size): Size;
  12421. /**
  12422. * Subtracts the width and height of two
  12423. * @param otherSize size to subtract to this size
  12424. * @returns a new Size set as the subtraction result of the given one from the current Size.
  12425. */
  12426. subtract(otherSize: Size): Size;
  12427. /**
  12428. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  12429. * @param start starting size to lerp between
  12430. * @param end end size to lerp between
  12431. * @param amount amount to lerp between the start and end values
  12432. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  12433. */
  12434. static Lerp(start: Size, end: Size, amount: number): Size;
  12435. }
  12436. }
  12437. declare module BABYLON {
  12438. /**
  12439. * Defines a runtime animation
  12440. */
  12441. export class RuntimeAnimation {
  12442. private _events;
  12443. /**
  12444. * The current frame of the runtime animation
  12445. */
  12446. private _currentFrame;
  12447. /**
  12448. * The animation used by the runtime animation
  12449. */
  12450. private _animation;
  12451. /**
  12452. * The target of the runtime animation
  12453. */
  12454. private _target;
  12455. /**
  12456. * The initiating animatable
  12457. */
  12458. private _host;
  12459. /**
  12460. * The original value of the runtime animation
  12461. */
  12462. private _originalValue;
  12463. /**
  12464. * The original blend value of the runtime animation
  12465. */
  12466. private _originalBlendValue;
  12467. /**
  12468. * The offsets cache of the runtime animation
  12469. */
  12470. private _offsetsCache;
  12471. /**
  12472. * The high limits cache of the runtime animation
  12473. */
  12474. private _highLimitsCache;
  12475. /**
  12476. * Specifies if the runtime animation has been stopped
  12477. */
  12478. private _stopped;
  12479. /**
  12480. * The blending factor of the runtime animation
  12481. */
  12482. private _blendingFactor;
  12483. /**
  12484. * The BabylonJS scene
  12485. */
  12486. private _scene;
  12487. /**
  12488. * The current value of the runtime animation
  12489. */
  12490. private _currentValue;
  12491. /** @hidden */ private _animationState: _IAnimationState;
  12492. /**
  12493. * The active target of the runtime animation
  12494. */
  12495. private _activeTargets;
  12496. private _currentActiveTarget;
  12497. private _directTarget;
  12498. /**
  12499. * The target path of the runtime animation
  12500. */
  12501. private _targetPath;
  12502. /**
  12503. * The weight of the runtime animation
  12504. */
  12505. private _weight;
  12506. /**
  12507. * The ratio offset of the runtime animation
  12508. */
  12509. private _ratioOffset;
  12510. /**
  12511. * The previous delay of the runtime animation
  12512. */
  12513. private _previousDelay;
  12514. /**
  12515. * The previous ratio of the runtime animation
  12516. */
  12517. private _previousRatio;
  12518. private _enableBlending;
  12519. private _keys;
  12520. private _minFrame;
  12521. private _maxFrame;
  12522. private _minValue;
  12523. private _maxValue;
  12524. private _targetIsArray;
  12525. /**
  12526. * Gets the current frame of the runtime animation
  12527. */
  12528. readonly currentFrame: number;
  12529. /**
  12530. * Gets the weight of the runtime animation
  12531. */
  12532. readonly weight: number;
  12533. /**
  12534. * Gets the current value of the runtime animation
  12535. */
  12536. readonly currentValue: any;
  12537. /**
  12538. * Gets the target path of the runtime animation
  12539. */
  12540. readonly targetPath: string;
  12541. /**
  12542. * Gets the actual target of the runtime animation
  12543. */
  12544. readonly target: any;
  12545. /** @hidden */ private _onLoop: () => void;
  12546. /**
  12547. * Create a new RuntimeAnimation object
  12548. * @param target defines the target of the animation
  12549. * @param animation defines the source animation object
  12550. * @param scene defines the hosting scene
  12551. * @param host defines the initiating Animatable
  12552. */
  12553. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  12554. private _preparePath;
  12555. /**
  12556. * Gets the animation from the runtime animation
  12557. */
  12558. readonly animation: Animation;
  12559. /**
  12560. * Resets the runtime animation to the beginning
  12561. * @param restoreOriginal defines whether to restore the target property to the original value
  12562. */
  12563. reset(restoreOriginal?: boolean): void;
  12564. /**
  12565. * Specifies if the runtime animation is stopped
  12566. * @returns Boolean specifying if the runtime animation is stopped
  12567. */
  12568. isStopped(): boolean;
  12569. /**
  12570. * Disposes of the runtime animation
  12571. */
  12572. dispose(): void;
  12573. /**
  12574. * Apply the interpolated value to the target
  12575. * @param currentValue defines the value computed by the animation
  12576. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  12577. */
  12578. setValue(currentValue: any, weight: number): void;
  12579. private _getOriginalValues;
  12580. private _setValue;
  12581. /**
  12582. * Gets the loop pmode of the runtime animation
  12583. * @returns Loop Mode
  12584. */
  12585. private _getCorrectLoopMode;
  12586. /**
  12587. * Move the current animation to a given frame
  12588. * @param frame defines the frame to move to
  12589. */
  12590. goToFrame(frame: number): void;
  12591. /**
  12592. * @hidden Internal use only
  12593. */ private _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  12594. /**
  12595. * Execute the current animation
  12596. * @param delay defines the delay to add to the current frame
  12597. * @param from defines the lower bound of the animation range
  12598. * @param to defines the upper bound of the animation range
  12599. * @param loop defines if the current animation must loop
  12600. * @param speedRatio defines the current speed ratio
  12601. * @param weight defines the weight of the animation (default is -1 so no weight)
  12602. * @param onLoop optional callback called when animation loops
  12603. * @returns a boolean indicating if the animation is running
  12604. */
  12605. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  12606. }
  12607. }
  12608. declare module BABYLON {
  12609. /**
  12610. * Class used to store an actual running animation
  12611. */
  12612. export class Animatable {
  12613. /** defines the target object */
  12614. target: any;
  12615. /** defines the starting frame number (default is 0) */
  12616. fromFrame: number;
  12617. /** defines the ending frame number (default is 100) */
  12618. toFrame: number;
  12619. /** defines if the animation must loop (default is false) */
  12620. loopAnimation: boolean;
  12621. /** defines a callback to call when animation ends if it is not looping */
  12622. onAnimationEnd?: (() => void) | null | undefined;
  12623. /** defines a callback to call when animation loops */
  12624. onAnimationLoop?: (() => void) | null | undefined;
  12625. private _localDelayOffset;
  12626. private _pausedDelay;
  12627. private _runtimeAnimations;
  12628. private _paused;
  12629. private _scene;
  12630. private _speedRatio;
  12631. private _weight;
  12632. private _syncRoot;
  12633. /**
  12634. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  12635. * This will only apply for non looping animation (default is true)
  12636. */
  12637. disposeOnEnd: boolean;
  12638. /**
  12639. * Gets a boolean indicating if the animation has started
  12640. */
  12641. animationStarted: boolean;
  12642. /**
  12643. * Observer raised when the animation ends
  12644. */
  12645. onAnimationEndObservable: Observable<Animatable>;
  12646. /**
  12647. * Observer raised when the animation loops
  12648. */
  12649. onAnimationLoopObservable: Observable<Animatable>;
  12650. /**
  12651. * Gets the root Animatable used to synchronize and normalize animations
  12652. */
  12653. readonly syncRoot: Nullable<Animatable>;
  12654. /**
  12655. * Gets the current frame of the first RuntimeAnimation
  12656. * Used to synchronize Animatables
  12657. */
  12658. readonly masterFrame: number;
  12659. /**
  12660. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  12661. */
  12662. weight: number;
  12663. /**
  12664. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  12665. */
  12666. speedRatio: number;
  12667. /**
  12668. * Creates a new Animatable
  12669. * @param scene defines the hosting scene
  12670. * @param target defines the target object
  12671. * @param fromFrame defines the starting frame number (default is 0)
  12672. * @param toFrame defines the ending frame number (default is 100)
  12673. * @param loopAnimation defines if the animation must loop (default is false)
  12674. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  12675. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  12676. * @param animations defines a group of animation to add to the new Animatable
  12677. * @param onAnimationLoop defines a callback to call when animation loops
  12678. */
  12679. constructor(scene: Scene,
  12680. /** defines the target object */
  12681. target: any,
  12682. /** defines the starting frame number (default is 0) */
  12683. fromFrame?: number,
  12684. /** defines the ending frame number (default is 100) */
  12685. toFrame?: number,
  12686. /** defines if the animation must loop (default is false) */
  12687. loopAnimation?: boolean, speedRatio?: number,
  12688. /** defines a callback to call when animation ends if it is not looping */
  12689. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  12690. /** defines a callback to call when animation loops */
  12691. onAnimationLoop?: (() => void) | null | undefined);
  12692. /**
  12693. * Synchronize and normalize current Animatable with a source Animatable
  12694. * This is useful when using animation weights and when animations are not of the same length
  12695. * @param root defines the root Animatable to synchronize with
  12696. * @returns the current Animatable
  12697. */
  12698. syncWith(root: Animatable): Animatable;
  12699. /**
  12700. * Gets the list of runtime animations
  12701. * @returns an array of RuntimeAnimation
  12702. */
  12703. getAnimations(): RuntimeAnimation[];
  12704. /**
  12705. * Adds more animations to the current animatable
  12706. * @param target defines the target of the animations
  12707. * @param animations defines the new animations to add
  12708. */
  12709. appendAnimations(target: any, animations: Animation[]): void;
  12710. /**
  12711. * Gets the source animation for a specific property
  12712. * @param property defines the propertyu to look for
  12713. * @returns null or the source animation for the given property
  12714. */
  12715. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  12716. /**
  12717. * Gets the runtime animation for a specific property
  12718. * @param property defines the propertyu to look for
  12719. * @returns null or the runtime animation for the given property
  12720. */
  12721. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  12722. /**
  12723. * Resets the animatable to its original state
  12724. */
  12725. reset(): void;
  12726. /**
  12727. * Allows the animatable to blend with current running animations
  12728. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12729. * @param blendingSpeed defines the blending speed to use
  12730. */
  12731. enableBlending(blendingSpeed: number): void;
  12732. /**
  12733. * Disable animation blending
  12734. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  12735. */
  12736. disableBlending(): void;
  12737. /**
  12738. * Jump directly to a given frame
  12739. * @param frame defines the frame to jump to
  12740. */
  12741. goToFrame(frame: number): void;
  12742. /**
  12743. * Pause the animation
  12744. */
  12745. pause(): void;
  12746. /**
  12747. * Restart the animation
  12748. */
  12749. restart(): void;
  12750. private _raiseOnAnimationEnd;
  12751. /**
  12752. * Stop and delete the current animation
  12753. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  12754. * @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)
  12755. */
  12756. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  12757. /**
  12758. * Wait asynchronously for the animation to end
  12759. * @returns a promise which will be fullfilled when the animation ends
  12760. */
  12761. waitAsync(): Promise<Animatable>;
  12762. /** @hidden */ private _animate(delay: number): boolean;
  12763. }
  12764. interface Scene {
  12765. /** @hidden */ private _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  12766. /** @hidden */ private _processLateAnimationBindingsForMatrices(holder: {
  12767. totalWeight: number;
  12768. animations: RuntimeAnimation[];
  12769. originalValue: Matrix;
  12770. }): any;
  12771. /** @hidden */ private _processLateAnimationBindingsForQuaternions(holder: {
  12772. totalWeight: number;
  12773. animations: RuntimeAnimation[];
  12774. originalValue: Quaternion;
  12775. }, refQuaternion: Quaternion): Quaternion;
  12776. /** @hidden */ private _processLateAnimationBindings(): void;
  12777. /**
  12778. * Will start the animation sequence of a given target
  12779. * @param target defines the target
  12780. * @param from defines from which frame should animation start
  12781. * @param to defines until which frame should animation run.
  12782. * @param weight defines the weight to apply to the animation (1.0 by default)
  12783. * @param loop defines if the animation loops
  12784. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12785. * @param onAnimationEnd defines the function to be executed when the animation ends
  12786. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12787. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12788. * @param onAnimationLoop defines the callback to call when an animation loops
  12789. * @returns the animatable object created for this animation
  12790. */
  12791. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12792. /**
  12793. * Will start the animation sequence of a given target
  12794. * @param target defines the target
  12795. * @param from defines from which frame should animation start
  12796. * @param to defines until which frame should animation run.
  12797. * @param loop defines if the animation loops
  12798. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12799. * @param onAnimationEnd defines the function to be executed when the animation ends
  12800. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12801. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12802. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  12803. * @param onAnimationLoop defines the callback to call when an animation loops
  12804. * @returns the animatable object created for this animation
  12805. */
  12806. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  12807. /**
  12808. * Will start the animation sequence of a given target and its hierarchy
  12809. * @param target defines the target
  12810. * @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.
  12811. * @param from defines from which frame should animation start
  12812. * @param to defines until which frame should animation run.
  12813. * @param loop defines if the animation loops
  12814. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  12815. * @param onAnimationEnd defines the function to be executed when the animation ends
  12816. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  12817. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  12818. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  12819. * @param onAnimationLoop defines the callback to call when an animation loops
  12820. * @returns the list of created animatables
  12821. */
  12822. 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[];
  12823. /**
  12824. * Begin a new animation on a given node
  12825. * @param target defines the target where the animation will take place
  12826. * @param animations defines the list of animations to start
  12827. * @param from defines the initial value
  12828. * @param to defines the final value
  12829. * @param loop defines if you want animation to loop (off by default)
  12830. * @param speedRatio defines the speed ratio to apply to all animations
  12831. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12832. * @param onAnimationLoop defines the callback to call when an animation loops
  12833. * @returns the list of created animatables
  12834. */
  12835. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  12836. /**
  12837. * Begin a new animation on a given node and its hierarchy
  12838. * @param target defines the root node where the animation will take place
  12839. * @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.
  12840. * @param animations defines the list of animations to start
  12841. * @param from defines the initial value
  12842. * @param to defines the final value
  12843. * @param loop defines if you want animation to loop (off by default)
  12844. * @param speedRatio defines the speed ratio to apply to all animations
  12845. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  12846. * @param onAnimationLoop defines the callback to call when an animation loops
  12847. * @returns the list of animatables created for all nodes
  12848. */
  12849. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  12850. /**
  12851. * Gets the animatable associated with a specific target
  12852. * @param target defines the target of the animatable
  12853. * @returns the required animatable if found
  12854. */
  12855. getAnimatableByTarget(target: any): Nullable<Animatable>;
  12856. /**
  12857. * Gets all animatables associated with a given target
  12858. * @param target defines the target to look animatables for
  12859. * @returns an array of Animatables
  12860. */
  12861. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  12862. /**
  12863. * Stops and removes all animations that have been applied to the scene
  12864. */
  12865. stopAllAnimations(): void;
  12866. }
  12867. interface Bone {
  12868. /**
  12869. * Copy an animation range from another bone
  12870. * @param source defines the source bone
  12871. * @param rangeName defines the range name to copy
  12872. * @param frameOffset defines the frame offset
  12873. * @param rescaleAsRequired defines if rescaling must be applied if required
  12874. * @param skelDimensionsRatio defines the scaling ratio
  12875. * @returns true if operation was successful
  12876. */
  12877. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  12878. }
  12879. }
  12880. declare module BABYLON {
  12881. /**
  12882. * Class used to override all child animations of a given target
  12883. */
  12884. export class AnimationPropertiesOverride {
  12885. /**
  12886. * Gets or sets a value indicating if animation blending must be used
  12887. */
  12888. enableBlending: boolean;
  12889. /**
  12890. * Gets or sets the blending speed to use when enableBlending is true
  12891. */
  12892. blendingSpeed: number;
  12893. /**
  12894. * Gets or sets the default loop mode to use
  12895. */
  12896. loopMode: number;
  12897. }
  12898. }
  12899. declare module BABYLON {
  12900. /**
  12901. * Class used to handle skinning animations
  12902. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  12903. */
  12904. export class Skeleton implements IAnimatable {
  12905. /** defines the skeleton name */
  12906. name: string;
  12907. /** defines the skeleton Id */
  12908. id: string;
  12909. /**
  12910. * Defines the list of child bones
  12911. */
  12912. bones: Bone[];
  12913. /**
  12914. * Defines an estimate of the dimension of the skeleton at rest
  12915. */
  12916. dimensionsAtRest: Vector3;
  12917. /**
  12918. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  12919. */
  12920. needInitialSkinMatrix: boolean;
  12921. /**
  12922. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  12923. */
  12924. overrideMesh: Nullable<AbstractMesh>;
  12925. /**
  12926. * Gets the list of animations attached to this skeleton
  12927. */
  12928. animations: Array<Animation>;
  12929. private _scene;
  12930. private _isDirty;
  12931. private _transformMatrices;
  12932. private _transformMatrixTexture;
  12933. private _meshesWithPoseMatrix;
  12934. private _animatables;
  12935. private _identity;
  12936. private _synchronizedWithMesh;
  12937. private _ranges;
  12938. private _lastAbsoluteTransformsUpdateId;
  12939. private _canUseTextureForBones;
  12940. private _uniqueId;
  12941. /** @hidden */ private _numBonesWithLinkedTransformNode: number;
  12942. /** @hidden */ private _hasWaitingData: Nullable<boolean>;
  12943. /**
  12944. * Specifies if the skeleton should be serialized
  12945. */
  12946. doNotSerialize: boolean;
  12947. private _useTextureToStoreBoneMatrices;
  12948. /**
  12949. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  12950. * Please note that this option is not available if the hardware does not support it
  12951. */
  12952. useTextureToStoreBoneMatrices: boolean;
  12953. private _animationPropertiesOverride;
  12954. /**
  12955. * Gets or sets the animation properties override
  12956. */
  12957. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  12958. /**
  12959. * List of inspectable custom properties (used by the Inspector)
  12960. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  12961. */
  12962. inspectableCustomProperties: IInspectable[];
  12963. /**
  12964. * An observable triggered before computing the skeleton's matrices
  12965. */
  12966. onBeforeComputeObservable: Observable<Skeleton>;
  12967. /**
  12968. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  12969. */
  12970. readonly isUsingTextureForMatrices: boolean;
  12971. /**
  12972. * Gets the unique ID of this skeleton
  12973. */
  12974. readonly uniqueId: number;
  12975. /**
  12976. * Creates a new skeleton
  12977. * @param name defines the skeleton name
  12978. * @param id defines the skeleton Id
  12979. * @param scene defines the hosting scene
  12980. */
  12981. constructor(
  12982. /** defines the skeleton name */
  12983. name: string,
  12984. /** defines the skeleton Id */
  12985. id: string, scene: Scene);
  12986. /**
  12987. * Gets the current object class name.
  12988. * @return the class name
  12989. */
  12990. getClassName(): string;
  12991. /**
  12992. * Returns an array containing the root bones
  12993. * @returns an array containing the root bones
  12994. */
  12995. getChildren(): Array<Bone>;
  12996. /**
  12997. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  12998. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  12999. * @returns a Float32Array containing matrices data
  13000. */
  13001. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13002. /**
  13003. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13004. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13005. * @returns a raw texture containing the data
  13006. */
  13007. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13008. /**
  13009. * Gets the current hosting scene
  13010. * @returns a scene object
  13011. */
  13012. getScene(): Scene;
  13013. /**
  13014. * Gets a string representing the current skeleton data
  13015. * @param fullDetails defines a boolean indicating if we want a verbose version
  13016. * @returns a string representing the current skeleton data
  13017. */
  13018. toString(fullDetails?: boolean): string;
  13019. /**
  13020. * Get bone's index searching by name
  13021. * @param name defines bone's name to search for
  13022. * @return the indice of the bone. Returns -1 if not found
  13023. */
  13024. getBoneIndexByName(name: string): number;
  13025. /**
  13026. * Creater a new animation range
  13027. * @param name defines the name of the range
  13028. * @param from defines the start key
  13029. * @param to defines the end key
  13030. */
  13031. createAnimationRange(name: string, from: number, to: number): void;
  13032. /**
  13033. * Delete a specific animation range
  13034. * @param name defines the name of the range
  13035. * @param deleteFrames defines if frames must be removed as well
  13036. */
  13037. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13038. /**
  13039. * Gets a specific animation range
  13040. * @param name defines the name of the range to look for
  13041. * @returns the requested animation range or null if not found
  13042. */
  13043. getAnimationRange(name: string): Nullable<AnimationRange>;
  13044. /**
  13045. * Gets the list of all animation ranges defined on this skeleton
  13046. * @returns an array
  13047. */
  13048. getAnimationRanges(): Nullable<AnimationRange>[];
  13049. /**
  13050. * Copy animation range from a source skeleton.
  13051. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13052. * @param source defines the source skeleton
  13053. * @param name defines the name of the range to copy
  13054. * @param rescaleAsRequired defines if rescaling must be applied if required
  13055. * @returns true if operation was successful
  13056. */
  13057. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13058. /**
  13059. * Forces the skeleton to go to rest pose
  13060. */
  13061. returnToRest(): void;
  13062. private _getHighestAnimationFrame;
  13063. /**
  13064. * Begin a specific animation range
  13065. * @param name defines the name of the range to start
  13066. * @param loop defines if looping must be turned on (false by default)
  13067. * @param speedRatio defines the speed ratio to apply (1 by default)
  13068. * @param onAnimationEnd defines a callback which will be called when animation will end
  13069. * @returns a new animatable
  13070. */
  13071. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13072. /** @hidden */ private _markAsDirty(): void;
  13073. /** @hidden */ private _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13074. /** @hidden */ private _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13075. private _computeTransformMatrices;
  13076. /**
  13077. * Build all resources required to render a skeleton
  13078. */
  13079. prepare(): void;
  13080. /**
  13081. * Gets the list of animatables currently running for this skeleton
  13082. * @returns an array of animatables
  13083. */
  13084. getAnimatables(): IAnimatable[];
  13085. /**
  13086. * Clone the current skeleton
  13087. * @param name defines the name of the new skeleton
  13088. * @param id defines the id of the new skeleton
  13089. * @returns the new skeleton
  13090. */
  13091. clone(name: string, id: string): Skeleton;
  13092. /**
  13093. * Enable animation blending for this skeleton
  13094. * @param blendingSpeed defines the blending speed to apply
  13095. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13096. */
  13097. enableBlending(blendingSpeed?: number): void;
  13098. /**
  13099. * Releases all resources associated with the current skeleton
  13100. */
  13101. dispose(): void;
  13102. /**
  13103. * Serialize the skeleton in a JSON object
  13104. * @returns a JSON object
  13105. */
  13106. serialize(): any;
  13107. /**
  13108. * Creates a new skeleton from serialized data
  13109. * @param parsedSkeleton defines the serialized data
  13110. * @param scene defines the hosting scene
  13111. * @returns a new skeleton
  13112. */
  13113. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13114. /**
  13115. * Compute all node absolute transforms
  13116. * @param forceUpdate defines if computation must be done even if cache is up to date
  13117. */
  13118. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13119. /**
  13120. * Gets the root pose matrix
  13121. * @returns a matrix
  13122. */
  13123. getPoseMatrix(): Nullable<Matrix>;
  13124. /**
  13125. * Sorts bones per internal index
  13126. */
  13127. sortBones(): void;
  13128. private _sortBones;
  13129. }
  13130. }
  13131. declare module BABYLON {
  13132. /**
  13133. * Class used to store bone information
  13134. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13135. */
  13136. export class Bone extends Node {
  13137. /**
  13138. * defines the bone name
  13139. */
  13140. name: string;
  13141. private static _tmpVecs;
  13142. private static _tmpQuat;
  13143. private static _tmpMats;
  13144. /**
  13145. * Gets the list of child bones
  13146. */
  13147. children: Bone[];
  13148. /** Gets the animations associated with this bone */
  13149. animations: Animation[];
  13150. /**
  13151. * Gets or sets bone length
  13152. */
  13153. length: number;
  13154. /**
  13155. * @hidden Internal only
  13156. * Set this value to map this bone to a different index in the transform matrices
  13157. * Set this value to -1 to exclude the bone from the transform matrices
  13158. */ private _index: Nullable<number>;
  13159. private _skeleton;
  13160. private _localMatrix;
  13161. private _restPose;
  13162. private _baseMatrix;
  13163. private _absoluteTransform;
  13164. private _invertedAbsoluteTransform;
  13165. private _parent;
  13166. private _scalingDeterminant;
  13167. private _worldTransform;
  13168. private _localScaling;
  13169. private _localRotation;
  13170. private _localPosition;
  13171. private _needToDecompose;
  13172. private _needToCompose;
  13173. /** @hidden */ private _linkedTransformNode: Nullable<TransformNode>;
  13174. /** @hidden */ private _waitingTransformNodeId: Nullable<string>;
  13175. /** @hidden */
  13176. /** @hidden */ private _matrix: Matrix;
  13177. /**
  13178. * Create a new bone
  13179. * @param name defines the bone name
  13180. * @param skeleton defines the parent skeleton
  13181. * @param parentBone defines the parent (can be null if the bone is the root)
  13182. * @param localMatrix defines the local matrix
  13183. * @param restPose defines the rest pose matrix
  13184. * @param baseMatrix defines the base matrix
  13185. * @param index defines index of the bone in the hiearchy
  13186. */
  13187. constructor(
  13188. /**
  13189. * defines the bone name
  13190. */
  13191. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13192. /**
  13193. * Gets the current object class name.
  13194. * @return the class name
  13195. */
  13196. getClassName(): string;
  13197. /**
  13198. * Gets the parent skeleton
  13199. * @returns a skeleton
  13200. */
  13201. getSkeleton(): Skeleton;
  13202. /**
  13203. * Gets parent bone
  13204. * @returns a bone or null if the bone is the root of the bone hierarchy
  13205. */
  13206. getParent(): Nullable<Bone>;
  13207. /**
  13208. * Returns an array containing the root bones
  13209. * @returns an array containing the root bones
  13210. */
  13211. getChildren(): Array<Bone>;
  13212. /**
  13213. * Sets the parent bone
  13214. * @param parent defines the parent (can be null if the bone is the root)
  13215. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13216. */
  13217. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13218. /**
  13219. * Gets the local matrix
  13220. * @returns a matrix
  13221. */
  13222. getLocalMatrix(): Matrix;
  13223. /**
  13224. * Gets the base matrix (initial matrix which remains unchanged)
  13225. * @returns a matrix
  13226. */
  13227. getBaseMatrix(): Matrix;
  13228. /**
  13229. * Gets the rest pose matrix
  13230. * @returns a matrix
  13231. */
  13232. getRestPose(): Matrix;
  13233. /**
  13234. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13235. */
  13236. getWorldMatrix(): Matrix;
  13237. /**
  13238. * Sets the local matrix to rest pose matrix
  13239. */
  13240. returnToRest(): void;
  13241. /**
  13242. * Gets the inverse of the absolute transform matrix.
  13243. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13244. * @returns a matrix
  13245. */
  13246. getInvertedAbsoluteTransform(): Matrix;
  13247. /**
  13248. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13249. * @returns a matrix
  13250. */
  13251. getAbsoluteTransform(): Matrix;
  13252. /**
  13253. * Links with the given transform node.
  13254. * The local matrix of this bone is copied from the transform node every frame.
  13255. * @param transformNode defines the transform node to link to
  13256. */
  13257. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13258. /**
  13259. * Gets the node used to drive the bone's transformation
  13260. * @returns a transform node or null
  13261. */
  13262. getTransformNode(): Nullable<TransformNode>;
  13263. /** Gets or sets current position (in local space) */
  13264. position: Vector3;
  13265. /** Gets or sets current rotation (in local space) */
  13266. rotation: Vector3;
  13267. /** Gets or sets current rotation quaternion (in local space) */
  13268. rotationQuaternion: Quaternion;
  13269. /** Gets or sets current scaling (in local space) */
  13270. scaling: Vector3;
  13271. /**
  13272. * Gets the animation properties override
  13273. */
  13274. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13275. private _decompose;
  13276. private _compose;
  13277. /**
  13278. * Update the base and local matrices
  13279. * @param matrix defines the new base or local matrix
  13280. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13281. * @param updateLocalMatrix defines if the local matrix should be updated
  13282. */
  13283. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13284. /** @hidden */ private _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13285. /**
  13286. * Flag the bone as dirty (Forcing it to update everything)
  13287. */
  13288. markAsDirty(): void;
  13289. /** @hidden */ private _markAsDirtyAndCompose(): void;
  13290. private _markAsDirtyAndDecompose;
  13291. /**
  13292. * Translate the bone in local or world space
  13293. * @param vec The amount to translate the bone
  13294. * @param space The space that the translation is in
  13295. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13296. */
  13297. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13298. /**
  13299. * Set the postion of the bone in local or world space
  13300. * @param position The position to set the bone
  13301. * @param space The space that the position is in
  13302. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13303. */
  13304. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13305. /**
  13306. * Set the absolute position of the bone (world space)
  13307. * @param position The position to set the bone
  13308. * @param mesh The mesh that this bone is attached to
  13309. */
  13310. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13311. /**
  13312. * Scale the bone on the x, y and z axes (in local space)
  13313. * @param x The amount to scale the bone on the x axis
  13314. * @param y The amount to scale the bone on the y axis
  13315. * @param z The amount to scale the bone on the z axis
  13316. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13317. */
  13318. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13319. /**
  13320. * Set the bone scaling in local space
  13321. * @param scale defines the scaling vector
  13322. */
  13323. setScale(scale: Vector3): void;
  13324. /**
  13325. * Gets the current scaling in local space
  13326. * @returns the current scaling vector
  13327. */
  13328. getScale(): Vector3;
  13329. /**
  13330. * Gets the current scaling in local space and stores it in a target vector
  13331. * @param result defines the target vector
  13332. */
  13333. getScaleToRef(result: Vector3): void;
  13334. /**
  13335. * Set the yaw, pitch, and roll of the bone in local or world space
  13336. * @param yaw The rotation of the bone on the y axis
  13337. * @param pitch The rotation of the bone on the x axis
  13338. * @param roll The rotation of the bone on the z axis
  13339. * @param space The space that the axes of rotation are in
  13340. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13341. */
  13342. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  13343. /**
  13344. * Add a rotation to the bone on an axis in local or world space
  13345. * @param axis The axis to rotate the bone on
  13346. * @param amount The amount to rotate the bone
  13347. * @param space The space that the axis is in
  13348. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13349. */
  13350. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  13351. /**
  13352. * Set the rotation of the bone to a particular axis angle in local or world space
  13353. * @param axis The axis to rotate the bone on
  13354. * @param angle The angle that the bone should be rotated to
  13355. * @param space The space that the axis is in
  13356. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13357. */
  13358. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  13359. /**
  13360. * Set the euler rotation of the bone in local of world space
  13361. * @param rotation The euler rotation that the bone should be set to
  13362. * @param space The space that the rotation is in
  13363. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13364. */
  13365. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13366. /**
  13367. * Set the quaternion rotation of the bone in local of world space
  13368. * @param quat The quaternion rotation that the bone should be set to
  13369. * @param space The space that the rotation is in
  13370. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13371. */
  13372. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  13373. /**
  13374. * Set the rotation matrix of the bone in local of world space
  13375. * @param rotMat The rotation matrix that the bone should be set to
  13376. * @param space The space that the rotation is in
  13377. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13378. */
  13379. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  13380. private _rotateWithMatrix;
  13381. private _getNegativeRotationToRef;
  13382. /**
  13383. * Get the position of the bone in local or world space
  13384. * @param space The space that the returned position is in
  13385. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13386. * @returns The position of the bone
  13387. */
  13388. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13389. /**
  13390. * Copy the position of the bone to a vector3 in local or world space
  13391. * @param space The space that the returned position is in
  13392. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13393. * @param result The vector3 to copy the position to
  13394. */
  13395. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  13396. /**
  13397. * Get the absolute position of the bone (world space)
  13398. * @param mesh The mesh that this bone is attached to
  13399. * @returns The absolute position of the bone
  13400. */
  13401. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  13402. /**
  13403. * Copy the absolute position of the bone (world space) to the result param
  13404. * @param mesh The mesh that this bone is attached to
  13405. * @param result The vector3 to copy the absolute position to
  13406. */
  13407. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  13408. /**
  13409. * Compute the absolute transforms of this bone and its children
  13410. */
  13411. computeAbsoluteTransforms(): void;
  13412. /**
  13413. * Get the world direction from an axis that is in the local space of the bone
  13414. * @param localAxis The local direction that is used to compute the world direction
  13415. * @param mesh The mesh that this bone is attached to
  13416. * @returns The world direction
  13417. */
  13418. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13419. /**
  13420. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  13421. * @param localAxis The local direction that is used to compute the world direction
  13422. * @param mesh The mesh that this bone is attached to
  13423. * @param result The vector3 that the world direction will be copied to
  13424. */
  13425. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13426. /**
  13427. * Get the euler rotation of the bone in local or world space
  13428. * @param space The space that the rotation should be in
  13429. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13430. * @returns The euler rotation
  13431. */
  13432. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  13433. /**
  13434. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  13435. * @param space The space that the rotation should be in
  13436. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13437. * @param result The vector3 that the rotation should be copied to
  13438. */
  13439. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13440. /**
  13441. * Get the quaternion rotation of the bone in either local or world space
  13442. * @param space The space that the rotation should be in
  13443. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13444. * @returns The quaternion rotation
  13445. */
  13446. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  13447. /**
  13448. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  13449. * @param space The space that the rotation should be in
  13450. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13451. * @param result The quaternion that the rotation should be copied to
  13452. */
  13453. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  13454. /**
  13455. * Get the rotation matrix of the bone in local or world space
  13456. * @param space The space that the rotation should be in
  13457. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13458. * @returns The rotation matrix
  13459. */
  13460. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  13461. /**
  13462. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  13463. * @param space The space that the rotation should be in
  13464. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13465. * @param result The quaternion that the rotation should be copied to
  13466. */
  13467. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  13468. /**
  13469. * Get the world position of a point that is in the local space of the bone
  13470. * @param position The local position
  13471. * @param mesh The mesh that this bone is attached to
  13472. * @returns The world position
  13473. */
  13474. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13475. /**
  13476. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  13477. * @param position The local position
  13478. * @param mesh The mesh that this bone is attached to
  13479. * @param result The vector3 that the world position should be copied to
  13480. */
  13481. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13482. /**
  13483. * Get the local position of a point that is in world space
  13484. * @param position The world position
  13485. * @param mesh The mesh that this bone is attached to
  13486. * @returns The local position
  13487. */
  13488. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  13489. /**
  13490. * Get the local position of a point that is in world space and copy it to the result param
  13491. * @param position The world position
  13492. * @param mesh The mesh that this bone is attached to
  13493. * @param result The vector3 that the local position should be copied to
  13494. */
  13495. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  13496. }
  13497. }
  13498. declare module BABYLON {
  13499. /**
  13500. * 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.
  13501. * @see https://doc.babylonjs.com/how_to/transformnode
  13502. */
  13503. export class TransformNode extends Node {
  13504. /**
  13505. * Object will not rotate to face the camera
  13506. */
  13507. static BILLBOARDMODE_NONE: number;
  13508. /**
  13509. * Object will rotate to face the camera but only on the x axis
  13510. */
  13511. static BILLBOARDMODE_X: number;
  13512. /**
  13513. * Object will rotate to face the camera but only on the y axis
  13514. */
  13515. static BILLBOARDMODE_Y: number;
  13516. /**
  13517. * Object will rotate to face the camera but only on the z axis
  13518. */
  13519. static BILLBOARDMODE_Z: number;
  13520. /**
  13521. * Object will rotate to face the camera
  13522. */
  13523. static BILLBOARDMODE_ALL: number;
  13524. /**
  13525. * Object will rotate to face the camera's position instead of orientation
  13526. */
  13527. static BILLBOARDMODE_USE_POSITION: number;
  13528. private _forward;
  13529. private _forwardInverted;
  13530. private _up;
  13531. private _right;
  13532. private _rightInverted;
  13533. private _position;
  13534. private _rotation;
  13535. private _rotationQuaternion;
  13536. protected _scaling: Vector3;
  13537. protected _isDirty: boolean;
  13538. private _transformToBoneReferal;
  13539. private _isAbsoluteSynced;
  13540. private _billboardMode;
  13541. /**
  13542. * Gets or sets the billboard mode. Default is 0.
  13543. *
  13544. * | Value | Type | Description |
  13545. * | --- | --- | --- |
  13546. * | 0 | BILLBOARDMODE_NONE | |
  13547. * | 1 | BILLBOARDMODE_X | |
  13548. * | 2 | BILLBOARDMODE_Y | |
  13549. * | 4 | BILLBOARDMODE_Z | |
  13550. * | 7 | BILLBOARDMODE_ALL | |
  13551. *
  13552. */
  13553. billboardMode: number;
  13554. private _preserveParentRotationForBillboard;
  13555. /**
  13556. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  13557. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  13558. */
  13559. preserveParentRotationForBillboard: boolean;
  13560. /**
  13561. * 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
  13562. */
  13563. scalingDeterminant: number;
  13564. private _infiniteDistance;
  13565. /**
  13566. * Gets or sets the distance of the object to max, often used by skybox
  13567. */
  13568. infiniteDistance: boolean;
  13569. /**
  13570. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  13571. * By default the system will update normals to compensate
  13572. */
  13573. ignoreNonUniformScaling: boolean;
  13574. /**
  13575. * 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
  13576. */
  13577. reIntegrateRotationIntoRotationQuaternion: boolean;
  13578. /** @hidden */ private _poseMatrix: Nullable<Matrix>;
  13579. /** @hidden */ private _localMatrix: Matrix;
  13580. private _usePivotMatrix;
  13581. private _absolutePosition;
  13582. private _absoluteScaling;
  13583. private _absoluteRotationQuaternion;
  13584. private _pivotMatrix;
  13585. private _pivotMatrixInverse;
  13586. protected _postMultiplyPivotMatrix: boolean;
  13587. protected _isWorldMatrixFrozen: boolean;
  13588. /** @hidden */ private _indexInSceneTransformNodesArray: number;
  13589. /**
  13590. * An event triggered after the world matrix is updated
  13591. */
  13592. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13593. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13594. /**
  13595. * Gets a string identifying the name of the class
  13596. * @returns "TransformNode" string
  13597. */
  13598. getClassName(): string;
  13599. /**
  13600. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  13601. */
  13602. position: Vector3;
  13603. /**
  13604. * 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)).
  13605. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  13606. */
  13607. rotation: Vector3;
  13608. /**
  13609. * 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)).
  13610. */
  13611. scaling: Vector3;
  13612. /**
  13613. * 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).
  13614. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  13615. */
  13616. rotationQuaternion: Nullable<Quaternion>;
  13617. /**
  13618. * The forward direction of that transform in world space.
  13619. */
  13620. readonly forward: Vector3;
  13621. /**
  13622. * The up direction of that transform in world space.
  13623. */
  13624. readonly up: Vector3;
  13625. /**
  13626. * The right direction of that transform in world space.
  13627. */
  13628. readonly right: Vector3;
  13629. /**
  13630. * Copies the parameter passed Matrix into the mesh Pose matrix.
  13631. * @param matrix the matrix to copy the pose from
  13632. * @returns this TransformNode.
  13633. */
  13634. updatePoseMatrix(matrix: Matrix): TransformNode;
  13635. /**
  13636. * Returns the mesh Pose matrix.
  13637. * @returns the pose matrix
  13638. */
  13639. getPoseMatrix(): Matrix;
  13640. /** @hidden */ private _isSynchronized(): boolean;
  13641. /** @hidden */ private _initCache(): void;
  13642. /**
  13643. * Flag the transform node as dirty (Forcing it to update everything)
  13644. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  13645. * @returns this transform node
  13646. */
  13647. markAsDirty(property: string): TransformNode;
  13648. /**
  13649. * Returns the current mesh absolute position.
  13650. * Returns a Vector3.
  13651. */
  13652. readonly absolutePosition: Vector3;
  13653. /**
  13654. * Returns the current mesh absolute scaling.
  13655. * Returns a Vector3.
  13656. */
  13657. readonly absoluteScaling: Vector3;
  13658. /**
  13659. * Returns the current mesh absolute rotation.
  13660. * Returns a Quaternion.
  13661. */
  13662. readonly absoluteRotationQuaternion: Quaternion;
  13663. /**
  13664. * Sets a new matrix to apply before all other transformation
  13665. * @param matrix defines the transform matrix
  13666. * @returns the current TransformNode
  13667. */
  13668. setPreTransformMatrix(matrix: Matrix): TransformNode;
  13669. /**
  13670. * Sets a new pivot matrix to the current node
  13671. * @param matrix defines the new pivot matrix to use
  13672. * @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
  13673. * @returns the current TransformNode
  13674. */
  13675. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  13676. /**
  13677. * Returns the mesh pivot matrix.
  13678. * Default : Identity.
  13679. * @returns the matrix
  13680. */
  13681. getPivotMatrix(): Matrix;
  13682. /**
  13683. * Prevents the World matrix to be computed any longer.
  13684. * @returns the TransformNode.
  13685. */
  13686. freezeWorldMatrix(): TransformNode;
  13687. /**
  13688. * Allows back the World matrix computation.
  13689. * @returns the TransformNode.
  13690. */
  13691. unfreezeWorldMatrix(): this;
  13692. /**
  13693. * True if the World matrix has been frozen.
  13694. */
  13695. readonly isWorldMatrixFrozen: boolean;
  13696. /**
  13697. * Retuns the mesh absolute position in the World.
  13698. * @returns a Vector3.
  13699. */
  13700. getAbsolutePosition(): Vector3;
  13701. /**
  13702. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13703. * @param absolutePosition the absolute position to set
  13704. * @returns the TransformNode.
  13705. */
  13706. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13707. /**
  13708. * Sets the mesh position in its local space.
  13709. * @param vector3 the position to set in localspace
  13710. * @returns the TransformNode.
  13711. */
  13712. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13713. /**
  13714. * Returns the mesh position in the local space from the current World matrix values.
  13715. * @returns a new Vector3.
  13716. */
  13717. getPositionExpressedInLocalSpace(): Vector3;
  13718. /**
  13719. * Translates the mesh along the passed Vector3 in its local space.
  13720. * @param vector3 the distance to translate in localspace
  13721. * @returns the TransformNode.
  13722. */
  13723. locallyTranslate(vector3: Vector3): TransformNode;
  13724. private static _lookAtVectorCache;
  13725. /**
  13726. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13727. * @param targetPoint the position (must be in same space as current mesh) to look at
  13728. * @param yawCor optional yaw (y-axis) correction in radians
  13729. * @param pitchCor optional pitch (x-axis) correction in radians
  13730. * @param rollCor optional roll (z-axis) correction in radians
  13731. * @param space the choosen space of the target
  13732. * @returns the TransformNode.
  13733. */
  13734. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13735. /**
  13736. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13737. * This Vector3 is expressed in the World space.
  13738. * @param localAxis axis to rotate
  13739. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13740. */
  13741. getDirection(localAxis: Vector3): Vector3;
  13742. /**
  13743. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13744. * localAxis is expressed in the mesh local space.
  13745. * result is computed in the Wordl space from the mesh World matrix.
  13746. * @param localAxis axis to rotate
  13747. * @param result the resulting transformnode
  13748. * @returns this TransformNode.
  13749. */
  13750. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13751. /**
  13752. * Sets this transform node rotation to the given local axis.
  13753. * @param localAxis the axis in local space
  13754. * @param yawCor optional yaw (y-axis) correction in radians
  13755. * @param pitchCor optional pitch (x-axis) correction in radians
  13756. * @param rollCor optional roll (z-axis) correction in radians
  13757. * @returns this TransformNode
  13758. */
  13759. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  13760. /**
  13761. * Sets a new pivot point to the current node
  13762. * @param point defines the new pivot point to use
  13763. * @param space defines if the point is in world or local space (local by default)
  13764. * @returns the current TransformNode
  13765. */
  13766. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13767. /**
  13768. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13769. * @returns the pivot point
  13770. */
  13771. getPivotPoint(): Vector3;
  13772. /**
  13773. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13774. * @param result the vector3 to store the result
  13775. * @returns this TransformNode.
  13776. */
  13777. getPivotPointToRef(result: Vector3): TransformNode;
  13778. /**
  13779. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13780. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  13781. */
  13782. getAbsolutePivotPoint(): Vector3;
  13783. /**
  13784. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13785. * @param result vector3 to store the result
  13786. * @returns this TransformNode.
  13787. */
  13788. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13789. /**
  13790. * Defines the passed node as the parent of the current node.
  13791. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13792. * @see https://doc.babylonjs.com/how_to/parenting
  13793. * @param node the node ot set as the parent
  13794. * @returns this TransformNode.
  13795. */
  13796. setParent(node: Nullable<Node>): TransformNode;
  13797. private _nonUniformScaling;
  13798. /**
  13799. * True if the scaling property of this object is non uniform eg. (1,2,1)
  13800. */
  13801. readonly nonUniformScaling: boolean;
  13802. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  13803. /**
  13804. * Attach the current TransformNode to another TransformNode associated with a bone
  13805. * @param bone Bone affecting the TransformNode
  13806. * @param affectedTransformNode TransformNode associated with the bone
  13807. * @returns this object
  13808. */
  13809. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13810. /**
  13811. * Detach the transform node if its associated with a bone
  13812. * @returns this object
  13813. */
  13814. detachFromBone(): TransformNode;
  13815. private static _rotationAxisCache;
  13816. /**
  13817. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13818. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13819. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13820. * The passed axis is also normalized.
  13821. * @param axis the axis to rotate around
  13822. * @param amount the amount to rotate in radians
  13823. * @param space Space to rotate in (Default: local)
  13824. * @returns the TransformNode.
  13825. */
  13826. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13827. /**
  13828. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13829. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13830. * The passed axis is also normalized. .
  13831. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13832. * @param point the point to rotate around
  13833. * @param axis the axis to rotate around
  13834. * @param amount the amount to rotate in radians
  13835. * @returns the TransformNode
  13836. */
  13837. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13838. /**
  13839. * Translates the mesh along the axis vector for the passed distance in the given space.
  13840. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  13841. * @param axis the axis to translate in
  13842. * @param distance the distance to translate
  13843. * @param space Space to rotate in (Default: local)
  13844. * @returns the TransformNode.
  13845. */
  13846. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13847. /**
  13848. * Adds a rotation step to the mesh current rotation.
  13849. * x, y, z are Euler angles expressed in radians.
  13850. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13851. * This means this rotation is made in the mesh local space only.
  13852. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13853. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13854. * ```javascript
  13855. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13856. * ```
  13857. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13858. * 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.
  13859. * @param x Rotation to add
  13860. * @param y Rotation to add
  13861. * @param z Rotation to add
  13862. * @returns the TransformNode.
  13863. */
  13864. addRotation(x: number, y: number, z: number): TransformNode;
  13865. /**
  13866. * @hidden
  13867. */
  13868. protected _getEffectiveParent(): Nullable<Node>;
  13869. /**
  13870. * Computes the world matrix of the node
  13871. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13872. * @returns the world matrix
  13873. */
  13874. computeWorldMatrix(force?: boolean): Matrix;
  13875. protected _afterComputeWorldMatrix(): void;
  13876. /**
  13877. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13878. * @param func callback function to add
  13879. *
  13880. * @returns the TransformNode.
  13881. */
  13882. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13883. /**
  13884. * Removes a registered callback function.
  13885. * @param func callback function to remove
  13886. * @returns the TransformNode.
  13887. */
  13888. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13889. /**
  13890. * Gets the position of the current mesh in camera space
  13891. * @param camera defines the camera to use
  13892. * @returns a position
  13893. */
  13894. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  13895. /**
  13896. * Returns the distance from the mesh to the active camera
  13897. * @param camera defines the camera to use
  13898. * @returns the distance
  13899. */
  13900. getDistanceToCamera(camera?: Nullable<Camera>): number;
  13901. /**
  13902. * Clone the current transform node
  13903. * @param name Name of the new clone
  13904. * @param newParent New parent for the clone
  13905. * @param doNotCloneChildren Do not clone children hierarchy
  13906. * @returns the new transform node
  13907. */
  13908. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13909. /**
  13910. * Serializes the objects information.
  13911. * @param currentSerializationObject defines the object to serialize in
  13912. * @returns the serialized object
  13913. */
  13914. serialize(currentSerializationObject?: any): any;
  13915. /**
  13916. * Returns a new TransformNode object parsed from the source provided.
  13917. * @param parsedTransformNode is the source.
  13918. * @param scene the scne the object belongs to
  13919. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13920. * @returns a new TransformNode object parsed from the source provided.
  13921. */
  13922. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13923. /**
  13924. * Get all child-transformNodes of this node
  13925. * @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
  13926. * @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
  13927. * @returns an array of TransformNode
  13928. */
  13929. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  13930. /**
  13931. * Releases resources associated with this transform node.
  13932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  13933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  13934. */
  13935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  13936. /**
  13937. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  13938. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  13939. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  13940. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  13941. * @returns the current mesh
  13942. */
  13943. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  13944. private _syncAbsoluteScalingAndRotation;
  13945. }
  13946. }
  13947. declare module BABYLON {
  13948. /**
  13949. * Defines the types of pose enabled controllers that are supported
  13950. */
  13951. export enum PoseEnabledControllerType {
  13952. /**
  13953. * HTC Vive
  13954. */
  13955. VIVE = 0,
  13956. /**
  13957. * Oculus Rift
  13958. */
  13959. OCULUS = 1,
  13960. /**
  13961. * Windows mixed reality
  13962. */
  13963. WINDOWS = 2,
  13964. /**
  13965. * Samsung gear VR
  13966. */
  13967. GEAR_VR = 3,
  13968. /**
  13969. * Google Daydream
  13970. */
  13971. DAYDREAM = 4,
  13972. /**
  13973. * Generic
  13974. */
  13975. GENERIC = 5
  13976. }
  13977. /**
  13978. * Defines the MutableGamepadButton interface for the state of a gamepad button
  13979. */
  13980. export interface MutableGamepadButton {
  13981. /**
  13982. * Value of the button/trigger
  13983. */
  13984. value: number;
  13985. /**
  13986. * If the button/trigger is currently touched
  13987. */
  13988. touched: boolean;
  13989. /**
  13990. * If the button/trigger is currently pressed
  13991. */
  13992. pressed: boolean;
  13993. }
  13994. /**
  13995. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  13996. * @hidden
  13997. */
  13998. export interface ExtendedGamepadButton extends GamepadButton {
  13999. /**
  14000. * If the button/trigger is currently pressed
  14001. */
  14002. readonly pressed: boolean;
  14003. /**
  14004. * If the button/trigger is currently touched
  14005. */
  14006. readonly touched: boolean;
  14007. /**
  14008. * Value of the button/trigger
  14009. */
  14010. readonly value: number;
  14011. }
  14012. /** @hidden */
  14013. export interface _GamePadFactory {
  14014. /**
  14015. * Returns wether or not the current gamepad can be created for this type of controller.
  14016. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14017. * @returns true if it can be created, otherwise false
  14018. */
  14019. canCreate(gamepadInfo: any): boolean;
  14020. /**
  14021. * Creates a new instance of the Gamepad.
  14022. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14023. * @returns the new gamepad instance
  14024. */
  14025. create(gamepadInfo: any): Gamepad;
  14026. }
  14027. /**
  14028. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14029. */
  14030. export class PoseEnabledControllerHelper {
  14031. /** @hidden */ private static _ControllerFactories: _GamePadFactory[];
  14032. /** @hidden */ private static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14033. /**
  14034. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14035. * @param vrGamepad the gamepad to initialized
  14036. * @returns a vr controller of the type the gamepad identified as
  14037. */
  14038. static InitiateController(vrGamepad: any): Gamepad;
  14039. }
  14040. /**
  14041. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14042. */
  14043. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14044. /**
  14045. * If the controller is used in a webXR session
  14046. */
  14047. isXR: boolean;
  14048. private _deviceRoomPosition;
  14049. private _deviceRoomRotationQuaternion;
  14050. /**
  14051. * The device position in babylon space
  14052. */
  14053. devicePosition: Vector3;
  14054. /**
  14055. * The device rotation in babylon space
  14056. */
  14057. deviceRotationQuaternion: Quaternion;
  14058. /**
  14059. * The scale factor of the device in babylon space
  14060. */
  14061. deviceScaleFactor: number;
  14062. /**
  14063. * (Likely devicePosition should be used instead) The device position in its room space
  14064. */
  14065. position: Vector3;
  14066. /**
  14067. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14068. */
  14069. rotationQuaternion: Quaternion;
  14070. /**
  14071. * The type of controller (Eg. Windows mixed reality)
  14072. */
  14073. controllerType: PoseEnabledControllerType;
  14074. protected _calculatedPosition: Vector3;
  14075. private _calculatedRotation;
  14076. /**
  14077. * The raw pose from the device
  14078. */
  14079. rawPose: DevicePose;
  14080. private _trackPosition;
  14081. private _maxRotationDistFromHeadset;
  14082. private _draggedRoomRotation;
  14083. /**
  14084. * @hidden
  14085. */ private _disableTrackPosition(fixedPosition: Vector3): void;
  14086. /**
  14087. * Internal, the mesh attached to the controller
  14088. * @hidden
  14089. */ private _mesh: Nullable<AbstractMesh>;
  14090. private _poseControlledCamera;
  14091. private _leftHandSystemQuaternion;
  14092. /**
  14093. * Internal, matrix used to convert room space to babylon space
  14094. * @hidden
  14095. */ private _deviceToWorld: Matrix;
  14096. /**
  14097. * Node to be used when casting a ray from the controller
  14098. * @hidden
  14099. */ private _pointingPoseNode: Nullable<TransformNode>;
  14100. /**
  14101. * Name of the child mesh that can be used to cast a ray from the controller
  14102. */
  14103. static readonly POINTING_POSE: string;
  14104. /**
  14105. * Creates a new PoseEnabledController from a gamepad
  14106. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14107. */
  14108. constructor(browserGamepad: any);
  14109. private _workingMatrix;
  14110. /**
  14111. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14112. */
  14113. update(): void;
  14114. /**
  14115. * Updates only the pose device and mesh without doing any button event checking
  14116. */
  14117. protected _updatePoseAndMesh(): void;
  14118. /**
  14119. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14120. * @param poseData raw pose fromthe device
  14121. */
  14122. updateFromDevice(poseData: DevicePose): void;
  14123. /**
  14124. * @hidden
  14125. */ private _meshAttachedObservable: Observable<AbstractMesh>;
  14126. /**
  14127. * Attaches a mesh to the controller
  14128. * @param mesh the mesh to be attached
  14129. */
  14130. attachToMesh(mesh: AbstractMesh): void;
  14131. /**
  14132. * Attaches the controllers mesh to a camera
  14133. * @param camera the camera the mesh should be attached to
  14134. */
  14135. attachToPoseControlledCamera(camera: TargetCamera): void;
  14136. /**
  14137. * Disposes of the controller
  14138. */
  14139. dispose(): void;
  14140. /**
  14141. * The mesh that is attached to the controller
  14142. */
  14143. readonly mesh: Nullable<AbstractMesh>;
  14144. /**
  14145. * Gets the ray of the controller in the direction the controller is pointing
  14146. * @param length the length the resulting ray should be
  14147. * @returns a ray in the direction the controller is pointing
  14148. */
  14149. getForwardRay(length?: number): Ray;
  14150. }
  14151. }
  14152. declare module BABYLON {
  14153. /**
  14154. * Defines the WebVRController object that represents controllers tracked in 3D space
  14155. */
  14156. export abstract class WebVRController extends PoseEnabledController {
  14157. /**
  14158. * Internal, the default controller model for the controller
  14159. */
  14160. protected _defaultModel: AbstractMesh;
  14161. /**
  14162. * Fired when the trigger state has changed
  14163. */
  14164. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14165. /**
  14166. * Fired when the main button state has changed
  14167. */
  14168. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14169. /**
  14170. * Fired when the secondary button state has changed
  14171. */
  14172. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14173. /**
  14174. * Fired when the pad state has changed
  14175. */
  14176. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14177. /**
  14178. * Fired when controllers stick values have changed
  14179. */
  14180. onPadValuesChangedObservable: Observable<StickValues>;
  14181. /**
  14182. * Array of button availible on the controller
  14183. */
  14184. protected _buttons: Array<MutableGamepadButton>;
  14185. private _onButtonStateChange;
  14186. /**
  14187. * Fired when a controller button's state has changed
  14188. * @param callback the callback containing the button that was modified
  14189. */
  14190. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14191. /**
  14192. * X and Y axis corresponding to the controllers joystick
  14193. */
  14194. pad: StickValues;
  14195. /**
  14196. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14197. */
  14198. hand: string;
  14199. /**
  14200. * The default controller model for the controller
  14201. */
  14202. readonly defaultModel: AbstractMesh;
  14203. /**
  14204. * Creates a new WebVRController from a gamepad
  14205. * @param vrGamepad the gamepad that the WebVRController should be created from
  14206. */
  14207. constructor(vrGamepad: any);
  14208. /**
  14209. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14210. */
  14211. update(): void;
  14212. /**
  14213. * Function to be called when a button is modified
  14214. */
  14215. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14216. /**
  14217. * Loads a mesh and attaches it to the controller
  14218. * @param scene the scene the mesh should be added to
  14219. * @param meshLoaded callback for when the mesh has been loaded
  14220. */
  14221. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14222. private _setButtonValue;
  14223. private _changes;
  14224. private _checkChanges;
  14225. /**
  14226. * Disposes of th webVRCOntroller
  14227. */
  14228. dispose(): void;
  14229. }
  14230. }
  14231. declare module BABYLON {
  14232. /**
  14233. * The HemisphericLight simulates the ambient environment light,
  14234. * so the passed direction is the light reflection direction, not the incoming direction.
  14235. */
  14236. export class HemisphericLight extends Light {
  14237. /**
  14238. * The groundColor is the light in the opposite direction to the one specified during creation.
  14239. * 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.
  14240. */
  14241. groundColor: Color3;
  14242. /**
  14243. * The light reflection direction, not the incoming direction.
  14244. */
  14245. direction: Vector3;
  14246. /**
  14247. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14248. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14249. * The HemisphericLight can't cast shadows.
  14250. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14251. * @param name The friendly name of the light
  14252. * @param direction The direction of the light reflection
  14253. * @param scene The scene the light belongs to
  14254. */
  14255. constructor(name: string, direction: Vector3, scene: Scene);
  14256. protected _buildUniformLayout(): void;
  14257. /**
  14258. * Returns the string "HemisphericLight".
  14259. * @return The class name
  14260. */
  14261. getClassName(): string;
  14262. /**
  14263. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14264. * Returns the updated direction.
  14265. * @param target The target the direction should point to
  14266. * @return The computed direction
  14267. */
  14268. setDirectionToTarget(target: Vector3): Vector3;
  14269. /**
  14270. * Returns the shadow generator associated to the light.
  14271. * @returns Always null for hemispheric lights because it does not support shadows.
  14272. */
  14273. getShadowGenerator(): Nullable<IShadowGenerator>;
  14274. /**
  14275. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14276. * @param effect The effect to update
  14277. * @param lightIndex The index of the light in the effect to update
  14278. * @returns The hemispheric light
  14279. */
  14280. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14281. /**
  14282. * Computes the world matrix of the node
  14283. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14284. * @param useWasUpdatedFlag defines a reserved property
  14285. * @returns the world matrix
  14286. */
  14287. computeWorldMatrix(): Matrix;
  14288. /**
  14289. * Returns the integer 3.
  14290. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  14291. */
  14292. getTypeID(): number;
  14293. /**
  14294. * Prepares the list of defines specific to the light type.
  14295. * @param defines the list of defines
  14296. * @param lightIndex defines the index of the light for the effect
  14297. */
  14298. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  14299. }
  14300. }
  14301. declare module BABYLON {
  14302. /** @hidden */
  14303. export var vrMultiviewToSingleviewPixelShader: {
  14304. name: string;
  14305. shader: string;
  14306. };
  14307. }
  14308. declare module BABYLON {
  14309. /**
  14310. * Renders to multiple views with a single draw call
  14311. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  14312. */
  14313. export class MultiviewRenderTarget extends RenderTargetTexture {
  14314. /**
  14315. * Creates a multiview render target
  14316. * @param scene scene used with the render target
  14317. * @param size the size of the render target (used for each view)
  14318. */
  14319. constructor(scene: Scene, size?: number | {
  14320. width: number;
  14321. height: number;
  14322. } | {
  14323. ratio: number;
  14324. });
  14325. /**
  14326. * @hidden
  14327. * @param faceIndex the face index, if its a cube texture
  14328. */ private _bindFrameBuffer(faceIndex?: number): void;
  14329. /**
  14330. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  14331. * @returns the view count
  14332. */
  14333. getViewCount(): number;
  14334. }
  14335. }
  14336. declare module BABYLON {
  14337. /**
  14338. * Reprasents a camera frustum
  14339. */
  14340. export class Frustum {
  14341. /**
  14342. * Gets the planes representing the frustum
  14343. * @param transform matrix to be applied to the returned planes
  14344. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  14345. */
  14346. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  14347. /**
  14348. * Gets the near frustum plane transformed by the transform matrix
  14349. * @param transform transformation matrix to be applied to the resulting frustum plane
  14350. * @param frustumPlane the resuling frustum plane
  14351. */
  14352. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14353. /**
  14354. * Gets the far frustum plane transformed by the transform matrix
  14355. * @param transform transformation matrix to be applied to the resulting frustum plane
  14356. * @param frustumPlane the resuling frustum plane
  14357. */
  14358. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14359. /**
  14360. * Gets the left frustum plane transformed by the transform matrix
  14361. * @param transform transformation matrix to be applied to the resulting frustum plane
  14362. * @param frustumPlane the resuling frustum plane
  14363. */
  14364. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14365. /**
  14366. * Gets the right frustum plane transformed by the transform matrix
  14367. * @param transform transformation matrix to be applied to the resulting frustum plane
  14368. * @param frustumPlane the resuling frustum plane
  14369. */
  14370. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14371. /**
  14372. * Gets the top frustum plane transformed by the transform matrix
  14373. * @param transform transformation matrix to be applied to the resulting frustum plane
  14374. * @param frustumPlane the resuling frustum plane
  14375. */
  14376. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14377. /**
  14378. * Gets the bottom frustum plane transformed by the transform matrix
  14379. * @param transform transformation matrix to be applied to the resulting frustum plane
  14380. * @param frustumPlane the resuling frustum plane
  14381. */
  14382. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  14383. /**
  14384. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  14385. * @param transform transformation matrix to be applied to the resulting frustum planes
  14386. * @param frustumPlanes the resuling frustum planes
  14387. */
  14388. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  14389. }
  14390. }
  14391. declare module BABYLON {
  14392. interface Engine {
  14393. /**
  14394. * Creates a new multiview render target
  14395. * @param width defines the width of the texture
  14396. * @param height defines the height of the texture
  14397. * @returns the created multiview texture
  14398. */
  14399. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  14400. /**
  14401. * Binds a multiview framebuffer to be drawn to
  14402. * @param multiviewTexture texture to bind
  14403. */
  14404. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  14405. }
  14406. interface Camera {
  14407. /**
  14408. * @hidden
  14409. * 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)
  14410. */ private _useMultiviewToSingleView: boolean;
  14411. /**
  14412. * @hidden
  14413. * 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)
  14414. */ private _multiviewTexture: Nullable<RenderTargetTexture>;
  14415. /**
  14416. * @hidden
  14417. * ensures the multiview texture of the camera exists and has the specified width/height
  14418. * @param width height to set on the multiview texture
  14419. * @param height width to set on the multiview texture
  14420. */ private _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  14421. }
  14422. interface Scene {
  14423. /** @hidden */ private _transformMatrixR: Matrix;
  14424. /** @hidden */ private _multiviewSceneUbo: Nullable<UniformBuffer>;
  14425. /** @hidden */ private _createMultiviewUbo(): void;
  14426. /** @hidden */ private _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  14427. /** @hidden */ private _renderMultiviewToSingleView(camera: Camera): void;
  14428. }
  14429. }
  14430. declare module BABYLON {
  14431. /**
  14432. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  14433. * This will not be used for webXR as it supports displaying texture arrays directly
  14434. */
  14435. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  14436. /**
  14437. * Initializes a VRMultiviewToSingleview
  14438. * @param name name of the post process
  14439. * @param camera camera to be applied to
  14440. * @param scaleFactor scaling factor to the size of the output texture
  14441. */
  14442. constructor(name: string, camera: Camera, scaleFactor: number);
  14443. }
  14444. }
  14445. declare module BABYLON {
  14446. interface Engine {
  14447. /** @hidden */ private _vrDisplay: any;
  14448. /** @hidden */ private _vrSupported: boolean;
  14449. /** @hidden */ private _oldSize: Size;
  14450. /** @hidden */ private _oldHardwareScaleFactor: number;
  14451. /** @hidden */ private _vrExclusivePointerMode: boolean;
  14452. /** @hidden */ private _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  14453. /** @hidden */ private _onVRDisplayPointerRestricted: () => void;
  14454. /** @hidden */ private _onVRDisplayPointerUnrestricted: () => void;
  14455. /** @hidden */ private _onVrDisplayConnect: Nullable<(display: any) => void>;
  14456. /** @hidden */ private _onVrDisplayDisconnect: Nullable<() => void>;
  14457. /** @hidden */ private _onVrDisplayPresentChange: Nullable<() => void>;
  14458. /**
  14459. * Observable signaled when VR display mode changes
  14460. */
  14461. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  14462. /**
  14463. * Observable signaled when VR request present is complete
  14464. */
  14465. onVRRequestPresentComplete: Observable<boolean>;
  14466. /**
  14467. * Observable signaled when VR request present starts
  14468. */
  14469. onVRRequestPresentStart: Observable<Engine>;
  14470. /**
  14471. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  14472. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  14473. */
  14474. isInVRExclusivePointerMode: boolean;
  14475. /**
  14476. * Gets a boolean indicating if a webVR device was detected
  14477. * @returns true if a webVR device was detected
  14478. */
  14479. isVRDevicePresent(): boolean;
  14480. /**
  14481. * Gets the current webVR device
  14482. * @returns the current webVR device (or null)
  14483. */
  14484. getVRDevice(): any;
  14485. /**
  14486. * Initializes a webVR display and starts listening to display change events
  14487. * The onVRDisplayChangedObservable will be notified upon these changes
  14488. * @returns A promise containing a VRDisplay and if vr is supported
  14489. */
  14490. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  14491. /** @hidden */ private _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  14492. /**
  14493. * Call this function to switch to webVR mode
  14494. * Will do nothing if webVR is not supported or if there is no webVR device
  14495. * @see http://doc.babylonjs.com/how_to/webvr_camera
  14496. */
  14497. enableVR(): void;
  14498. /** @hidden */ private _onVRFullScreenTriggered(): void;
  14499. }
  14500. }
  14501. declare module BABYLON {
  14502. /**
  14503. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  14504. * IMPORTANT!! The data is right-hand data.
  14505. * @export
  14506. * @interface DevicePose
  14507. */
  14508. export interface DevicePose {
  14509. /**
  14510. * The position of the device, values in array are [x,y,z].
  14511. */
  14512. readonly position: Nullable<Float32Array>;
  14513. /**
  14514. * The linearVelocity of the device, values in array are [x,y,z].
  14515. */
  14516. readonly linearVelocity: Nullable<Float32Array>;
  14517. /**
  14518. * The linearAcceleration of the device, values in array are [x,y,z].
  14519. */
  14520. readonly linearAcceleration: Nullable<Float32Array>;
  14521. /**
  14522. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  14523. */
  14524. readonly orientation: Nullable<Float32Array>;
  14525. /**
  14526. * The angularVelocity of the device, values in array are [x,y,z].
  14527. */
  14528. readonly angularVelocity: Nullable<Float32Array>;
  14529. /**
  14530. * The angularAcceleration of the device, values in array are [x,y,z].
  14531. */
  14532. readonly angularAcceleration: Nullable<Float32Array>;
  14533. }
  14534. /**
  14535. * Interface representing a pose controlled object in Babylon.
  14536. * A pose controlled object has both regular pose values as well as pose values
  14537. * from an external device such as a VR head mounted display
  14538. */
  14539. export interface PoseControlled {
  14540. /**
  14541. * The position of the object in babylon space.
  14542. */
  14543. position: Vector3;
  14544. /**
  14545. * The rotation quaternion of the object in babylon space.
  14546. */
  14547. rotationQuaternion: Quaternion;
  14548. /**
  14549. * The position of the device in babylon space.
  14550. */
  14551. devicePosition?: Vector3;
  14552. /**
  14553. * The rotation quaternion of the device in babylon space.
  14554. */
  14555. deviceRotationQuaternion: Quaternion;
  14556. /**
  14557. * The raw pose coming from the device.
  14558. */
  14559. rawPose: Nullable<DevicePose>;
  14560. /**
  14561. * The scale of the device to be used when translating from device space to babylon space.
  14562. */
  14563. deviceScaleFactor: number;
  14564. /**
  14565. * Updates the poseControlled values based on the input device pose.
  14566. * @param poseData the pose data to update the object with
  14567. */
  14568. updateFromDevice(poseData: DevicePose): void;
  14569. }
  14570. /**
  14571. * Set of options to customize the webVRCamera
  14572. */
  14573. export interface WebVROptions {
  14574. /**
  14575. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  14576. */
  14577. trackPosition?: boolean;
  14578. /**
  14579. * Sets the scale of the vrDevice in babylon space. (default: 1)
  14580. */
  14581. positionScale?: number;
  14582. /**
  14583. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  14584. */
  14585. displayName?: string;
  14586. /**
  14587. * Should the native controller meshes be initialized. (default: true)
  14588. */
  14589. controllerMeshes?: boolean;
  14590. /**
  14591. * Creating a default HemiLight only on controllers. (default: true)
  14592. */
  14593. defaultLightingOnControllers?: boolean;
  14594. /**
  14595. * If you don't want to use the default VR button of the helper. (default: false)
  14596. */
  14597. useCustomVRButton?: boolean;
  14598. /**
  14599. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  14600. */
  14601. customVRButton?: HTMLButtonElement;
  14602. /**
  14603. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  14604. */
  14605. rayLength?: number;
  14606. /**
  14607. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  14608. */
  14609. defaultHeight?: number;
  14610. /**
  14611. * If multiview should be used if availible (default: false)
  14612. */
  14613. useMultiview?: boolean;
  14614. }
  14615. /**
  14616. * This represents a WebVR camera.
  14617. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  14618. * @example http://doc.babylonjs.com/how_to/webvr_camera
  14619. */
  14620. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  14621. private webVROptions;
  14622. /**
  14623. * @hidden
  14624. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  14625. */ private _vrDevice: any;
  14626. /**
  14627. * The rawPose of the vrDevice.
  14628. */
  14629. rawPose: Nullable<DevicePose>;
  14630. private _onVREnabled;
  14631. private _specsVersion;
  14632. private _attached;
  14633. private _frameData;
  14634. protected _descendants: Array<Node>;
  14635. private _deviceRoomPosition;
  14636. /** @hidden */ private _deviceRoomRotationQuaternion: Quaternion;
  14637. private _standingMatrix;
  14638. /**
  14639. * Represents device position in babylon space.
  14640. */
  14641. devicePosition: Vector3;
  14642. /**
  14643. * Represents device rotation in babylon space.
  14644. */
  14645. deviceRotationQuaternion: Quaternion;
  14646. /**
  14647. * The scale of the device to be used when translating from device space to babylon space.
  14648. */
  14649. deviceScaleFactor: number;
  14650. private _deviceToWorld;
  14651. private _worldToDevice;
  14652. /**
  14653. * References to the webVR controllers for the vrDevice.
  14654. */
  14655. controllers: Array<WebVRController>;
  14656. /**
  14657. * Emits an event when a controller is attached.
  14658. */
  14659. onControllersAttachedObservable: Observable<WebVRController[]>;
  14660. /**
  14661. * Emits an event when a controller's mesh has been loaded;
  14662. */
  14663. onControllerMeshLoadedObservable: Observable<WebVRController>;
  14664. /**
  14665. * Emits an event when the HMD's pose has been updated.
  14666. */
  14667. onPoseUpdatedFromDeviceObservable: Observable<any>;
  14668. private _poseSet;
  14669. /**
  14670. * If the rig cameras be used as parent instead of this camera.
  14671. */
  14672. rigParenting: boolean;
  14673. private _lightOnControllers;
  14674. private _defaultHeight?;
  14675. /**
  14676. * Instantiates a WebVRFreeCamera.
  14677. * @param name The name of the WebVRFreeCamera
  14678. * @param position The starting anchor position for the camera
  14679. * @param scene The scene the camera belongs to
  14680. * @param webVROptions a set of customizable options for the webVRCamera
  14681. */
  14682. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  14683. /**
  14684. * Gets the device distance from the ground in meters.
  14685. * @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.
  14686. */
  14687. deviceDistanceToRoomGround(): number;
  14688. /**
  14689. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14690. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  14691. */
  14692. useStandingMatrix(callback?: (bool: boolean) => void): void;
  14693. /**
  14694. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  14695. * @returns A promise with a boolean set to if the standing matrix is supported.
  14696. */
  14697. useStandingMatrixAsync(): Promise<boolean>;
  14698. /**
  14699. * Disposes the camera
  14700. */
  14701. dispose(): void;
  14702. /**
  14703. * Gets a vrController by name.
  14704. * @param name The name of the controller to retreive
  14705. * @returns the controller matching the name specified or null if not found
  14706. */
  14707. getControllerByName(name: string): Nullable<WebVRController>;
  14708. private _leftController;
  14709. /**
  14710. * The controller corresponding to the users left hand.
  14711. */
  14712. readonly leftController: Nullable<WebVRController>;
  14713. private _rightController;
  14714. /**
  14715. * The controller corresponding to the users right hand.
  14716. */
  14717. readonly rightController: Nullable<WebVRController>;
  14718. /**
  14719. * Casts a ray forward from the vrCamera's gaze.
  14720. * @param length Length of the ray (default: 100)
  14721. * @returns the ray corresponding to the gaze
  14722. */
  14723. getForwardRay(length?: number): Ray;
  14724. /**
  14725. * @hidden
  14726. * Updates the camera based on device's frame data
  14727. */ private _checkInputs(): void;
  14728. /**
  14729. * Updates the poseControlled values based on the input device pose.
  14730. * @param poseData Pose coming from the device
  14731. */
  14732. updateFromDevice(poseData: DevicePose): void;
  14733. private _htmlElementAttached;
  14734. private _detachIfAttached;
  14735. /**
  14736. * WebVR's attach control will start broadcasting frames to the device.
  14737. * Note that in certain browsers (chrome for example) this function must be called
  14738. * within a user-interaction callback. Example:
  14739. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  14740. *
  14741. * @param element html element to attach the vrDevice to
  14742. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  14743. */
  14744. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  14745. /**
  14746. * Detaches the camera from the html element and disables VR
  14747. *
  14748. * @param element html element to detach from
  14749. */
  14750. detachControl(element: HTMLElement): void;
  14751. /**
  14752. * @returns the name of this class
  14753. */
  14754. getClassName(): string;
  14755. /**
  14756. * Calls resetPose on the vrDisplay
  14757. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  14758. */
  14759. resetToCurrentRotation(): void;
  14760. /**
  14761. * @hidden
  14762. * Updates the rig cameras (left and right eye)
  14763. */ private _updateRigCameras(): void;
  14764. private _workingVector;
  14765. private _oneVector;
  14766. private _workingMatrix;
  14767. private updateCacheCalled;
  14768. private _correctPositionIfNotTrackPosition;
  14769. /**
  14770. * @hidden
  14771. * Updates the cached values of the camera
  14772. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  14773. */ private _updateCache(ignoreParentClass?: boolean): void;
  14774. /**
  14775. * @hidden
  14776. * Get current device position in babylon world
  14777. */ private _computeDevicePosition(): void;
  14778. /**
  14779. * Updates the current device position and rotation in the babylon world
  14780. */
  14781. update(): void;
  14782. /**
  14783. * @hidden
  14784. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  14785. * @returns an identity matrix
  14786. */ private _getViewMatrix(): Matrix;
  14787. private _tmpMatrix;
  14788. /**
  14789. * This function is called by the two RIG cameras.
  14790. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  14791. * @hidden
  14792. */ private _getWebVRViewMatrix(): Matrix;
  14793. /** @hidden */ private _getWebVRProjectionMatrix(): Matrix;
  14794. private _onGamepadConnectedObserver;
  14795. private _onGamepadDisconnectedObserver;
  14796. private _updateCacheWhenTrackingDisabledObserver;
  14797. /**
  14798. * Initializes the controllers and their meshes
  14799. */
  14800. initControllers(): void;
  14801. }
  14802. }
  14803. declare module BABYLON {
  14804. /**
  14805. * Size options for a post process
  14806. */
  14807. export type PostProcessOptions = {
  14808. width: number;
  14809. height: number;
  14810. };
  14811. /**
  14812. * PostProcess can be used to apply a shader to a texture after it has been rendered
  14813. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  14814. */
  14815. export class PostProcess {
  14816. /** Name of the PostProcess. */
  14817. name: string;
  14818. /**
  14819. * Gets or sets the unique id of the post process
  14820. */
  14821. uniqueId: number;
  14822. /**
  14823. * Width of the texture to apply the post process on
  14824. */
  14825. width: number;
  14826. /**
  14827. * Height of the texture to apply the post process on
  14828. */
  14829. height: number;
  14830. /**
  14831. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  14832. * @hidden
  14833. */ private _outputTexture: Nullable<InternalTexture>;
  14834. /**
  14835. * Sampling mode used by the shader
  14836. * See https://doc.babylonjs.com/classes/3.1/texture
  14837. */
  14838. renderTargetSamplingMode: number;
  14839. /**
  14840. * Clear color to use when screen clearing
  14841. */
  14842. clearColor: Color4;
  14843. /**
  14844. * If the buffer needs to be cleared before applying the post process. (default: true)
  14845. * Should be set to false if shader will overwrite all previous pixels.
  14846. */
  14847. autoClear: boolean;
  14848. /**
  14849. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  14850. */
  14851. alphaMode: number;
  14852. /**
  14853. * Sets the setAlphaBlendConstants of the babylon engine
  14854. */
  14855. alphaConstants: Color4;
  14856. /**
  14857. * Animations to be used for the post processing
  14858. */
  14859. animations: Animation[];
  14860. /**
  14861. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  14862. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  14863. */
  14864. enablePixelPerfectMode: boolean;
  14865. /**
  14866. * Force the postprocess to be applied without taking in account viewport
  14867. */
  14868. forceFullscreenViewport: boolean;
  14869. /**
  14870. * List of inspectable custom properties (used by the Inspector)
  14871. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  14872. */
  14873. inspectableCustomProperties: IInspectable[];
  14874. /**
  14875. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  14876. *
  14877. * | Value | Type | Description |
  14878. * | ----- | ----------------------------------- | ----------- |
  14879. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  14880. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  14881. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  14882. *
  14883. */
  14884. scaleMode: number;
  14885. /**
  14886. * Force textures to be a power of two (default: false)
  14887. */
  14888. alwaysForcePOT: boolean;
  14889. private _samples;
  14890. /**
  14891. * Number of sample textures (default: 1)
  14892. */
  14893. samples: number;
  14894. /**
  14895. * Modify the scale of the post process to be the same as the viewport (default: false)
  14896. */
  14897. adaptScaleToCurrentViewport: boolean;
  14898. private _camera;
  14899. private _scene;
  14900. private _engine;
  14901. private _options;
  14902. private _reusable;
  14903. private _textureType;
  14904. /**
  14905. * Smart array of input and output textures for the post process.
  14906. * @hidden
  14907. */ private _textures: SmartArray<InternalTexture>;
  14908. /**
  14909. * The index in _textures that corresponds to the output texture.
  14910. * @hidden
  14911. */ private _currentRenderTextureInd: number;
  14912. private _effect;
  14913. private _samplers;
  14914. private _fragmentUrl;
  14915. private _vertexUrl;
  14916. private _parameters;
  14917. private _scaleRatio;
  14918. protected _indexParameters: any;
  14919. private _shareOutputWithPostProcess;
  14920. private _texelSize;
  14921. private _forcedOutputTexture;
  14922. /**
  14923. * Returns the fragment url or shader name used in the post process.
  14924. * @returns the fragment url or name in the shader store.
  14925. */
  14926. getEffectName(): string;
  14927. /**
  14928. * An event triggered when the postprocess is activated.
  14929. */
  14930. onActivateObservable: Observable<Camera>;
  14931. private _onActivateObserver;
  14932. /**
  14933. * A function that is added to the onActivateObservable
  14934. */
  14935. onActivate: Nullable<(camera: Camera) => void>;
  14936. /**
  14937. * An event triggered when the postprocess changes its size.
  14938. */
  14939. onSizeChangedObservable: Observable<PostProcess>;
  14940. private _onSizeChangedObserver;
  14941. /**
  14942. * A function that is added to the onSizeChangedObservable
  14943. */
  14944. onSizeChanged: (postProcess: PostProcess) => void;
  14945. /**
  14946. * An event triggered when the postprocess applies its effect.
  14947. */
  14948. onApplyObservable: Observable<Effect>;
  14949. private _onApplyObserver;
  14950. /**
  14951. * A function that is added to the onApplyObservable
  14952. */
  14953. onApply: (effect: Effect) => void;
  14954. /**
  14955. * An event triggered before rendering the postprocess
  14956. */
  14957. onBeforeRenderObservable: Observable<Effect>;
  14958. private _onBeforeRenderObserver;
  14959. /**
  14960. * A function that is added to the onBeforeRenderObservable
  14961. */
  14962. onBeforeRender: (effect: Effect) => void;
  14963. /**
  14964. * An event triggered after rendering the postprocess
  14965. */
  14966. onAfterRenderObservable: Observable<Effect>;
  14967. private _onAfterRenderObserver;
  14968. /**
  14969. * A function that is added to the onAfterRenderObservable
  14970. */
  14971. onAfterRender: (efect: Effect) => void;
  14972. /**
  14973. * 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
  14974. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  14975. */
  14976. inputTexture: InternalTexture;
  14977. /**
  14978. * Gets the camera which post process is applied to.
  14979. * @returns The camera the post process is applied to.
  14980. */
  14981. getCamera(): Camera;
  14982. /**
  14983. * Gets the texel size of the postprocess.
  14984. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  14985. */
  14986. readonly texelSize: Vector2;
  14987. /**
  14988. * Creates a new instance PostProcess
  14989. * @param name The name of the PostProcess.
  14990. * @param fragmentUrl The url of the fragment shader to be used.
  14991. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  14992. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  14993. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  14994. * @param camera The camera to apply the render pass to.
  14995. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  14996. * @param engine The engine which the post process will be applied. (default: current engine)
  14997. * @param reusable If the post process can be reused on the same frame. (default: false)
  14998. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  14999. * @param textureType Type of textures used when performing the post process. (default: 0)
  15000. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15001. * @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
  15002. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15003. */
  15004. constructor(
  15005. /** Name of the PostProcess. */
  15006. 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);
  15007. /**
  15008. * Gets a string idenfifying the name of the class
  15009. * @returns "PostProcess" string
  15010. */
  15011. getClassName(): string;
  15012. /**
  15013. * Gets the engine which this post process belongs to.
  15014. * @returns The engine the post process was enabled with.
  15015. */
  15016. getEngine(): Engine;
  15017. /**
  15018. * The effect that is created when initializing the post process.
  15019. * @returns The created effect corresponding the the postprocess.
  15020. */
  15021. getEffect(): Effect;
  15022. /**
  15023. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15024. * @param postProcess The post process to share the output with.
  15025. * @returns This post process.
  15026. */
  15027. shareOutputWith(postProcess: PostProcess): PostProcess;
  15028. /**
  15029. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15030. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15031. */
  15032. useOwnOutput(): void;
  15033. /**
  15034. * Updates the effect with the current post process compile time values and recompiles the shader.
  15035. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15036. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15037. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15038. * @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
  15039. * @param onCompiled Called when the shader has been compiled.
  15040. * @param onError Called if there is an error when compiling a shader.
  15041. */
  15042. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15043. /**
  15044. * The post process is reusable if it can be used multiple times within one frame.
  15045. * @returns If the post process is reusable
  15046. */
  15047. isReusable(): boolean;
  15048. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15049. markTextureDirty(): void;
  15050. /**
  15051. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15052. * 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.
  15053. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15054. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15055. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15056. * @returns The target texture that was bound to be written to.
  15057. */
  15058. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15059. /**
  15060. * If the post process is supported.
  15061. */
  15062. readonly isSupported: boolean;
  15063. /**
  15064. * The aspect ratio of the output texture.
  15065. */
  15066. readonly aspectRatio: number;
  15067. /**
  15068. * Get a value indicating if the post-process is ready to be used
  15069. * @returns true if the post-process is ready (shader is compiled)
  15070. */
  15071. isReady(): boolean;
  15072. /**
  15073. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15074. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15075. */
  15076. apply(): Nullable<Effect>;
  15077. private _disposeTextures;
  15078. /**
  15079. * Disposes the post process.
  15080. * @param camera The camera to dispose the post process on.
  15081. */
  15082. dispose(camera?: Camera): void;
  15083. }
  15084. }
  15085. declare module BABYLON {
  15086. /** @hidden */
  15087. export var kernelBlurVaryingDeclaration: {
  15088. name: string;
  15089. shader: string;
  15090. };
  15091. }
  15092. declare module BABYLON {
  15093. /** @hidden */
  15094. export var kernelBlurFragment: {
  15095. name: string;
  15096. shader: string;
  15097. };
  15098. }
  15099. declare module BABYLON {
  15100. /** @hidden */
  15101. export var kernelBlurFragment2: {
  15102. name: string;
  15103. shader: string;
  15104. };
  15105. }
  15106. declare module BABYLON {
  15107. /** @hidden */
  15108. export var kernelBlurPixelShader: {
  15109. name: string;
  15110. shader: string;
  15111. };
  15112. }
  15113. declare module BABYLON {
  15114. /** @hidden */
  15115. export var kernelBlurVertex: {
  15116. name: string;
  15117. shader: string;
  15118. };
  15119. }
  15120. declare module BABYLON {
  15121. /** @hidden */
  15122. export var kernelBlurVertexShader: {
  15123. name: string;
  15124. shader: string;
  15125. };
  15126. }
  15127. declare module BABYLON {
  15128. /**
  15129. * The Blur Post Process which blurs an image based on a kernel and direction.
  15130. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15131. */
  15132. export class BlurPostProcess extends PostProcess {
  15133. /** The direction in which to blur the image. */
  15134. direction: Vector2;
  15135. private blockCompilation;
  15136. protected _kernel: number;
  15137. protected _idealKernel: number;
  15138. protected _packedFloat: boolean;
  15139. private _staticDefines;
  15140. /**
  15141. * Sets the length in pixels of the blur sample region
  15142. */
  15143. /**
  15144. * Gets the length in pixels of the blur sample region
  15145. */
  15146. kernel: number;
  15147. /**
  15148. * Sets wether or not the blur needs to unpack/repack floats
  15149. */
  15150. /**
  15151. * Gets wether or not the blur is unpacking/repacking floats
  15152. */
  15153. packedFloat: boolean;
  15154. /**
  15155. * Creates a new instance BlurPostProcess
  15156. * @param name The name of the effect.
  15157. * @param direction The direction in which to blur the image.
  15158. * @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.
  15159. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15160. * @param camera The camera to apply the render pass to.
  15161. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15162. * @param engine The engine which the post process will be applied. (default: current engine)
  15163. * @param reusable If the post process can be reused on the same frame. (default: false)
  15164. * @param textureType Type of textures used when performing the post process. (default: 0)
  15165. * @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)
  15166. */
  15167. constructor(name: string,
  15168. /** The direction in which to blur the image. */
  15169. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15170. /**
  15171. * Updates the effect with the current post process compile time values and recompiles the shader.
  15172. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15173. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15174. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15175. * @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
  15176. * @param onCompiled Called when the shader has been compiled.
  15177. * @param onError Called if there is an error when compiling a shader.
  15178. */
  15179. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15180. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15181. /**
  15182. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15183. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15184. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15185. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15186. * The gaps between physical kernels are compensated for in the weighting of the samples
  15187. * @param idealKernel Ideal blur kernel.
  15188. * @return Nearest best kernel.
  15189. */
  15190. protected _nearestBestKernel(idealKernel: number): number;
  15191. /**
  15192. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15193. * @param x The point on the Gaussian distribution to sample.
  15194. * @return the value of the Gaussian function at x.
  15195. */
  15196. protected _gaussianWeight(x: number): number;
  15197. /**
  15198. * Generates a string that can be used as a floating point number in GLSL.
  15199. * @param x Value to print.
  15200. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15201. * @return GLSL float string.
  15202. */
  15203. protected _glslFloat(x: number, decimalFigures?: number): string;
  15204. }
  15205. }
  15206. declare module BABYLON {
  15207. /**
  15208. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15209. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15210. * You can then easily use it as a reflectionTexture on a flat surface.
  15211. * In case the surface is not a plane, please consider relying on reflection probes.
  15212. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15213. */
  15214. export class MirrorTexture extends RenderTargetTexture {
  15215. private scene;
  15216. /**
  15217. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  15218. * 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.
  15219. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15220. */
  15221. mirrorPlane: Plane;
  15222. /**
  15223. * Define the blur ratio used to blur the reflection if needed.
  15224. */
  15225. blurRatio: number;
  15226. /**
  15227. * Define the adaptive blur kernel used to blur the reflection if needed.
  15228. * This will autocompute the closest best match for the `blurKernel`
  15229. */
  15230. adaptiveBlurKernel: number;
  15231. /**
  15232. * Define the blur kernel used to blur the reflection if needed.
  15233. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15234. */
  15235. blurKernel: number;
  15236. /**
  15237. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  15238. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15239. */
  15240. blurKernelX: number;
  15241. /**
  15242. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  15243. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  15244. */
  15245. blurKernelY: number;
  15246. private _autoComputeBlurKernel;
  15247. protected _onRatioRescale(): void;
  15248. private _updateGammaSpace;
  15249. private _imageProcessingConfigChangeObserver;
  15250. private _transformMatrix;
  15251. private _mirrorMatrix;
  15252. private _savedViewMatrix;
  15253. private _blurX;
  15254. private _blurY;
  15255. private _adaptiveBlurKernel;
  15256. private _blurKernelX;
  15257. private _blurKernelY;
  15258. private _blurRatio;
  15259. /**
  15260. * Instantiates a Mirror Texture.
  15261. * Mirror texture can be used to simulate the view from a mirror in a scene.
  15262. * It will dynamically be rendered every frame to adapt to the camera point of view.
  15263. * You can then easily use it as a reflectionTexture on a flat surface.
  15264. * In case the surface is not a plane, please consider relying on reflection probes.
  15265. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  15266. * @param name
  15267. * @param size
  15268. * @param scene
  15269. * @param generateMipMaps
  15270. * @param type
  15271. * @param samplingMode
  15272. * @param generateDepthBuffer
  15273. */
  15274. constructor(name: string, size: number | {
  15275. width: number;
  15276. height: number;
  15277. } | {
  15278. ratio: number;
  15279. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  15280. private _preparePostProcesses;
  15281. /**
  15282. * Clone the mirror texture.
  15283. * @returns the cloned texture
  15284. */
  15285. clone(): MirrorTexture;
  15286. /**
  15287. * Serialize the texture to a JSON representation you could use in Parse later on
  15288. * @returns the serialized JSON representation
  15289. */
  15290. serialize(): any;
  15291. /**
  15292. * Dispose the texture and release its associated resources.
  15293. */
  15294. dispose(): void;
  15295. }
  15296. }
  15297. declare module BABYLON {
  15298. /**
  15299. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15300. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15301. */
  15302. export class Texture extends BaseTexture {
  15303. /** @hidden */ private static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  15304. /** @hidden */ private static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  15305. /** @hidden */ private static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  15306. /** nearest is mag = nearest and min = nearest and mip = linear */
  15307. static readonly NEAREST_SAMPLINGMODE: number;
  15308. /** nearest is mag = nearest and min = nearest and mip = linear */
  15309. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  15310. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15311. static readonly BILINEAR_SAMPLINGMODE: number;
  15312. /** Bilinear is mag = linear and min = linear and mip = nearest */
  15313. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  15314. /** Trilinear is mag = linear and min = linear and mip = linear */
  15315. static readonly TRILINEAR_SAMPLINGMODE: number;
  15316. /** Trilinear is mag = linear and min = linear and mip = linear */
  15317. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  15318. /** mag = nearest and min = nearest and mip = nearest */
  15319. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  15320. /** mag = nearest and min = linear and mip = nearest */
  15321. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  15322. /** mag = nearest and min = linear and mip = linear */
  15323. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  15324. /** mag = nearest and min = linear and mip = none */
  15325. static readonly NEAREST_LINEAR: number;
  15326. /** mag = nearest and min = nearest and mip = none */
  15327. static readonly NEAREST_NEAREST: number;
  15328. /** mag = linear and min = nearest and mip = nearest */
  15329. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  15330. /** mag = linear and min = nearest and mip = linear */
  15331. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  15332. /** mag = linear and min = linear and mip = none */
  15333. static readonly LINEAR_LINEAR: number;
  15334. /** mag = linear and min = nearest and mip = none */
  15335. static readonly LINEAR_NEAREST: number;
  15336. /** Explicit coordinates mode */
  15337. static readonly EXPLICIT_MODE: number;
  15338. /** Spherical coordinates mode */
  15339. static readonly SPHERICAL_MODE: number;
  15340. /** Planar coordinates mode */
  15341. static readonly PLANAR_MODE: number;
  15342. /** Cubic coordinates mode */
  15343. static readonly CUBIC_MODE: number;
  15344. /** Projection coordinates mode */
  15345. static readonly PROJECTION_MODE: number;
  15346. /** Inverse Cubic coordinates mode */
  15347. static readonly SKYBOX_MODE: number;
  15348. /** Inverse Cubic coordinates mode */
  15349. static readonly INVCUBIC_MODE: number;
  15350. /** Equirectangular coordinates mode */
  15351. static readonly EQUIRECTANGULAR_MODE: number;
  15352. /** Equirectangular Fixed coordinates mode */
  15353. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  15354. /** Equirectangular Fixed Mirrored coordinates mode */
  15355. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  15356. /** Texture is not repeating outside of 0..1 UVs */
  15357. static readonly CLAMP_ADDRESSMODE: number;
  15358. /** Texture is repeating outside of 0..1 UVs */
  15359. static readonly WRAP_ADDRESSMODE: number;
  15360. /** Texture is repeating and mirrored */
  15361. static readonly MIRROR_ADDRESSMODE: number;
  15362. /**
  15363. * 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
  15364. */
  15365. static UseSerializedUrlIfAny: boolean;
  15366. /**
  15367. * Define the url of the texture.
  15368. */
  15369. url: Nullable<string>;
  15370. /**
  15371. * Define an offset on the texture to offset the u coordinates of the UVs
  15372. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15373. */
  15374. uOffset: number;
  15375. /**
  15376. * Define an offset on the texture to offset the v coordinates of the UVs
  15377. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  15378. */
  15379. vOffset: number;
  15380. /**
  15381. * Define an offset on the texture to scale the u coordinates of the UVs
  15382. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15383. */
  15384. uScale: number;
  15385. /**
  15386. * Define an offset on the texture to scale the v coordinates of the UVs
  15387. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  15388. */
  15389. vScale: number;
  15390. /**
  15391. * Define an offset on the texture to rotate around the u coordinates of the UVs
  15392. * @see http://doc.babylonjs.com/how_to/more_materials
  15393. */
  15394. uAng: number;
  15395. /**
  15396. * Define an offset on the texture to rotate around the v coordinates of the UVs
  15397. * @see http://doc.babylonjs.com/how_to/more_materials
  15398. */
  15399. vAng: number;
  15400. /**
  15401. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  15402. * @see http://doc.babylonjs.com/how_to/more_materials
  15403. */
  15404. wAng: number;
  15405. /**
  15406. * Defines the center of rotation (U)
  15407. */
  15408. uRotationCenter: number;
  15409. /**
  15410. * Defines the center of rotation (V)
  15411. */
  15412. vRotationCenter: number;
  15413. /**
  15414. * Defines the center of rotation (W)
  15415. */
  15416. wRotationCenter: number;
  15417. /**
  15418. * Are mip maps generated for this texture or not.
  15419. */
  15420. readonly noMipmap: boolean;
  15421. /**
  15422. * List of inspectable custom properties (used by the Inspector)
  15423. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15424. */
  15425. inspectableCustomProperties: Nullable<IInspectable[]>;
  15426. private _noMipmap;
  15427. /** @hidden */ private _invertY: boolean;
  15428. private _rowGenerationMatrix;
  15429. private _cachedTextureMatrix;
  15430. private _projectionModeMatrix;
  15431. private _t0;
  15432. private _t1;
  15433. private _t2;
  15434. private _cachedUOffset;
  15435. private _cachedVOffset;
  15436. private _cachedUScale;
  15437. private _cachedVScale;
  15438. private _cachedUAng;
  15439. private _cachedVAng;
  15440. private _cachedWAng;
  15441. private _cachedProjectionMatrixId;
  15442. private _cachedCoordinatesMode;
  15443. /** @hidden */
  15444. protected _initialSamplingMode: number;
  15445. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  15446. private _deleteBuffer;
  15447. protected _format: Nullable<number>;
  15448. private _delayedOnLoad;
  15449. private _delayedOnError;
  15450. /**
  15451. * Observable triggered once the texture has been loaded.
  15452. */
  15453. onLoadObservable: Observable<Texture>;
  15454. protected _isBlocking: boolean;
  15455. /**
  15456. * Is the texture preventing material to render while loading.
  15457. * If false, a default texture will be used instead of the loading one during the preparation step.
  15458. */
  15459. isBlocking: boolean;
  15460. /**
  15461. * Get the current sampling mode associated with the texture.
  15462. */
  15463. readonly samplingMode: number;
  15464. /**
  15465. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  15466. */
  15467. readonly invertY: boolean;
  15468. /**
  15469. * Instantiates a new texture.
  15470. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  15471. * @see http://doc.babylonjs.com/babylon101/materials#texture
  15472. * @param url define the url of the picture to load as a texture
  15473. * @param scene define the scene or engine the texture will belong to
  15474. * @param noMipmap define if the texture will require mip maps or not
  15475. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15476. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15477. * @param onLoad define a callback triggered when the texture has been loaded
  15478. * @param onError define a callback triggered when an error occurred during the loading session
  15479. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15480. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15481. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15482. */
  15483. 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 | HTMLImageElement | Blob>, deleteBuffer?: boolean, format?: number);
  15484. /**
  15485. * Update the url (and optional buffer) of this texture if url was null during construction.
  15486. * @param url the url of the texture
  15487. * @param buffer the buffer of the texture (defaults to null)
  15488. * @param onLoad callback called when the texture is loaded (defaults to null)
  15489. */
  15490. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  15491. /**
  15492. * Finish the loading sequence of a texture flagged as delayed load.
  15493. * @hidden
  15494. */
  15495. delayLoad(): void;
  15496. private _prepareRowForTextureGeneration;
  15497. /**
  15498. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  15499. * @returns the transform matrix of the texture.
  15500. */
  15501. getTextureMatrix(): Matrix;
  15502. /**
  15503. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  15504. * @returns The reflection texture transform
  15505. */
  15506. getReflectionTextureMatrix(): Matrix;
  15507. /**
  15508. * Clones the texture.
  15509. * @returns the cloned texture
  15510. */
  15511. clone(): Texture;
  15512. /**
  15513. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  15514. * @returns The JSON representation of the texture
  15515. */
  15516. serialize(): any;
  15517. /**
  15518. * Get the current class name of the texture useful for serialization or dynamic coding.
  15519. * @returns "Texture"
  15520. */
  15521. getClassName(): string;
  15522. /**
  15523. * Dispose the texture and release its associated resources.
  15524. */
  15525. dispose(): void;
  15526. /**
  15527. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  15528. * @param parsedTexture Define the JSON representation of the texture
  15529. * @param scene Define the scene the parsed texture should be instantiated in
  15530. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  15531. * @returns The parsed texture if successful
  15532. */
  15533. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  15534. /**
  15535. * Creates a texture from its base 64 representation.
  15536. * @param data Define the base64 payload without the data: prefix
  15537. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15538. * @param scene Define the scene the texture should belong to
  15539. * @param noMipmap Forces the texture to not create mip map information if true
  15540. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15541. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15542. * @param onLoad define a callback triggered when the texture has been loaded
  15543. * @param onError define a callback triggered when an error occurred during the loading session
  15544. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15545. * @returns the created texture
  15546. */
  15547. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  15548. /**
  15549. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  15550. * @param data Define the base64 payload without the data: prefix
  15551. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  15552. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  15553. * @param scene Define the scene the texture should belong to
  15554. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  15555. * @param noMipmap Forces the texture to not create mip map information if true
  15556. * @param invertY define if the texture needs to be inverted on the y axis during loading
  15557. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  15558. * @param onLoad define a callback triggered when the texture has been loaded
  15559. * @param onError define a callback triggered when an error occurred during the loading session
  15560. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  15561. * @returns the created texture
  15562. */
  15563. 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;
  15564. }
  15565. }
  15566. declare module BABYLON {
  15567. /**
  15568. * PostProcessManager is used to manage one or more post processes or post process pipelines
  15569. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15570. */
  15571. export class PostProcessManager {
  15572. private _scene;
  15573. private _indexBuffer;
  15574. private _vertexBuffers;
  15575. /**
  15576. * Creates a new instance PostProcess
  15577. * @param scene The scene that the post process is associated with.
  15578. */
  15579. constructor(scene: Scene);
  15580. private _prepareBuffers;
  15581. private _buildIndexBuffer;
  15582. /**
  15583. * Rebuilds the vertex buffers of the manager.
  15584. * @hidden
  15585. */ private _rebuild(): void;
  15586. /**
  15587. * Prepares a frame to be run through a post process.
  15588. * @param sourceTexture The input texture to the post procesess. (default: null)
  15589. * @param postProcesses An array of post processes to be run. (default: null)
  15590. * @returns True if the post processes were able to be run.
  15591. * @hidden
  15592. */ private _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  15593. /**
  15594. * Manually render a set of post processes to a texture.
  15595. * @param postProcesses An array of post processes to be run.
  15596. * @param targetTexture The target texture to render to.
  15597. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  15598. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  15599. * @param lodLevel defines which lod of the texture to render to
  15600. */
  15601. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  15602. /**
  15603. * Finalize the result of the output of the postprocesses.
  15604. * @param doNotPresent If true the result will not be displayed to the screen.
  15605. * @param targetTexture The target texture to render to.
  15606. * @param faceIndex The index of the face to bind the target texture to.
  15607. * @param postProcesses The array of post processes to render.
  15608. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  15609. * @hidden
  15610. */ private _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  15611. /**
  15612. * Disposes of the post process manager.
  15613. */
  15614. dispose(): void;
  15615. }
  15616. }
  15617. declare module BABYLON {
  15618. /** Interface used by value gradients (color, factor, ...) */
  15619. export interface IValueGradient {
  15620. /**
  15621. * Gets or sets the gradient value (between 0 and 1)
  15622. */
  15623. gradient: number;
  15624. }
  15625. /** Class used to store color4 gradient */
  15626. export class ColorGradient implements IValueGradient {
  15627. /**
  15628. * Gets or sets the gradient value (between 0 and 1)
  15629. */
  15630. gradient: number;
  15631. /**
  15632. * Gets or sets first associated color
  15633. */
  15634. color1: Color4;
  15635. /**
  15636. * Gets or sets second associated color
  15637. */
  15638. color2?: Color4;
  15639. /**
  15640. * Will get a color picked randomly between color1 and color2.
  15641. * If color2 is undefined then color1 will be used
  15642. * @param result defines the target Color4 to store the result in
  15643. */
  15644. getColorToRef(result: Color4): void;
  15645. }
  15646. /** Class used to store color 3 gradient */
  15647. export class Color3Gradient implements IValueGradient {
  15648. /**
  15649. * Gets or sets the gradient value (between 0 and 1)
  15650. */
  15651. gradient: number;
  15652. /**
  15653. * Gets or sets the associated color
  15654. */
  15655. color: Color3;
  15656. }
  15657. /** Class used to store factor gradient */
  15658. export class FactorGradient implements IValueGradient {
  15659. /**
  15660. * Gets or sets the gradient value (between 0 and 1)
  15661. */
  15662. gradient: number;
  15663. /**
  15664. * Gets or sets first associated factor
  15665. */
  15666. factor1: number;
  15667. /**
  15668. * Gets or sets second associated factor
  15669. */
  15670. factor2?: number;
  15671. /**
  15672. * Will get a number picked randomly between factor1 and factor2.
  15673. * If factor2 is undefined then factor1 will be used
  15674. * @returns the picked number
  15675. */
  15676. getFactor(): number;
  15677. }
  15678. /**
  15679. * Helper used to simplify some generic gradient tasks
  15680. */
  15681. export class GradientHelper {
  15682. /**
  15683. * Gets the current gradient from an array of IValueGradient
  15684. * @param ratio defines the current ratio to get
  15685. * @param gradients defines the array of IValueGradient
  15686. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  15687. */
  15688. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  15689. }
  15690. }
  15691. declare module BABYLON {
  15692. interface AbstractScene {
  15693. /**
  15694. * The list of procedural textures added to the scene
  15695. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15696. */
  15697. proceduralTextures: Array<ProceduralTexture>;
  15698. }
  15699. /**
  15700. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  15701. * in a given scene.
  15702. */
  15703. export class ProceduralTextureSceneComponent implements ISceneComponent {
  15704. /**
  15705. * The component name helpfull to identify the component in the list of scene components.
  15706. */
  15707. readonly name: string;
  15708. /**
  15709. * The scene the component belongs to.
  15710. */
  15711. scene: Scene;
  15712. /**
  15713. * Creates a new instance of the component for the given scene
  15714. * @param scene Defines the scene to register the component in
  15715. */
  15716. constructor(scene: Scene);
  15717. /**
  15718. * Registers the component in a given scene
  15719. */
  15720. register(): void;
  15721. /**
  15722. * Rebuilds the elements related to this component in case of
  15723. * context lost for instance.
  15724. */
  15725. rebuild(): void;
  15726. /**
  15727. * Disposes the component and the associated ressources.
  15728. */
  15729. dispose(): void;
  15730. private _beforeClear;
  15731. }
  15732. }
  15733. declare module BABYLON {
  15734. interface Engine {
  15735. /**
  15736. * Creates a new render target cube texture
  15737. * @param size defines the size of the texture
  15738. * @param options defines the options used to create the texture
  15739. * @returns a new render target cube texture stored in an InternalTexture
  15740. */
  15741. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  15742. }
  15743. }
  15744. declare module BABYLON {
  15745. /** @hidden */
  15746. export var proceduralVertexShader: {
  15747. name: string;
  15748. shader: string;
  15749. };
  15750. }
  15751. declare module BABYLON {
  15752. /**
  15753. * 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.
  15754. * This is the base class of any Procedural texture and contains most of the shareable code.
  15755. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15756. */
  15757. export class ProceduralTexture extends Texture {
  15758. isCube: boolean;
  15759. /**
  15760. * Define if the texture is enabled or not (disabled texture will not render)
  15761. */
  15762. isEnabled: boolean;
  15763. /**
  15764. * Define if the texture must be cleared before rendering (default is true)
  15765. */
  15766. autoClear: boolean;
  15767. /**
  15768. * Callback called when the texture is generated
  15769. */
  15770. onGenerated: () => void;
  15771. /**
  15772. * Event raised when the texture is generated
  15773. */
  15774. onGeneratedObservable: Observable<ProceduralTexture>;
  15775. /** @hidden */ private _generateMipMaps: boolean;
  15776. /** @hidden **/ private _effect: Effect;
  15777. /** @hidden */ private _textures: {
  15778. [key: string]: Texture;
  15779. };
  15780. private _size;
  15781. private _currentRefreshId;
  15782. private _refreshRate;
  15783. private _vertexBuffers;
  15784. private _indexBuffer;
  15785. private _uniforms;
  15786. private _samplers;
  15787. private _fragment;
  15788. private _floats;
  15789. private _ints;
  15790. private _floatsArrays;
  15791. private _colors3;
  15792. private _colors4;
  15793. private _vectors2;
  15794. private _vectors3;
  15795. private _matrices;
  15796. private _fallbackTexture;
  15797. private _fallbackTextureUsed;
  15798. private _engine;
  15799. private _cachedDefines;
  15800. private _contentUpdateId;
  15801. private _contentData;
  15802. /**
  15803. * Instantiates a new procedural texture.
  15804. * 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.
  15805. * This is the base class of any Procedural texture and contains most of the shareable code.
  15806. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  15807. * @param name Define the name of the texture
  15808. * @param size Define the size of the texture to create
  15809. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  15810. * @param scene Define the scene the texture belongs to
  15811. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  15812. * @param generateMipMaps Define if the texture should creates mip maps or not
  15813. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  15814. */
  15815. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  15816. /**
  15817. * The effect that is created when initializing the post process.
  15818. * @returns The created effect corresponding the the postprocess.
  15819. */
  15820. getEffect(): Effect;
  15821. /**
  15822. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  15823. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  15824. */
  15825. getContent(): Nullable<ArrayBufferView>;
  15826. private _createIndexBuffer;
  15827. /** @hidden */ private _rebuild(): void;
  15828. /**
  15829. * Resets the texture in order to recreate its associated resources.
  15830. * This can be called in case of context loss
  15831. */
  15832. reset(): void;
  15833. protected _getDefines(): string;
  15834. /**
  15835. * Is the texture ready to be used ? (rendered at least once)
  15836. * @returns true if ready, otherwise, false.
  15837. */
  15838. isReady(): boolean;
  15839. /**
  15840. * Resets the refresh counter of the texture and start bak from scratch.
  15841. * Could be useful to regenerate the texture if it is setup to render only once.
  15842. */
  15843. resetRefreshCounter(): void;
  15844. /**
  15845. * Set the fragment shader to use in order to render the texture.
  15846. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  15847. */
  15848. setFragment(fragment: any): void;
  15849. /**
  15850. * Define the refresh rate of the texture or the rendering frequency.
  15851. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  15852. */
  15853. refreshRate: number;
  15854. /** @hidden */ private _shouldRender(): boolean;
  15855. /**
  15856. * Get the size the texture is rendering at.
  15857. * @returns the size (texture is always squared)
  15858. */
  15859. getRenderSize(): number;
  15860. /**
  15861. * Resize the texture to new value.
  15862. * @param size Define the new size the texture should have
  15863. * @param generateMipMaps Define whether the new texture should create mip maps
  15864. */
  15865. resize(size: number, generateMipMaps: boolean): void;
  15866. private _checkUniform;
  15867. /**
  15868. * Set a texture in the shader program used to render.
  15869. * @param name Define the name of the uniform samplers as defined in the shader
  15870. * @param texture Define the texture to bind to this sampler
  15871. * @return the texture itself allowing "fluent" like uniform updates
  15872. */
  15873. setTexture(name: string, texture: Texture): ProceduralTexture;
  15874. /**
  15875. * Set a float in the shader.
  15876. * @param name Define the name of the uniform as defined in the shader
  15877. * @param value Define the value to give to the uniform
  15878. * @return the texture itself allowing "fluent" like uniform updates
  15879. */
  15880. setFloat(name: string, value: number): ProceduralTexture;
  15881. /**
  15882. * Set a int in the shader.
  15883. * @param name Define the name of the uniform as defined in the shader
  15884. * @param value Define the value to give to the uniform
  15885. * @return the texture itself allowing "fluent" like uniform updates
  15886. */
  15887. setInt(name: string, value: number): ProceduralTexture;
  15888. /**
  15889. * Set an array of floats in the shader.
  15890. * @param name Define the name of the uniform as defined in the shader
  15891. * @param value Define the value to give to the uniform
  15892. * @return the texture itself allowing "fluent" like uniform updates
  15893. */
  15894. setFloats(name: string, value: number[]): ProceduralTexture;
  15895. /**
  15896. * Set a vec3 in the shader from a Color3.
  15897. * @param name Define the name of the uniform as defined in the shader
  15898. * @param value Define the value to give to the uniform
  15899. * @return the texture itself allowing "fluent" like uniform updates
  15900. */
  15901. setColor3(name: string, value: Color3): ProceduralTexture;
  15902. /**
  15903. * Set a vec4 in the shader from a Color4.
  15904. * @param name Define the name of the uniform as defined in the shader
  15905. * @param value Define the value to give to the uniform
  15906. * @return the texture itself allowing "fluent" like uniform updates
  15907. */
  15908. setColor4(name: string, value: Color4): ProceduralTexture;
  15909. /**
  15910. * Set a vec2 in the shader from a Vector2.
  15911. * @param name Define the name of the uniform as defined in the shader
  15912. * @param value Define the value to give to the uniform
  15913. * @return the texture itself allowing "fluent" like uniform updates
  15914. */
  15915. setVector2(name: string, value: Vector2): ProceduralTexture;
  15916. /**
  15917. * Set a vec3 in the shader from a Vector3.
  15918. * @param name Define the name of the uniform as defined in the shader
  15919. * @param value Define the value to give to the uniform
  15920. * @return the texture itself allowing "fluent" like uniform updates
  15921. */
  15922. setVector3(name: string, value: Vector3): ProceduralTexture;
  15923. /**
  15924. * Set a mat4 in the shader from a MAtrix.
  15925. * @param name Define the name of the uniform as defined in the shader
  15926. * @param value Define the value to give to the uniform
  15927. * @return the texture itself allowing "fluent" like uniform updates
  15928. */
  15929. setMatrix(name: string, value: Matrix): ProceduralTexture;
  15930. /**
  15931. * Render the texture to its associated render target.
  15932. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  15933. */
  15934. render(useCameraPostProcess?: boolean): void;
  15935. /**
  15936. * Clone the texture.
  15937. * @returns the cloned texture
  15938. */
  15939. clone(): ProceduralTexture;
  15940. /**
  15941. * Dispose the texture and release its asoociated resources.
  15942. */
  15943. dispose(): void;
  15944. }
  15945. }
  15946. declare module BABYLON {
  15947. /**
  15948. * This represents the base class for particle system in Babylon.
  15949. * 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.
  15950. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15951. * @example https://doc.babylonjs.com/babylon101/particles
  15952. */
  15953. export class BaseParticleSystem {
  15954. /**
  15955. * Source color is added to the destination color without alpha affecting the result
  15956. */
  15957. static BLENDMODE_ONEONE: number;
  15958. /**
  15959. * Blend current color and particle color using particle’s alpha
  15960. */
  15961. static BLENDMODE_STANDARD: number;
  15962. /**
  15963. * Add current color and particle color multiplied by particle’s alpha
  15964. */
  15965. static BLENDMODE_ADD: number;
  15966. /**
  15967. * Multiply current color with particle color
  15968. */
  15969. static BLENDMODE_MULTIPLY: number;
  15970. /**
  15971. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  15972. */
  15973. static BLENDMODE_MULTIPLYADD: number;
  15974. /**
  15975. * List of animations used by the particle system.
  15976. */
  15977. animations: Animation[];
  15978. /**
  15979. * The id of the Particle system.
  15980. */
  15981. id: string;
  15982. /**
  15983. * The friendly name of the Particle system.
  15984. */
  15985. name: string;
  15986. /**
  15987. * The rendering group used by the Particle system to chose when to render.
  15988. */
  15989. renderingGroupId: number;
  15990. /**
  15991. * The emitter represents the Mesh or position we are attaching the particle system to.
  15992. */
  15993. emitter: Nullable<AbstractMesh | Vector3>;
  15994. /**
  15995. * The maximum number of particles to emit per frame
  15996. */
  15997. emitRate: number;
  15998. /**
  15999. * If you want to launch only a few particles at once, that can be done, as well.
  16000. */
  16001. manualEmitCount: number;
  16002. /**
  16003. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16004. */
  16005. updateSpeed: number;
  16006. /**
  16007. * The amount of time the particle system is running (depends of the overall update speed).
  16008. */
  16009. targetStopDuration: number;
  16010. /**
  16011. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16012. */
  16013. disposeOnStop: boolean;
  16014. /**
  16015. * Minimum power of emitting particles.
  16016. */
  16017. minEmitPower: number;
  16018. /**
  16019. * Maximum power of emitting particles.
  16020. */
  16021. maxEmitPower: number;
  16022. /**
  16023. * Minimum life time of emitting particles.
  16024. */
  16025. minLifeTime: number;
  16026. /**
  16027. * Maximum life time of emitting particles.
  16028. */
  16029. maxLifeTime: number;
  16030. /**
  16031. * Minimum Size of emitting particles.
  16032. */
  16033. minSize: number;
  16034. /**
  16035. * Maximum Size of emitting particles.
  16036. */
  16037. maxSize: number;
  16038. /**
  16039. * Minimum scale of emitting particles on X axis.
  16040. */
  16041. minScaleX: number;
  16042. /**
  16043. * Maximum scale of emitting particles on X axis.
  16044. */
  16045. maxScaleX: number;
  16046. /**
  16047. * Minimum scale of emitting particles on Y axis.
  16048. */
  16049. minScaleY: number;
  16050. /**
  16051. * Maximum scale of emitting particles on Y axis.
  16052. */
  16053. maxScaleY: number;
  16054. /**
  16055. * Gets or sets the minimal initial rotation in radians.
  16056. */
  16057. minInitialRotation: number;
  16058. /**
  16059. * Gets or sets the maximal initial rotation in radians.
  16060. */
  16061. maxInitialRotation: number;
  16062. /**
  16063. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16064. */
  16065. minAngularSpeed: number;
  16066. /**
  16067. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16068. */
  16069. maxAngularSpeed: number;
  16070. /**
  16071. * The texture used to render each particle. (this can be a spritesheet)
  16072. */
  16073. particleTexture: Nullable<Texture>;
  16074. /**
  16075. * The layer mask we are rendering the particles through.
  16076. */
  16077. layerMask: number;
  16078. /**
  16079. * This can help using your own shader to render the particle system.
  16080. * The according effect will be created
  16081. */
  16082. customShader: any;
  16083. /**
  16084. * By default particle system starts as soon as they are created. This prevents the
  16085. * automatic start to happen and let you decide when to start emitting particles.
  16086. */
  16087. preventAutoStart: boolean;
  16088. private _noiseTexture;
  16089. /**
  16090. * Gets or sets a texture used to add random noise to particle positions
  16091. */
  16092. noiseTexture: Nullable<ProceduralTexture>;
  16093. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16094. noiseStrength: Vector3;
  16095. /**
  16096. * Callback triggered when the particle animation is ending.
  16097. */
  16098. onAnimationEnd: Nullable<() => void>;
  16099. /**
  16100. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  16101. */
  16102. blendMode: number;
  16103. /**
  16104. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  16105. * to override the particles.
  16106. */
  16107. forceDepthWrite: boolean;
  16108. /** 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 */
  16109. preWarmCycles: number;
  16110. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  16111. preWarmStepOffset: number;
  16112. /**
  16113. * 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)
  16114. */
  16115. spriteCellChangeSpeed: number;
  16116. /**
  16117. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16118. */
  16119. startSpriteCellID: number;
  16120. /**
  16121. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16122. */
  16123. endSpriteCellID: number;
  16124. /**
  16125. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16126. */
  16127. spriteCellWidth: number;
  16128. /**
  16129. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16130. */
  16131. spriteCellHeight: number;
  16132. /**
  16133. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16134. */
  16135. spriteRandomStartCell: boolean;
  16136. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16137. translationPivot: Vector2;
  16138. /** @hidden */
  16139. protected _isAnimationSheetEnabled: boolean;
  16140. /**
  16141. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16142. */
  16143. beginAnimationOnStart: boolean;
  16144. /**
  16145. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16146. */
  16147. beginAnimationFrom: number;
  16148. /**
  16149. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16150. */
  16151. beginAnimationTo: number;
  16152. /**
  16153. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16154. */
  16155. beginAnimationLoop: boolean;
  16156. /**
  16157. * Gets or sets a world offset applied to all particles
  16158. */
  16159. worldOffset: Vector3;
  16160. /**
  16161. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  16162. */
  16163. isAnimationSheetEnabled: boolean;
  16164. /**
  16165. * Get hosting scene
  16166. * @returns the scene
  16167. */
  16168. getScene(): Scene;
  16169. /**
  16170. * You can use gravity if you want to give an orientation to your particles.
  16171. */
  16172. gravity: Vector3;
  16173. protected _colorGradients: Nullable<Array<ColorGradient>>;
  16174. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  16175. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  16176. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  16177. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  16178. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  16179. protected _dragGradients: Nullable<Array<FactorGradient>>;
  16180. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  16181. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  16182. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  16183. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  16184. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  16185. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  16186. /**
  16187. * Defines the delay in milliseconds before starting the system (0 by default)
  16188. */
  16189. startDelay: number;
  16190. /**
  16191. * Gets the current list of drag gradients.
  16192. * You must use addDragGradient and removeDragGradient to udpate this list
  16193. * @returns the list of drag gradients
  16194. */
  16195. getDragGradients(): Nullable<Array<FactorGradient>>;
  16196. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16197. limitVelocityDamping: number;
  16198. /**
  16199. * Gets the current list of limit velocity gradients.
  16200. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16201. * @returns the list of limit velocity gradients
  16202. */
  16203. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16204. /**
  16205. * Gets the current list of color gradients.
  16206. * You must use addColorGradient and removeColorGradient to udpate this list
  16207. * @returns the list of color gradients
  16208. */
  16209. getColorGradients(): Nullable<Array<ColorGradient>>;
  16210. /**
  16211. * Gets the current list of size gradients.
  16212. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16213. * @returns the list of size gradients
  16214. */
  16215. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16216. /**
  16217. * Gets the current list of color remap gradients.
  16218. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16219. * @returns the list of color remap gradients
  16220. */
  16221. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16222. /**
  16223. * Gets the current list of alpha remap gradients.
  16224. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16225. * @returns the list of alpha remap gradients
  16226. */
  16227. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16228. /**
  16229. * Gets the current list of life time gradients.
  16230. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16231. * @returns the list of life time gradients
  16232. */
  16233. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16234. /**
  16235. * Gets the current list of angular speed gradients.
  16236. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16237. * @returns the list of angular speed gradients
  16238. */
  16239. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16240. /**
  16241. * Gets the current list of velocity gradients.
  16242. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16243. * @returns the list of velocity gradients
  16244. */
  16245. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16246. /**
  16247. * Gets the current list of start size gradients.
  16248. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16249. * @returns the list of start size gradients
  16250. */
  16251. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16252. /**
  16253. * Gets the current list of emit rate gradients.
  16254. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16255. * @returns the list of emit rate gradients
  16256. */
  16257. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16258. /**
  16259. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16260. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16261. */
  16262. direction1: Vector3;
  16263. /**
  16264. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16265. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16266. */
  16267. direction2: Vector3;
  16268. /**
  16269. * 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.
  16270. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16271. */
  16272. minEmitBox: Vector3;
  16273. /**
  16274. * 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.
  16275. * This only works when particleEmitterTyps is a BoxParticleEmitter
  16276. */
  16277. maxEmitBox: Vector3;
  16278. /**
  16279. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16280. */
  16281. color1: Color4;
  16282. /**
  16283. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  16284. */
  16285. color2: Color4;
  16286. /**
  16287. * Color the particle will have at the end of its lifetime
  16288. */
  16289. colorDead: Color4;
  16290. /**
  16291. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  16292. */
  16293. textureMask: Color4;
  16294. /**
  16295. * The particle emitter type defines the emitter used by the particle system.
  16296. * It can be for example box, sphere, or cone...
  16297. */
  16298. particleEmitterType: IParticleEmitterType;
  16299. /** @hidden */ private _isSubEmitter: boolean;
  16300. /**
  16301. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16302. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16303. */
  16304. billboardMode: number;
  16305. protected _isBillboardBased: boolean;
  16306. /**
  16307. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16308. */
  16309. isBillboardBased: boolean;
  16310. /**
  16311. * The scene the particle system belongs to.
  16312. */
  16313. protected _scene: Scene;
  16314. /**
  16315. * Local cache of defines for image processing.
  16316. */
  16317. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  16318. /**
  16319. * Default configuration related to image processing available in the standard Material.
  16320. */
  16321. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  16322. /**
  16323. * Gets the image processing configuration used either in this material.
  16324. */
  16325. /**
  16326. * Sets the Default image processing configuration used either in the this material.
  16327. *
  16328. * If sets to null, the scene one is in use.
  16329. */
  16330. imageProcessingConfiguration: ImageProcessingConfiguration;
  16331. /**
  16332. * Attaches a new image processing configuration to the Standard Material.
  16333. * @param configuration
  16334. */
  16335. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  16336. /** @hidden */
  16337. protected _reset(): void;
  16338. /** @hidden */
  16339. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  16340. /**
  16341. * Instantiates a particle system.
  16342. * 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.
  16343. * @param name The name of the particle system
  16344. */
  16345. constructor(name: string);
  16346. /**
  16347. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16348. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16349. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16350. * @returns the emitter
  16351. */
  16352. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16353. /**
  16354. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16355. * @param radius The radius of the hemisphere to emit from
  16356. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16357. * @returns the emitter
  16358. */
  16359. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  16360. /**
  16361. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16362. * @param radius The radius of the sphere to emit from
  16363. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16364. * @returns the emitter
  16365. */
  16366. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  16367. /**
  16368. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16369. * @param radius The radius of the sphere to emit from
  16370. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16371. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16372. * @returns the emitter
  16373. */
  16374. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  16375. /**
  16376. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16377. * @param radius The radius of the emission cylinder
  16378. * @param height The height of the emission cylinder
  16379. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16380. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16381. * @returns the emitter
  16382. */
  16383. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  16384. /**
  16385. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16386. * @param radius The radius of the cylinder to emit from
  16387. * @param height The height of the emission cylinder
  16388. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16389. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16390. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16391. * @returns the emitter
  16392. */
  16393. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  16394. /**
  16395. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16396. * @param radius The radius of the cone to emit from
  16397. * @param angle The base angle of the cone
  16398. * @returns the emitter
  16399. */
  16400. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  16401. /**
  16402. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16403. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16404. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16405. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16406. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16407. * @returns the emitter
  16408. */
  16409. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16410. }
  16411. }
  16412. declare module BABYLON {
  16413. /**
  16414. * Type of sub emitter
  16415. */
  16416. export enum SubEmitterType {
  16417. /**
  16418. * Attached to the particle over it's lifetime
  16419. */
  16420. ATTACHED = 0,
  16421. /**
  16422. * Created when the particle dies
  16423. */
  16424. END = 1
  16425. }
  16426. /**
  16427. * Sub emitter class used to emit particles from an existing particle
  16428. */
  16429. export class SubEmitter {
  16430. /**
  16431. * the particle system to be used by the sub emitter
  16432. */
  16433. particleSystem: ParticleSystem;
  16434. /**
  16435. * Type of the submitter (Default: END)
  16436. */
  16437. type: SubEmitterType;
  16438. /**
  16439. * 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)
  16440. * Note: This only is supported when using an emitter of type Mesh
  16441. */
  16442. inheritDirection: boolean;
  16443. /**
  16444. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  16445. */
  16446. inheritedVelocityAmount: number;
  16447. /**
  16448. * Creates a sub emitter
  16449. * @param particleSystem the particle system to be used by the sub emitter
  16450. */
  16451. constructor(
  16452. /**
  16453. * the particle system to be used by the sub emitter
  16454. */
  16455. particleSystem: ParticleSystem);
  16456. /**
  16457. * Clones the sub emitter
  16458. * @returns the cloned sub emitter
  16459. */
  16460. clone(): SubEmitter;
  16461. /**
  16462. * Serialize current object to a JSON object
  16463. * @returns the serialized object
  16464. */
  16465. serialize(): any;
  16466. /** @hidden */ private static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  16467. /**
  16468. * Creates a new SubEmitter from a serialized JSON version
  16469. * @param serializationObject defines the JSON object to read from
  16470. * @param scene defines the hosting scene
  16471. * @param rootUrl defines the rootUrl for data loading
  16472. * @returns a new SubEmitter
  16473. */
  16474. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  16475. /** Release associated resources */
  16476. dispose(): void;
  16477. }
  16478. }
  16479. declare module BABYLON {
  16480. /** @hidden */
  16481. export var clipPlaneFragmentDeclaration: {
  16482. name: string;
  16483. shader: string;
  16484. };
  16485. }
  16486. declare module BABYLON {
  16487. /** @hidden */
  16488. export var imageProcessingDeclaration: {
  16489. name: string;
  16490. shader: string;
  16491. };
  16492. }
  16493. declare module BABYLON {
  16494. /** @hidden */
  16495. export var imageProcessingFunctions: {
  16496. name: string;
  16497. shader: string;
  16498. };
  16499. }
  16500. declare module BABYLON {
  16501. /** @hidden */
  16502. export var clipPlaneFragment: {
  16503. name: string;
  16504. shader: string;
  16505. };
  16506. }
  16507. declare module BABYLON {
  16508. /** @hidden */
  16509. export var particlesPixelShader: {
  16510. name: string;
  16511. shader: string;
  16512. };
  16513. }
  16514. declare module BABYLON {
  16515. /** @hidden */
  16516. export var clipPlaneVertexDeclaration: {
  16517. name: string;
  16518. shader: string;
  16519. };
  16520. }
  16521. declare module BABYLON {
  16522. /** @hidden */
  16523. export var clipPlaneVertex: {
  16524. name: string;
  16525. shader: string;
  16526. };
  16527. }
  16528. declare module BABYLON {
  16529. /** @hidden */
  16530. export var particlesVertexShader: {
  16531. name: string;
  16532. shader: string;
  16533. };
  16534. }
  16535. declare module BABYLON {
  16536. /**
  16537. * This represents a particle system in Babylon.
  16538. * 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.
  16539. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16540. * @example https://doc.babylonjs.com/babylon101/particles
  16541. */
  16542. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  16543. /**
  16544. * Billboard mode will only apply to Y axis
  16545. */
  16546. static readonly BILLBOARDMODE_Y: number;
  16547. /**
  16548. * Billboard mode will apply to all axes
  16549. */
  16550. static readonly BILLBOARDMODE_ALL: number;
  16551. /**
  16552. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  16553. */
  16554. static readonly BILLBOARDMODE_STRETCHED: number;
  16555. /**
  16556. * This function can be defined to provide custom update for active particles.
  16557. * This function will be called instead of regular update (age, position, color, etc.).
  16558. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  16559. */
  16560. updateFunction: (particles: Particle[]) => void;
  16561. private _emitterWorldMatrix;
  16562. /**
  16563. * This function can be defined to specify initial direction for every new particle.
  16564. * It by default use the emitterType defined function
  16565. */
  16566. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  16567. /**
  16568. * This function can be defined to specify initial position for every new particle.
  16569. * It by default use the emitterType defined function
  16570. */
  16571. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  16572. /**
  16573. * @hidden
  16574. */ private _inheritedVelocityOffset: Vector3;
  16575. /**
  16576. * An event triggered when the system is disposed
  16577. */
  16578. onDisposeObservable: Observable<ParticleSystem>;
  16579. private _onDisposeObserver;
  16580. /**
  16581. * Sets a callback that will be triggered when the system is disposed
  16582. */
  16583. onDispose: () => void;
  16584. private _particles;
  16585. private _epsilon;
  16586. private _capacity;
  16587. private _stockParticles;
  16588. private _newPartsExcess;
  16589. private _vertexData;
  16590. private _vertexBuffer;
  16591. private _vertexBuffers;
  16592. private _spriteBuffer;
  16593. private _indexBuffer;
  16594. private _effect;
  16595. private _customEffect;
  16596. private _cachedDefines;
  16597. private _scaledColorStep;
  16598. private _colorDiff;
  16599. private _scaledDirection;
  16600. private _scaledGravity;
  16601. private _currentRenderId;
  16602. private _alive;
  16603. private _useInstancing;
  16604. private _started;
  16605. private _stopped;
  16606. private _actualFrame;
  16607. private _scaledUpdateSpeed;
  16608. private _vertexBufferSize;
  16609. /** @hidden */ private _currentEmitRateGradient: Nullable<FactorGradient>;
  16610. /** @hidden */ private _currentEmitRate1: number;
  16611. /** @hidden */ private _currentEmitRate2: number;
  16612. /** @hidden */ private _currentStartSizeGradient: Nullable<FactorGradient>;
  16613. /** @hidden */ private _currentStartSize1: number;
  16614. /** @hidden */ private _currentStartSize2: number;
  16615. private readonly _rawTextureWidth;
  16616. private _rampGradientsTexture;
  16617. private _useRampGradients;
  16618. /** Gets or sets a boolean indicating that ramp gradients must be used
  16619. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16620. */
  16621. useRampGradients: boolean;
  16622. /**
  16623. * 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.
  16624. * 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: [])
  16625. */
  16626. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  16627. private _subEmitters;
  16628. /**
  16629. * @hidden
  16630. * If the particle systems emitter should be disposed when the particle system is disposed
  16631. */ private _disposeEmitterOnDispose: boolean;
  16632. /**
  16633. * The current active Sub-systems, this property is used by the root particle system only.
  16634. */
  16635. activeSubSystems: Array<ParticleSystem>;
  16636. private _rootParticleSystem;
  16637. /**
  16638. * Gets the current list of active particles
  16639. */
  16640. readonly particles: Particle[];
  16641. /**
  16642. * Returns the string "ParticleSystem"
  16643. * @returns a string containing the class name
  16644. */
  16645. getClassName(): string;
  16646. /**
  16647. * Instantiates a particle system.
  16648. * 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.
  16649. * @param name The name of the particle system
  16650. * @param capacity The max number of particles alive at the same time
  16651. * @param scene The scene the particle system belongs to
  16652. * @param customEffect a custom effect used to change the way particles are rendered by default
  16653. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  16654. * @param epsilon Offset used to render the particles
  16655. */
  16656. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  16657. private _addFactorGradient;
  16658. private _removeFactorGradient;
  16659. /**
  16660. * Adds a new life time gradient
  16661. * @param gradient defines the gradient to use (between 0 and 1)
  16662. * @param factor defines the life time factor to affect to the specified gradient
  16663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16664. * @returns the current particle system
  16665. */
  16666. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16667. /**
  16668. * Remove a specific life time gradient
  16669. * @param gradient defines the gradient to remove
  16670. * @returns the current particle system
  16671. */
  16672. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16673. /**
  16674. * Adds a new size gradient
  16675. * @param gradient defines the gradient to use (between 0 and 1)
  16676. * @param factor defines the size factor to affect to the specified gradient
  16677. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16678. * @returns the current particle system
  16679. */
  16680. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16681. /**
  16682. * Remove a specific size gradient
  16683. * @param gradient defines the gradient to remove
  16684. * @returns the current particle system
  16685. */
  16686. removeSizeGradient(gradient: number): IParticleSystem;
  16687. /**
  16688. * Adds a new color remap gradient
  16689. * @param gradient defines the gradient to use (between 0 and 1)
  16690. * @param min defines the color remap minimal range
  16691. * @param max defines the color remap maximal range
  16692. * @returns the current particle system
  16693. */
  16694. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16695. /**
  16696. * Remove a specific color remap gradient
  16697. * @param gradient defines the gradient to remove
  16698. * @returns the current particle system
  16699. */
  16700. removeColorRemapGradient(gradient: number): IParticleSystem;
  16701. /**
  16702. * Adds a new alpha remap gradient
  16703. * @param gradient defines the gradient to use (between 0 and 1)
  16704. * @param min defines the alpha remap minimal range
  16705. * @param max defines the alpha remap maximal range
  16706. * @returns the current particle system
  16707. */
  16708. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16709. /**
  16710. * Remove a specific alpha remap gradient
  16711. * @param gradient defines the gradient to remove
  16712. * @returns the current particle system
  16713. */
  16714. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  16715. /**
  16716. * Adds a new angular speed gradient
  16717. * @param gradient defines the gradient to use (between 0 and 1)
  16718. * @param factor defines the angular speed to affect to the specified gradient
  16719. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16720. * @returns the current particle system
  16721. */
  16722. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16723. /**
  16724. * Remove a specific angular speed gradient
  16725. * @param gradient defines the gradient to remove
  16726. * @returns the current particle system
  16727. */
  16728. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16729. /**
  16730. * Adds a new velocity gradient
  16731. * @param gradient defines the gradient to use (between 0 and 1)
  16732. * @param factor defines the velocity to affect to the specified gradient
  16733. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16734. * @returns the current particle system
  16735. */
  16736. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16737. /**
  16738. * Remove a specific velocity gradient
  16739. * @param gradient defines the gradient to remove
  16740. * @returns the current particle system
  16741. */
  16742. removeVelocityGradient(gradient: number): IParticleSystem;
  16743. /**
  16744. * Adds a new limit velocity gradient
  16745. * @param gradient defines the gradient to use (between 0 and 1)
  16746. * @param factor defines the limit velocity value to affect to the specified gradient
  16747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16748. * @returns the current particle system
  16749. */
  16750. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16751. /**
  16752. * Remove a specific limit velocity gradient
  16753. * @param gradient defines the gradient to remove
  16754. * @returns the current particle system
  16755. */
  16756. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16757. /**
  16758. * Adds a new drag gradient
  16759. * @param gradient defines the gradient to use (between 0 and 1)
  16760. * @param factor defines the drag value to affect to the specified gradient
  16761. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16762. * @returns the current particle system
  16763. */
  16764. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16765. /**
  16766. * Remove a specific drag gradient
  16767. * @param gradient defines the gradient to remove
  16768. * @returns the current particle system
  16769. */
  16770. removeDragGradient(gradient: number): IParticleSystem;
  16771. /**
  16772. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16773. * @param gradient defines the gradient to use (between 0 and 1)
  16774. * @param factor defines the emit rate value to affect to the specified gradient
  16775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16776. * @returns the current particle system
  16777. */
  16778. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16779. /**
  16780. * Remove a specific emit rate gradient
  16781. * @param gradient defines the gradient to remove
  16782. * @returns the current particle system
  16783. */
  16784. removeEmitRateGradient(gradient: number): IParticleSystem;
  16785. /**
  16786. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16787. * @param gradient defines the gradient to use (between 0 and 1)
  16788. * @param factor defines the start size value to affect to the specified gradient
  16789. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16790. * @returns the current particle system
  16791. */
  16792. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16793. /**
  16794. * Remove a specific start size gradient
  16795. * @param gradient defines the gradient to remove
  16796. * @returns the current particle system
  16797. */
  16798. removeStartSizeGradient(gradient: number): IParticleSystem;
  16799. private _createRampGradientTexture;
  16800. /**
  16801. * Gets the current list of ramp gradients.
  16802. * You must use addRampGradient and removeRampGradient to udpate this list
  16803. * @returns the list of ramp gradients
  16804. */
  16805. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16806. /**
  16807. * Adds a new ramp gradient used to remap particle colors
  16808. * @param gradient defines the gradient to use (between 0 and 1)
  16809. * @param color defines the color to affect to the specified gradient
  16810. * @returns the current particle system
  16811. */
  16812. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  16813. /**
  16814. * Remove a specific ramp gradient
  16815. * @param gradient defines the gradient to remove
  16816. * @returns the current particle system
  16817. */
  16818. removeRampGradient(gradient: number): ParticleSystem;
  16819. /**
  16820. * Adds a new color gradient
  16821. * @param gradient defines the gradient to use (between 0 and 1)
  16822. * @param color1 defines the color to affect to the specified gradient
  16823. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16824. * @returns this particle system
  16825. */
  16826. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16827. /**
  16828. * Remove a specific color gradient
  16829. * @param gradient defines the gradient to remove
  16830. * @returns this particle system
  16831. */
  16832. removeColorGradient(gradient: number): IParticleSystem;
  16833. private _fetchR;
  16834. protected _reset(): void;
  16835. private _resetEffect;
  16836. private _createVertexBuffers;
  16837. private _createIndexBuffer;
  16838. /**
  16839. * Gets the maximum number of particles active at the same time.
  16840. * @returns The max number of active particles.
  16841. */
  16842. getCapacity(): number;
  16843. /**
  16844. * Gets whether there are still active particles in the system.
  16845. * @returns True if it is alive, otherwise false.
  16846. */
  16847. isAlive(): boolean;
  16848. /**
  16849. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16850. * @returns True if it has been started, otherwise false.
  16851. */
  16852. isStarted(): boolean;
  16853. private _prepareSubEmitterInternalArray;
  16854. /**
  16855. * Starts the particle system and begins to emit
  16856. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  16857. */
  16858. start(delay?: number): void;
  16859. /**
  16860. * Stops the particle system.
  16861. * @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.
  16862. */
  16863. stop(stopSubEmitters?: boolean): void;
  16864. /**
  16865. * Remove all active particles
  16866. */
  16867. reset(): void;
  16868. /**
  16869. * @hidden (for internal use only)
  16870. */ private _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  16871. /**
  16872. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  16873. * Its lifetime will start back at 0.
  16874. */
  16875. recycleParticle: (particle: Particle) => void;
  16876. private _stopSubEmitters;
  16877. private _createParticle;
  16878. private _removeFromRoot;
  16879. private _emitFromParticle;
  16880. private _update;
  16881. /** @hidden */ private static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  16882. /** @hidden */ private static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  16883. /** @hidden */
  16884. private _getEffect;
  16885. /**
  16886. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  16887. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  16888. */
  16889. animate(preWarmOnly?: boolean): void;
  16890. private _appendParticleVertices;
  16891. /**
  16892. * Rebuilds the particle system.
  16893. */
  16894. rebuild(): void;
  16895. /**
  16896. * Is this system ready to be used/rendered
  16897. * @return true if the system is ready
  16898. */
  16899. isReady(): boolean;
  16900. private _render;
  16901. /**
  16902. * Renders the particle system in its current state.
  16903. * @returns the current number of particles
  16904. */
  16905. render(): number;
  16906. /**
  16907. * Disposes the particle system and free the associated resources
  16908. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16909. */
  16910. dispose(disposeTexture?: boolean): void;
  16911. /**
  16912. * Clones the particle system.
  16913. * @param name The name of the cloned object
  16914. * @param newEmitter The new emitter to use
  16915. * @returns the cloned particle system
  16916. */
  16917. clone(name: string, newEmitter: any): ParticleSystem;
  16918. /**
  16919. * Serializes the particle system to a JSON object.
  16920. * @returns the JSON object
  16921. */
  16922. serialize(): any;
  16923. /** @hidden */ private static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  16924. /** @hidden */ private static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  16925. /**
  16926. * Parses a JSON object to create a particle system.
  16927. * @param parsedParticleSystem The JSON object to parse
  16928. * @param scene The scene to create the particle system in
  16929. * @param rootUrl The root url to use to load external dependencies like texture
  16930. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  16931. * @returns the Parsed particle system
  16932. */
  16933. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  16934. }
  16935. }
  16936. declare module BABYLON {
  16937. /**
  16938. * A particle represents one of the element emitted by a particle system.
  16939. * This is mainly define by its coordinates, direction, velocity and age.
  16940. */
  16941. export class Particle {
  16942. /**
  16943. * The particle system the particle belongs to.
  16944. */
  16945. particleSystem: ParticleSystem;
  16946. private static _Count;
  16947. /**
  16948. * Unique ID of the particle
  16949. */
  16950. id: number;
  16951. /**
  16952. * The world position of the particle in the scene.
  16953. */
  16954. position: Vector3;
  16955. /**
  16956. * The world direction of the particle in the scene.
  16957. */
  16958. direction: Vector3;
  16959. /**
  16960. * The color of the particle.
  16961. */
  16962. color: Color4;
  16963. /**
  16964. * The color change of the particle per step.
  16965. */
  16966. colorStep: Color4;
  16967. /**
  16968. * Defines how long will the life of the particle be.
  16969. */
  16970. lifeTime: number;
  16971. /**
  16972. * The current age of the particle.
  16973. */
  16974. age: number;
  16975. /**
  16976. * The current size of the particle.
  16977. */
  16978. size: number;
  16979. /**
  16980. * The current scale of the particle.
  16981. */
  16982. scale: Vector2;
  16983. /**
  16984. * The current angle of the particle.
  16985. */
  16986. angle: number;
  16987. /**
  16988. * Defines how fast is the angle changing.
  16989. */
  16990. angularSpeed: number;
  16991. /**
  16992. * Defines the cell index used by the particle to be rendered from a sprite.
  16993. */
  16994. cellIndex: number;
  16995. /**
  16996. * The information required to support color remapping
  16997. */
  16998. remapData: Vector4;
  16999. /** @hidden */ private _randomCellOffset?: number;
  17000. /** @hidden */ private _initialDirection: Nullable<Vector3>;
  17001. /** @hidden */ private _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  17002. /** @hidden */ private _initialStartSpriteCellID: number;
  17003. /** @hidden */ private _initialEndSpriteCellID: number;
  17004. /** @hidden */ private _currentColorGradient: Nullable<ColorGradient>;
  17005. /** @hidden */ private _currentColor1: Color4;
  17006. /** @hidden */ private _currentColor2: Color4;
  17007. /** @hidden */ private _currentSizeGradient: Nullable<FactorGradient>;
  17008. /** @hidden */ private _currentSize1: number;
  17009. /** @hidden */ private _currentSize2: number;
  17010. /** @hidden */ private _currentAngularSpeedGradient: Nullable<FactorGradient>;
  17011. /** @hidden */ private _currentAngularSpeed1: number;
  17012. /** @hidden */ private _currentAngularSpeed2: number;
  17013. /** @hidden */ private _currentVelocityGradient: Nullable<FactorGradient>;
  17014. /** @hidden */ private _currentVelocity1: number;
  17015. /** @hidden */ private _currentVelocity2: number;
  17016. /** @hidden */ private _currentLimitVelocityGradient: Nullable<FactorGradient>;
  17017. /** @hidden */ private _currentLimitVelocity1: number;
  17018. /** @hidden */ private _currentLimitVelocity2: number;
  17019. /** @hidden */ private _currentDragGradient: Nullable<FactorGradient>;
  17020. /** @hidden */ private _currentDrag1: number;
  17021. /** @hidden */ private _currentDrag2: number;
  17022. /** @hidden */ private _randomNoiseCoordinates1: Vector3;
  17023. /** @hidden */ private _randomNoiseCoordinates2: Vector3;
  17024. /**
  17025. * Creates a new instance Particle
  17026. * @param particleSystem the particle system the particle belongs to
  17027. */
  17028. constructor(
  17029. /**
  17030. * The particle system the particle belongs to.
  17031. */
  17032. particleSystem: ParticleSystem);
  17033. private updateCellInfoFromSystem;
  17034. /**
  17035. * Defines how the sprite cell index is updated for the particle
  17036. */
  17037. updateCellIndex(): void;
  17038. /** @hidden */ private _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  17039. /** @hidden */ private _inheritParticleInfoToSubEmitters(): void;
  17040. /** @hidden */ private _reset(): void;
  17041. /**
  17042. * Copy the properties of particle to another one.
  17043. * @param other the particle to copy the information to.
  17044. */
  17045. copyTo(other: Particle): void;
  17046. }
  17047. }
  17048. declare module BABYLON {
  17049. /**
  17050. * Particle emitter represents a volume emitting particles.
  17051. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  17052. */
  17053. export interface IParticleEmitterType {
  17054. /**
  17055. * Called by the particle System when the direction is computed for the created particle.
  17056. * @param worldMatrix is the world matrix of the particle system
  17057. * @param directionToUpdate is the direction vector to update with the result
  17058. * @param particle is the particle we are computed the direction for
  17059. */
  17060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17061. /**
  17062. * Called by the particle System when the position is computed for the created particle.
  17063. * @param worldMatrix is the world matrix of the particle system
  17064. * @param positionToUpdate is the position vector to update with the result
  17065. * @param particle is the particle we are computed the position for
  17066. */
  17067. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17068. /**
  17069. * Clones the current emitter and returns a copy of it
  17070. * @returns the new emitter
  17071. */
  17072. clone(): IParticleEmitterType;
  17073. /**
  17074. * Called by the GPUParticleSystem to setup the update shader
  17075. * @param effect defines the update shader
  17076. */
  17077. applyToShader(effect: Effect): void;
  17078. /**
  17079. * Returns a string to use to update the GPU particles update shader
  17080. * @returns the effect defines string
  17081. */
  17082. getEffectDefines(): string;
  17083. /**
  17084. * Returns a string representing the class name
  17085. * @returns a string containing the class name
  17086. */
  17087. getClassName(): string;
  17088. /**
  17089. * Serializes the particle system to a JSON object.
  17090. * @returns the JSON object
  17091. */
  17092. serialize(): any;
  17093. /**
  17094. * Parse properties from a JSON object
  17095. * @param serializationObject defines the JSON object
  17096. */
  17097. parse(serializationObject: any): void;
  17098. }
  17099. }
  17100. declare module BABYLON {
  17101. /**
  17102. * Particle emitter emitting particles from the inside of a box.
  17103. * It emits the particles randomly between 2 given directions.
  17104. */
  17105. export class BoxParticleEmitter implements IParticleEmitterType {
  17106. /**
  17107. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17108. */
  17109. direction1: Vector3;
  17110. /**
  17111. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17112. */
  17113. direction2: Vector3;
  17114. /**
  17115. * 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.
  17116. */
  17117. minEmitBox: Vector3;
  17118. /**
  17119. * 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.
  17120. */
  17121. maxEmitBox: Vector3;
  17122. /**
  17123. * Creates a new instance BoxParticleEmitter
  17124. */
  17125. constructor();
  17126. /**
  17127. * Called by the particle System when the direction is computed for the created particle.
  17128. * @param worldMatrix is the world matrix of the particle system
  17129. * @param directionToUpdate is the direction vector to update with the result
  17130. * @param particle is the particle we are computed the direction for
  17131. */
  17132. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17133. /**
  17134. * Called by the particle System when the position is computed for the created particle.
  17135. * @param worldMatrix is the world matrix of the particle system
  17136. * @param positionToUpdate is the position vector to update with the result
  17137. * @param particle is the particle we are computed the position for
  17138. */
  17139. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17140. /**
  17141. * Clones the current emitter and returns a copy of it
  17142. * @returns the new emitter
  17143. */
  17144. clone(): BoxParticleEmitter;
  17145. /**
  17146. * Called by the GPUParticleSystem to setup the update shader
  17147. * @param effect defines the update shader
  17148. */
  17149. applyToShader(effect: Effect): void;
  17150. /**
  17151. * Returns a string to use to update the GPU particles update shader
  17152. * @returns a string containng the defines string
  17153. */
  17154. getEffectDefines(): string;
  17155. /**
  17156. * Returns the string "BoxParticleEmitter"
  17157. * @returns a string containing the class name
  17158. */
  17159. getClassName(): string;
  17160. /**
  17161. * Serializes the particle system to a JSON object.
  17162. * @returns the JSON object
  17163. */
  17164. serialize(): any;
  17165. /**
  17166. * Parse properties from a JSON object
  17167. * @param serializationObject defines the JSON object
  17168. */
  17169. parse(serializationObject: any): void;
  17170. }
  17171. }
  17172. declare module BABYLON {
  17173. /**
  17174. * Particle emitter emitting particles from the inside of a cone.
  17175. * It emits the particles alongside the cone volume from the base to the particle.
  17176. * The emission direction might be randomized.
  17177. */
  17178. export class ConeParticleEmitter implements IParticleEmitterType {
  17179. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17180. directionRandomizer: number;
  17181. private _radius;
  17182. private _angle;
  17183. private _height;
  17184. /**
  17185. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  17186. */
  17187. radiusRange: number;
  17188. /**
  17189. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  17190. */
  17191. heightRange: number;
  17192. /**
  17193. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  17194. */
  17195. emitFromSpawnPointOnly: boolean;
  17196. /**
  17197. * Gets or sets the radius of the emission cone
  17198. */
  17199. radius: number;
  17200. /**
  17201. * Gets or sets the angle of the emission cone
  17202. */
  17203. angle: number;
  17204. private _buildHeight;
  17205. /**
  17206. * Creates a new instance ConeParticleEmitter
  17207. * @param radius the radius of the emission cone (1 by default)
  17208. * @param angle the cone base angle (PI by default)
  17209. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  17210. */
  17211. constructor(radius?: number, angle?: number,
  17212. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  17213. directionRandomizer?: number);
  17214. /**
  17215. * Called by the particle System when the direction is computed for the created particle.
  17216. * @param worldMatrix is the world matrix of the particle system
  17217. * @param directionToUpdate is the direction vector to update with the result
  17218. * @param particle is the particle we are computed the direction for
  17219. */
  17220. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17221. /**
  17222. * Called by the particle System when the position is computed for the created particle.
  17223. * @param worldMatrix is the world matrix of the particle system
  17224. * @param positionToUpdate is the position vector to update with the result
  17225. * @param particle is the particle we are computed the position for
  17226. */
  17227. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17228. /**
  17229. * Clones the current emitter and returns a copy of it
  17230. * @returns the new emitter
  17231. */
  17232. clone(): ConeParticleEmitter;
  17233. /**
  17234. * Called by the GPUParticleSystem to setup the update shader
  17235. * @param effect defines the update shader
  17236. */
  17237. applyToShader(effect: Effect): void;
  17238. /**
  17239. * Returns a string to use to update the GPU particles update shader
  17240. * @returns a string containng the defines string
  17241. */
  17242. getEffectDefines(): string;
  17243. /**
  17244. * Returns the string "ConeParticleEmitter"
  17245. * @returns a string containing the class name
  17246. */
  17247. getClassName(): string;
  17248. /**
  17249. * Serializes the particle system to a JSON object.
  17250. * @returns the JSON object
  17251. */
  17252. serialize(): any;
  17253. /**
  17254. * Parse properties from a JSON object
  17255. * @param serializationObject defines the JSON object
  17256. */
  17257. parse(serializationObject: any): void;
  17258. }
  17259. }
  17260. declare module BABYLON {
  17261. /**
  17262. * Particle emitter emitting particles from the inside of a cylinder.
  17263. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  17264. */
  17265. export class CylinderParticleEmitter implements IParticleEmitterType {
  17266. /**
  17267. * The radius of the emission cylinder.
  17268. */
  17269. radius: number;
  17270. /**
  17271. * The height of the emission cylinder.
  17272. */
  17273. height: number;
  17274. /**
  17275. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17276. */
  17277. radiusRange: number;
  17278. /**
  17279. * How much to randomize the particle direction [0-1].
  17280. */
  17281. directionRandomizer: number;
  17282. /**
  17283. * Creates a new instance CylinderParticleEmitter
  17284. * @param radius the radius of the emission cylinder (1 by default)
  17285. * @param height the height of the emission cylinder (1 by default)
  17286. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17287. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17288. */
  17289. constructor(
  17290. /**
  17291. * The radius of the emission cylinder.
  17292. */
  17293. radius?: number,
  17294. /**
  17295. * The height of the emission cylinder.
  17296. */
  17297. height?: number,
  17298. /**
  17299. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17300. */
  17301. radiusRange?: number,
  17302. /**
  17303. * How much to randomize the particle direction [0-1].
  17304. */
  17305. directionRandomizer?: number);
  17306. /**
  17307. * Called by the particle System when the direction is computed for the created particle.
  17308. * @param worldMatrix is the world matrix of the particle system
  17309. * @param directionToUpdate is the direction vector to update with the result
  17310. * @param particle is the particle we are computed the direction for
  17311. */
  17312. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17313. /**
  17314. * Called by the particle System when the position is computed for the created particle.
  17315. * @param worldMatrix is the world matrix of the particle system
  17316. * @param positionToUpdate is the position vector to update with the result
  17317. * @param particle is the particle we are computed the position for
  17318. */
  17319. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17320. /**
  17321. * Clones the current emitter and returns a copy of it
  17322. * @returns the new emitter
  17323. */
  17324. clone(): CylinderParticleEmitter;
  17325. /**
  17326. * Called by the GPUParticleSystem to setup the update shader
  17327. * @param effect defines the update shader
  17328. */
  17329. applyToShader(effect: Effect): void;
  17330. /**
  17331. * Returns a string to use to update the GPU particles update shader
  17332. * @returns a string containng the defines string
  17333. */
  17334. getEffectDefines(): string;
  17335. /**
  17336. * Returns the string "CylinderParticleEmitter"
  17337. * @returns a string containing the class name
  17338. */
  17339. getClassName(): string;
  17340. /**
  17341. * Serializes the particle system to a JSON object.
  17342. * @returns the JSON object
  17343. */
  17344. serialize(): any;
  17345. /**
  17346. * Parse properties from a JSON object
  17347. * @param serializationObject defines the JSON object
  17348. */
  17349. parse(serializationObject: any): void;
  17350. }
  17351. /**
  17352. * Particle emitter emitting particles from the inside of a cylinder.
  17353. * It emits the particles randomly between two vectors.
  17354. */
  17355. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  17356. /**
  17357. * The min limit of the emission direction.
  17358. */
  17359. direction1: Vector3;
  17360. /**
  17361. * The max limit of the emission direction.
  17362. */
  17363. direction2: Vector3;
  17364. /**
  17365. * Creates a new instance CylinderDirectedParticleEmitter
  17366. * @param radius the radius of the emission cylinder (1 by default)
  17367. * @param height the height of the emission cylinder (1 by default)
  17368. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17369. * @param direction1 the min limit of the emission direction (up vector by default)
  17370. * @param direction2 the max limit of the emission direction (up vector by default)
  17371. */
  17372. constructor(radius?: number, height?: number, radiusRange?: number,
  17373. /**
  17374. * The min limit of the emission direction.
  17375. */
  17376. direction1?: Vector3,
  17377. /**
  17378. * The max limit of the emission direction.
  17379. */
  17380. direction2?: Vector3);
  17381. /**
  17382. * Called by the particle System when the direction is computed for the created particle.
  17383. * @param worldMatrix is the world matrix of the particle system
  17384. * @param directionToUpdate is the direction vector to update with the result
  17385. * @param particle is the particle we are computed the direction for
  17386. */
  17387. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17388. /**
  17389. * Clones the current emitter and returns a copy of it
  17390. * @returns the new emitter
  17391. */
  17392. clone(): CylinderDirectedParticleEmitter;
  17393. /**
  17394. * Called by the GPUParticleSystem to setup the update shader
  17395. * @param effect defines the update shader
  17396. */
  17397. applyToShader(effect: Effect): void;
  17398. /**
  17399. * Returns a string to use to update the GPU particles update shader
  17400. * @returns a string containng the defines string
  17401. */
  17402. getEffectDefines(): string;
  17403. /**
  17404. * Returns the string "CylinderDirectedParticleEmitter"
  17405. * @returns a string containing the class name
  17406. */
  17407. getClassName(): string;
  17408. /**
  17409. * Serializes the particle system to a JSON object.
  17410. * @returns the JSON object
  17411. */
  17412. serialize(): any;
  17413. /**
  17414. * Parse properties from a JSON object
  17415. * @param serializationObject defines the JSON object
  17416. */
  17417. parse(serializationObject: any): void;
  17418. }
  17419. }
  17420. declare module BABYLON {
  17421. /**
  17422. * Particle emitter emitting particles from the inside of a hemisphere.
  17423. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  17424. */
  17425. export class HemisphericParticleEmitter implements IParticleEmitterType {
  17426. /**
  17427. * The radius of the emission hemisphere.
  17428. */
  17429. radius: number;
  17430. /**
  17431. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17432. */
  17433. radiusRange: number;
  17434. /**
  17435. * How much to randomize the particle direction [0-1].
  17436. */
  17437. directionRandomizer: number;
  17438. /**
  17439. * Creates a new instance HemisphericParticleEmitter
  17440. * @param radius the radius of the emission hemisphere (1 by default)
  17441. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17442. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17443. */
  17444. constructor(
  17445. /**
  17446. * The radius of the emission hemisphere.
  17447. */
  17448. radius?: number,
  17449. /**
  17450. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17451. */
  17452. radiusRange?: number,
  17453. /**
  17454. * How much to randomize the particle direction [0-1].
  17455. */
  17456. directionRandomizer?: number);
  17457. /**
  17458. * Called by the particle System when the direction is computed for the created particle.
  17459. * @param worldMatrix is the world matrix of the particle system
  17460. * @param directionToUpdate is the direction vector to update with the result
  17461. * @param particle is the particle we are computed the direction for
  17462. */
  17463. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17464. /**
  17465. * Called by the particle System when the position is computed for the created particle.
  17466. * @param worldMatrix is the world matrix of the particle system
  17467. * @param positionToUpdate is the position vector to update with the result
  17468. * @param particle is the particle we are computed the position for
  17469. */
  17470. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17471. /**
  17472. * Clones the current emitter and returns a copy of it
  17473. * @returns the new emitter
  17474. */
  17475. clone(): HemisphericParticleEmitter;
  17476. /**
  17477. * Called by the GPUParticleSystem to setup the update shader
  17478. * @param effect defines the update shader
  17479. */
  17480. applyToShader(effect: Effect): void;
  17481. /**
  17482. * Returns a string to use to update the GPU particles update shader
  17483. * @returns a string containng the defines string
  17484. */
  17485. getEffectDefines(): string;
  17486. /**
  17487. * Returns the string "HemisphericParticleEmitter"
  17488. * @returns a string containing the class name
  17489. */
  17490. getClassName(): string;
  17491. /**
  17492. * Serializes the particle system to a JSON object.
  17493. * @returns the JSON object
  17494. */
  17495. serialize(): any;
  17496. /**
  17497. * Parse properties from a JSON object
  17498. * @param serializationObject defines the JSON object
  17499. */
  17500. parse(serializationObject: any): void;
  17501. }
  17502. }
  17503. declare module BABYLON {
  17504. /**
  17505. * Particle emitter emitting particles from a point.
  17506. * It emits the particles randomly between 2 given directions.
  17507. */
  17508. export class PointParticleEmitter implements IParticleEmitterType {
  17509. /**
  17510. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17511. */
  17512. direction1: Vector3;
  17513. /**
  17514. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17515. */
  17516. direction2: Vector3;
  17517. /**
  17518. * Creates a new instance PointParticleEmitter
  17519. */
  17520. constructor();
  17521. /**
  17522. * Called by the particle System when the direction is computed for the created particle.
  17523. * @param worldMatrix is the world matrix of the particle system
  17524. * @param directionToUpdate is the direction vector to update with the result
  17525. * @param particle is the particle we are computed the direction for
  17526. */
  17527. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17528. /**
  17529. * Called by the particle System when the position is computed for the created particle.
  17530. * @param worldMatrix is the world matrix of the particle system
  17531. * @param positionToUpdate is the position vector to update with the result
  17532. * @param particle is the particle we are computed the position for
  17533. */
  17534. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17535. /**
  17536. * Clones the current emitter and returns a copy of it
  17537. * @returns the new emitter
  17538. */
  17539. clone(): PointParticleEmitter;
  17540. /**
  17541. * Called by the GPUParticleSystem to setup the update shader
  17542. * @param effect defines the update shader
  17543. */
  17544. applyToShader(effect: Effect): void;
  17545. /**
  17546. * Returns a string to use to update the GPU particles update shader
  17547. * @returns a string containng the defines string
  17548. */
  17549. getEffectDefines(): string;
  17550. /**
  17551. * Returns the string "PointParticleEmitter"
  17552. * @returns a string containing the class name
  17553. */
  17554. getClassName(): string;
  17555. /**
  17556. * Serializes the particle system to a JSON object.
  17557. * @returns the JSON object
  17558. */
  17559. serialize(): any;
  17560. /**
  17561. * Parse properties from a JSON object
  17562. * @param serializationObject defines the JSON object
  17563. */
  17564. parse(serializationObject: any): void;
  17565. }
  17566. }
  17567. declare module BABYLON {
  17568. /**
  17569. * Particle emitter emitting particles from the inside of a sphere.
  17570. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  17571. */
  17572. export class SphereParticleEmitter implements IParticleEmitterType {
  17573. /**
  17574. * The radius of the emission sphere.
  17575. */
  17576. radius: number;
  17577. /**
  17578. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17579. */
  17580. radiusRange: number;
  17581. /**
  17582. * How much to randomize the particle direction [0-1].
  17583. */
  17584. directionRandomizer: number;
  17585. /**
  17586. * Creates a new instance SphereParticleEmitter
  17587. * @param radius the radius of the emission sphere (1 by default)
  17588. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17589. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  17590. */
  17591. constructor(
  17592. /**
  17593. * The radius of the emission sphere.
  17594. */
  17595. radius?: number,
  17596. /**
  17597. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  17598. */
  17599. radiusRange?: number,
  17600. /**
  17601. * How much to randomize the particle direction [0-1].
  17602. */
  17603. directionRandomizer?: number);
  17604. /**
  17605. * Called by the particle System when the direction is computed for the created particle.
  17606. * @param worldMatrix is the world matrix of the particle system
  17607. * @param directionToUpdate is the direction vector to update with the result
  17608. * @param particle is the particle we are computed the direction for
  17609. */
  17610. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17611. /**
  17612. * Called by the particle System when the position is computed for the created particle.
  17613. * @param worldMatrix is the world matrix of the particle system
  17614. * @param positionToUpdate is the position vector to update with the result
  17615. * @param particle is the particle we are computed the position for
  17616. */
  17617. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  17618. /**
  17619. * Clones the current emitter and returns a copy of it
  17620. * @returns the new emitter
  17621. */
  17622. clone(): SphereParticleEmitter;
  17623. /**
  17624. * Called by the GPUParticleSystem to setup the update shader
  17625. * @param effect defines the update shader
  17626. */
  17627. applyToShader(effect: Effect): void;
  17628. /**
  17629. * Returns a string to use to update the GPU particles update shader
  17630. * @returns a string containng the defines string
  17631. */
  17632. getEffectDefines(): string;
  17633. /**
  17634. * Returns the string "SphereParticleEmitter"
  17635. * @returns a string containing the class name
  17636. */
  17637. getClassName(): string;
  17638. /**
  17639. * Serializes the particle system to a JSON object.
  17640. * @returns the JSON object
  17641. */
  17642. serialize(): any;
  17643. /**
  17644. * Parse properties from a JSON object
  17645. * @param serializationObject defines the JSON object
  17646. */
  17647. parse(serializationObject: any): void;
  17648. }
  17649. /**
  17650. * Particle emitter emitting particles from the inside of a sphere.
  17651. * It emits the particles randomly between two vectors.
  17652. */
  17653. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  17654. /**
  17655. * The min limit of the emission direction.
  17656. */
  17657. direction1: Vector3;
  17658. /**
  17659. * The max limit of the emission direction.
  17660. */
  17661. direction2: Vector3;
  17662. /**
  17663. * Creates a new instance SphereDirectedParticleEmitter
  17664. * @param radius the radius of the emission sphere (1 by default)
  17665. * @param direction1 the min limit of the emission direction (up vector by default)
  17666. * @param direction2 the max limit of the emission direction (up vector by default)
  17667. */
  17668. constructor(radius?: number,
  17669. /**
  17670. * The min limit of the emission direction.
  17671. */
  17672. direction1?: Vector3,
  17673. /**
  17674. * The max limit of the emission direction.
  17675. */
  17676. direction2?: Vector3);
  17677. /**
  17678. * Called by the particle System when the direction is computed for the created particle.
  17679. * @param worldMatrix is the world matrix of the particle system
  17680. * @param directionToUpdate is the direction vector to update with the result
  17681. * @param particle is the particle we are computed the direction for
  17682. */
  17683. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  17684. /**
  17685. * Clones the current emitter and returns a copy of it
  17686. * @returns the new emitter
  17687. */
  17688. clone(): SphereDirectedParticleEmitter;
  17689. /**
  17690. * Called by the GPUParticleSystem to setup the update shader
  17691. * @param effect defines the update shader
  17692. */
  17693. applyToShader(effect: Effect): void;
  17694. /**
  17695. * Returns a string to use to update the GPU particles update shader
  17696. * @returns a string containng the defines string
  17697. */
  17698. getEffectDefines(): string;
  17699. /**
  17700. * Returns the string "SphereDirectedParticleEmitter"
  17701. * @returns a string containing the class name
  17702. */
  17703. getClassName(): string;
  17704. /**
  17705. * Serializes the particle system to a JSON object.
  17706. * @returns the JSON object
  17707. */
  17708. serialize(): any;
  17709. /**
  17710. * Parse properties from a JSON object
  17711. * @param serializationObject defines the JSON object
  17712. */
  17713. parse(serializationObject: any): void;
  17714. }
  17715. }
  17716. declare module BABYLON {
  17717. /**
  17718. * Interface representing a particle system in Babylon.js.
  17719. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  17720. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  17721. */
  17722. export interface IParticleSystem {
  17723. /**
  17724. * List of animations used by the particle system.
  17725. */
  17726. animations: Animation[];
  17727. /**
  17728. * The id of the Particle system.
  17729. */
  17730. id: string;
  17731. /**
  17732. * The name of the Particle system.
  17733. */
  17734. name: string;
  17735. /**
  17736. * The emitter represents the Mesh or position we are attaching the particle system to.
  17737. */
  17738. emitter: Nullable<AbstractMesh | Vector3>;
  17739. /**
  17740. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17741. */
  17742. isBillboardBased: boolean;
  17743. /**
  17744. * The rendering group used by the Particle system to chose when to render.
  17745. */
  17746. renderingGroupId: number;
  17747. /**
  17748. * The layer mask we are rendering the particles through.
  17749. */
  17750. layerMask: number;
  17751. /**
  17752. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  17753. */
  17754. updateSpeed: number;
  17755. /**
  17756. * The amount of time the particle system is running (depends of the overall update speed).
  17757. */
  17758. targetStopDuration: number;
  17759. /**
  17760. * The texture used to render each particle. (this can be a spritesheet)
  17761. */
  17762. particleTexture: Nullable<Texture>;
  17763. /**
  17764. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  17765. */
  17766. blendMode: number;
  17767. /**
  17768. * Minimum life time of emitting particles.
  17769. */
  17770. minLifeTime: number;
  17771. /**
  17772. * Maximum life time of emitting particles.
  17773. */
  17774. maxLifeTime: number;
  17775. /**
  17776. * Minimum Size of emitting particles.
  17777. */
  17778. minSize: number;
  17779. /**
  17780. * Maximum Size of emitting particles.
  17781. */
  17782. maxSize: number;
  17783. /**
  17784. * Minimum scale of emitting particles on X axis.
  17785. */
  17786. minScaleX: number;
  17787. /**
  17788. * Maximum scale of emitting particles on X axis.
  17789. */
  17790. maxScaleX: number;
  17791. /**
  17792. * Minimum scale of emitting particles on Y axis.
  17793. */
  17794. minScaleY: number;
  17795. /**
  17796. * Maximum scale of emitting particles on Y axis.
  17797. */
  17798. maxScaleY: number;
  17799. /**
  17800. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17801. */
  17802. color1: Color4;
  17803. /**
  17804. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  17805. */
  17806. color2: Color4;
  17807. /**
  17808. * Color the particle will have at the end of its lifetime.
  17809. */
  17810. colorDead: Color4;
  17811. /**
  17812. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  17813. */
  17814. emitRate: number;
  17815. /**
  17816. * You can use gravity if you want to give an orientation to your particles.
  17817. */
  17818. gravity: Vector3;
  17819. /**
  17820. * Minimum power of emitting particles.
  17821. */
  17822. minEmitPower: number;
  17823. /**
  17824. * Maximum power of emitting particles.
  17825. */
  17826. maxEmitPower: number;
  17827. /**
  17828. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17829. */
  17830. minAngularSpeed: number;
  17831. /**
  17832. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17833. */
  17834. maxAngularSpeed: number;
  17835. /**
  17836. * Gets or sets the minimal initial rotation in radians.
  17837. */
  17838. minInitialRotation: number;
  17839. /**
  17840. * Gets or sets the maximal initial rotation in radians.
  17841. */
  17842. maxInitialRotation: number;
  17843. /**
  17844. * The particle emitter type defines the emitter used by the particle system.
  17845. * It can be for example box, sphere, or cone...
  17846. */
  17847. particleEmitterType: Nullable<IParticleEmitterType>;
  17848. /**
  17849. * Defines the delay in milliseconds before starting the system (0 by default)
  17850. */
  17851. startDelay: number;
  17852. /**
  17853. * 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
  17854. */
  17855. preWarmCycles: number;
  17856. /**
  17857. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  17858. */
  17859. preWarmStepOffset: number;
  17860. /**
  17861. * 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)
  17862. */
  17863. spriteCellChangeSpeed: number;
  17864. /**
  17865. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17866. */
  17867. startSpriteCellID: number;
  17868. /**
  17869. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17870. */
  17871. endSpriteCellID: number;
  17872. /**
  17873. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17874. */
  17875. spriteCellWidth: number;
  17876. /**
  17877. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17878. */
  17879. spriteCellHeight: number;
  17880. /**
  17881. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17882. */
  17883. spriteRandomStartCell: boolean;
  17884. /**
  17885. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  17886. */
  17887. isAnimationSheetEnabled: boolean;
  17888. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17889. translationPivot: Vector2;
  17890. /**
  17891. * Gets or sets a texture used to add random noise to particle positions
  17892. */
  17893. noiseTexture: Nullable<BaseTexture>;
  17894. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17895. noiseStrength: Vector3;
  17896. /**
  17897. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17898. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17899. */
  17900. billboardMode: number;
  17901. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17902. limitVelocityDamping: number;
  17903. /**
  17904. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17905. */
  17906. beginAnimationOnStart: boolean;
  17907. /**
  17908. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17909. */
  17910. beginAnimationFrom: number;
  17911. /**
  17912. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17913. */
  17914. beginAnimationTo: number;
  17915. /**
  17916. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17917. */
  17918. beginAnimationLoop: boolean;
  17919. /**
  17920. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  17921. */
  17922. disposeOnStop: boolean;
  17923. /**
  17924. * Gets the maximum number of particles active at the same time.
  17925. * @returns The max number of active particles.
  17926. */
  17927. getCapacity(): number;
  17928. /**
  17929. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17930. * @returns True if it has been started, otherwise false.
  17931. */
  17932. isStarted(): boolean;
  17933. /**
  17934. * Animates the particle system for this frame.
  17935. */
  17936. animate(): void;
  17937. /**
  17938. * Renders the particle system in its current state.
  17939. * @returns the current number of particles
  17940. */
  17941. render(): number;
  17942. /**
  17943. * Dispose the particle system and frees its associated resources.
  17944. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17945. */
  17946. dispose(disposeTexture?: boolean): void;
  17947. /**
  17948. * Clones the particle system.
  17949. * @param name The name of the cloned object
  17950. * @param newEmitter The new emitter to use
  17951. * @returns the cloned particle system
  17952. */
  17953. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  17954. /**
  17955. * Serializes the particle system to a JSON object.
  17956. * @returns the JSON object
  17957. */
  17958. serialize(): any;
  17959. /**
  17960. * Rebuild the particle system
  17961. */
  17962. rebuild(): void;
  17963. /**
  17964. * Starts the particle system and begins to emit
  17965. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  17966. */
  17967. start(delay?: number): void;
  17968. /**
  17969. * Stops the particle system.
  17970. */
  17971. stop(): void;
  17972. /**
  17973. * Remove all active particles
  17974. */
  17975. reset(): void;
  17976. /**
  17977. * Is this system ready to be used/rendered
  17978. * @return true if the system is ready
  17979. */
  17980. isReady(): boolean;
  17981. /**
  17982. * Adds a new color gradient
  17983. * @param gradient defines the gradient to use (between 0 and 1)
  17984. * @param color1 defines the color to affect to the specified gradient
  17985. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17986. * @returns the current particle system
  17987. */
  17988. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17989. /**
  17990. * Remove a specific color gradient
  17991. * @param gradient defines the gradient to remove
  17992. * @returns the current particle system
  17993. */
  17994. removeColorGradient(gradient: number): IParticleSystem;
  17995. /**
  17996. * Adds a new size gradient
  17997. * @param gradient defines the gradient to use (between 0 and 1)
  17998. * @param factor defines the size factor to affect to the specified gradient
  17999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18000. * @returns the current particle system
  18001. */
  18002. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18003. /**
  18004. * Remove a specific size gradient
  18005. * @param gradient defines the gradient to remove
  18006. * @returns the current particle system
  18007. */
  18008. removeSizeGradient(gradient: number): IParticleSystem;
  18009. /**
  18010. * Gets the current list of color gradients.
  18011. * You must use addColorGradient and removeColorGradient to udpate this list
  18012. * @returns the list of color gradients
  18013. */
  18014. getColorGradients(): Nullable<Array<ColorGradient>>;
  18015. /**
  18016. * Gets the current list of size gradients.
  18017. * You must use addSizeGradient and removeSizeGradient to udpate this list
  18018. * @returns the list of size gradients
  18019. */
  18020. getSizeGradients(): Nullable<Array<FactorGradient>>;
  18021. /**
  18022. * Gets the current list of angular speed gradients.
  18023. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  18024. * @returns the list of angular speed gradients
  18025. */
  18026. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  18027. /**
  18028. * Adds a new angular speed gradient
  18029. * @param gradient defines the gradient to use (between 0 and 1)
  18030. * @param factor defines the angular speed to affect to the specified gradient
  18031. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18032. * @returns the current particle system
  18033. */
  18034. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18035. /**
  18036. * Remove a specific angular speed gradient
  18037. * @param gradient defines the gradient to remove
  18038. * @returns the current particle system
  18039. */
  18040. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  18041. /**
  18042. * Gets the current list of velocity gradients.
  18043. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  18044. * @returns the list of velocity gradients
  18045. */
  18046. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  18047. /**
  18048. * Adds a new velocity gradient
  18049. * @param gradient defines the gradient to use (between 0 and 1)
  18050. * @param factor defines the velocity to affect to the specified gradient
  18051. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18052. * @returns the current particle system
  18053. */
  18054. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18055. /**
  18056. * Remove a specific velocity gradient
  18057. * @param gradient defines the gradient to remove
  18058. * @returns the current particle system
  18059. */
  18060. removeVelocityGradient(gradient: number): IParticleSystem;
  18061. /**
  18062. * Gets the current list of limit velocity gradients.
  18063. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  18064. * @returns the list of limit velocity gradients
  18065. */
  18066. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  18067. /**
  18068. * Adds a new limit velocity gradient
  18069. * @param gradient defines the gradient to use (between 0 and 1)
  18070. * @param factor defines the limit velocity to affect to the specified gradient
  18071. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18072. * @returns the current particle system
  18073. */
  18074. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18075. /**
  18076. * Remove a specific limit velocity gradient
  18077. * @param gradient defines the gradient to remove
  18078. * @returns the current particle system
  18079. */
  18080. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  18081. /**
  18082. * Adds a new drag gradient
  18083. * @param gradient defines the gradient to use (between 0 and 1)
  18084. * @param factor defines the drag to affect to the specified gradient
  18085. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18086. * @returns the current particle system
  18087. */
  18088. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18089. /**
  18090. * Remove a specific drag gradient
  18091. * @param gradient defines the gradient to remove
  18092. * @returns the current particle system
  18093. */
  18094. removeDragGradient(gradient: number): IParticleSystem;
  18095. /**
  18096. * Gets the current list of drag gradients.
  18097. * You must use addDragGradient and removeDragGradient to udpate this list
  18098. * @returns the list of drag gradients
  18099. */
  18100. getDragGradients(): Nullable<Array<FactorGradient>>;
  18101. /**
  18102. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  18103. * @param gradient defines the gradient to use (between 0 and 1)
  18104. * @param factor defines the emit rate to affect to the specified gradient
  18105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18106. * @returns the current particle system
  18107. */
  18108. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18109. /**
  18110. * Remove a specific emit rate gradient
  18111. * @param gradient defines the gradient to remove
  18112. * @returns the current particle system
  18113. */
  18114. removeEmitRateGradient(gradient: number): IParticleSystem;
  18115. /**
  18116. * Gets the current list of emit rate gradients.
  18117. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  18118. * @returns the list of emit rate gradients
  18119. */
  18120. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  18121. /**
  18122. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  18123. * @param gradient defines the gradient to use (between 0 and 1)
  18124. * @param factor defines the start size to affect to the specified gradient
  18125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18126. * @returns the current particle system
  18127. */
  18128. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18129. /**
  18130. * Remove a specific start size gradient
  18131. * @param gradient defines the gradient to remove
  18132. * @returns the current particle system
  18133. */
  18134. removeStartSizeGradient(gradient: number): IParticleSystem;
  18135. /**
  18136. * Gets the current list of start size gradients.
  18137. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  18138. * @returns the list of start size gradients
  18139. */
  18140. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  18141. /**
  18142. * Adds a new life time gradient
  18143. * @param gradient defines the gradient to use (between 0 and 1)
  18144. * @param factor defines the life time factor to affect to the specified gradient
  18145. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  18146. * @returns the current particle system
  18147. */
  18148. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  18149. /**
  18150. * Remove a specific life time gradient
  18151. * @param gradient defines the gradient to remove
  18152. * @returns the current particle system
  18153. */
  18154. removeLifeTimeGradient(gradient: number): IParticleSystem;
  18155. /**
  18156. * Gets the current list of life time gradients.
  18157. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  18158. * @returns the list of life time gradients
  18159. */
  18160. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  18161. /**
  18162. * Gets the current list of color gradients.
  18163. * You must use addColorGradient and removeColorGradient to udpate this list
  18164. * @returns the list of color gradients
  18165. */
  18166. getColorGradients(): Nullable<Array<ColorGradient>>;
  18167. /**
  18168. * Adds a new ramp gradient used to remap particle colors
  18169. * @param gradient defines the gradient to use (between 0 and 1)
  18170. * @param color defines the color to affect to the specified gradient
  18171. * @returns the current particle system
  18172. */
  18173. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  18174. /**
  18175. * Gets the current list of ramp gradients.
  18176. * You must use addRampGradient and removeRampGradient to udpate this list
  18177. * @returns the list of ramp gradients
  18178. */
  18179. getRampGradients(): Nullable<Array<Color3Gradient>>;
  18180. /** Gets or sets a boolean indicating that ramp gradients must be used
  18181. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  18182. */
  18183. useRampGradients: boolean;
  18184. /**
  18185. * Adds a new color remap gradient
  18186. * @param gradient defines the gradient to use (between 0 and 1)
  18187. * @param min defines the color remap minimal range
  18188. * @param max defines the color remap maximal range
  18189. * @returns the current particle system
  18190. */
  18191. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18192. /**
  18193. * Gets the current list of color remap gradients.
  18194. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  18195. * @returns the list of color remap gradients
  18196. */
  18197. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  18198. /**
  18199. * Adds a new alpha remap gradient
  18200. * @param gradient defines the gradient to use (between 0 and 1)
  18201. * @param min defines the alpha remap minimal range
  18202. * @param max defines the alpha remap maximal range
  18203. * @returns the current particle system
  18204. */
  18205. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  18206. /**
  18207. * Gets the current list of alpha remap gradients.
  18208. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  18209. * @returns the list of alpha remap gradients
  18210. */
  18211. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  18212. /**
  18213. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  18214. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18215. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18216. * @returns the emitter
  18217. */
  18218. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  18219. /**
  18220. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  18221. * @param radius The radius of the hemisphere to emit from
  18222. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18223. * @returns the emitter
  18224. */
  18225. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  18226. /**
  18227. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  18228. * @param radius The radius of the sphere to emit from
  18229. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  18230. * @returns the emitter
  18231. */
  18232. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  18233. /**
  18234. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  18235. * @param radius The radius of the sphere to emit from
  18236. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  18237. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  18238. * @returns the emitter
  18239. */
  18240. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18241. /**
  18242. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  18243. * @param radius The radius of the emission cylinder
  18244. * @param height The height of the emission cylinder
  18245. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  18246. * @param directionRandomizer How much to randomize the particle direction [0-1]
  18247. * @returns the emitter
  18248. */
  18249. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  18250. /**
  18251. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  18252. * @param radius The radius of the cylinder to emit from
  18253. * @param height The height of the emission cylinder
  18254. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18255. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  18256. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  18257. * @returns the emitter
  18258. */
  18259. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  18260. /**
  18261. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  18262. * @param radius The radius of the cone to emit from
  18263. * @param angle The base angle of the cone
  18264. * @returns the emitter
  18265. */
  18266. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  18267. /**
  18268. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  18269. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  18270. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  18271. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18272. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  18273. * @returns the emitter
  18274. */
  18275. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  18276. /**
  18277. * Get hosting scene
  18278. * @returns the scene
  18279. */
  18280. getScene(): Scene;
  18281. }
  18282. }
  18283. declare module BABYLON {
  18284. /**
  18285. * Creates an instance based on a source mesh.
  18286. */
  18287. export class InstancedMesh extends AbstractMesh {
  18288. private _sourceMesh;
  18289. private _currentLOD;
  18290. /** @hidden */ private _indexInSourceMeshInstanceArray: number;
  18291. constructor(name: string, source: Mesh);
  18292. /**
  18293. * Returns the string "InstancedMesh".
  18294. */
  18295. getClassName(): string;
  18296. /** Gets the list of lights affecting that mesh */
  18297. readonly lightSources: Light[]; private _resyncLightSources(): void; private _resyncLighSource(light: Light): void; private _removeLightSource(light: Light): void;
  18298. /**
  18299. * If the source mesh receives shadows
  18300. */
  18301. readonly receiveShadows: boolean;
  18302. /**
  18303. * The material of the source mesh
  18304. */
  18305. readonly material: Nullable<Material>;
  18306. /**
  18307. * Visibility of the source mesh
  18308. */
  18309. readonly visibility: number;
  18310. /**
  18311. * Skeleton of the source mesh
  18312. */
  18313. readonly skeleton: Nullable<Skeleton>;
  18314. /**
  18315. * Rendering ground id of the source mesh
  18316. */
  18317. renderingGroupId: number;
  18318. /**
  18319. * Returns the total number of vertices (integer).
  18320. */
  18321. getTotalVertices(): number;
  18322. /**
  18323. * Returns a positive integer : the total number of indices in this mesh geometry.
  18324. * @returns the numner of indices or zero if the mesh has no geometry.
  18325. */
  18326. getTotalIndices(): number;
  18327. /**
  18328. * The source mesh of the instance
  18329. */
  18330. readonly sourceMesh: Mesh;
  18331. /**
  18332. * Is this node ready to be used/rendered
  18333. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  18334. * @return {boolean} is it ready
  18335. */
  18336. isReady(completeCheck?: boolean): boolean;
  18337. /**
  18338. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  18339. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  18340. * @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.
  18341. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  18342. */
  18343. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  18344. /**
  18345. * Sets the vertex data of the mesh geometry for the requested `kind`.
  18346. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  18347. * The `data` are either a numeric array either a Float32Array.
  18348. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  18349. * 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).
  18350. * Note that a new underlying VertexBuffer object is created each call.
  18351. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  18352. *
  18353. * Possible `kind` values :
  18354. * - VertexBuffer.PositionKind
  18355. * - VertexBuffer.UVKind
  18356. * - VertexBuffer.UV2Kind
  18357. * - VertexBuffer.UV3Kind
  18358. * - VertexBuffer.UV4Kind
  18359. * - VertexBuffer.UV5Kind
  18360. * - VertexBuffer.UV6Kind
  18361. * - VertexBuffer.ColorKind
  18362. * - VertexBuffer.MatricesIndicesKind
  18363. * - VertexBuffer.MatricesIndicesExtraKind
  18364. * - VertexBuffer.MatricesWeightsKind
  18365. * - VertexBuffer.MatricesWeightsExtraKind
  18366. *
  18367. * Returns the Mesh.
  18368. */
  18369. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  18370. /**
  18371. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  18372. * If the mesh has no geometry, it is simply returned as it is.
  18373. * The `data` are either a numeric array either a Float32Array.
  18374. * No new underlying VertexBuffer object is created.
  18375. * 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.
  18376. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  18377. *
  18378. * Possible `kind` values :
  18379. * - VertexBuffer.PositionKind
  18380. * - VertexBuffer.UVKind
  18381. * - VertexBuffer.UV2Kind
  18382. * - VertexBuffer.UV3Kind
  18383. * - VertexBuffer.UV4Kind
  18384. * - VertexBuffer.UV5Kind
  18385. * - VertexBuffer.UV6Kind
  18386. * - VertexBuffer.ColorKind
  18387. * - VertexBuffer.MatricesIndicesKind
  18388. * - VertexBuffer.MatricesIndicesExtraKind
  18389. * - VertexBuffer.MatricesWeightsKind
  18390. * - VertexBuffer.MatricesWeightsExtraKind
  18391. *
  18392. * Returns the Mesh.
  18393. */
  18394. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  18395. /**
  18396. * Sets the mesh indices.
  18397. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  18398. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  18399. * This method creates a new index buffer each call.
  18400. * Returns the Mesh.
  18401. */
  18402. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  18403. /**
  18404. * Boolean : True if the mesh owns the requested kind of data.
  18405. */
  18406. isVerticesDataPresent(kind: string): boolean;
  18407. /**
  18408. * Returns an array of indices (IndicesArray).
  18409. */
  18410. getIndices(): Nullable<IndicesArray>; protected readonly _positions: Nullable<Vector3[]>;
  18411. /**
  18412. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  18413. * This means the mesh underlying bounding box and sphere are recomputed.
  18414. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  18415. * @returns the current mesh
  18416. */
  18417. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  18418. /** @hidden */ private _preActivate(): InstancedMesh;
  18419. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  18420. /** @hidden */ private _postActivate(): void;
  18421. getWorldMatrix(): Matrix;
  18422. readonly isAnInstance: boolean;
  18423. /**
  18424. * Returns the current associated LOD AbstractMesh.
  18425. */
  18426. getLOD(camera: Camera): AbstractMesh;
  18427. /** @hidden */ private _syncSubMeshes(): InstancedMesh;
  18428. /** @hidden */ private _generatePointsArray(): boolean;
  18429. /**
  18430. * Creates a new InstancedMesh from the current mesh.
  18431. * - name (string) : the cloned mesh name
  18432. * - newParent (optional Node) : the optional Node to parent the clone to.
  18433. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  18434. *
  18435. * Returns the clone.
  18436. */
  18437. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): InstancedMesh;
  18438. /**
  18439. * Disposes the InstancedMesh.
  18440. * Returns nothing.
  18441. */
  18442. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18443. }
  18444. }
  18445. declare module BABYLON {
  18446. /**
  18447. * Defines the options associated with the creation of a shader material.
  18448. */
  18449. export interface IShaderMaterialOptions {
  18450. /**
  18451. * Does the material work in alpha blend mode
  18452. */
  18453. needAlphaBlending: boolean;
  18454. /**
  18455. * Does the material work in alpha test mode
  18456. */
  18457. needAlphaTesting: boolean;
  18458. /**
  18459. * The list of attribute names used in the shader
  18460. */
  18461. attributes: string[];
  18462. /**
  18463. * The list of unifrom names used in the shader
  18464. */
  18465. uniforms: string[];
  18466. /**
  18467. * The list of UBO names used in the shader
  18468. */
  18469. uniformBuffers: string[];
  18470. /**
  18471. * The list of sampler names used in the shader
  18472. */
  18473. samplers: string[];
  18474. /**
  18475. * The list of defines used in the shader
  18476. */
  18477. defines: string[];
  18478. }
  18479. /**
  18480. * 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.
  18481. *
  18482. * This returned material effects how the mesh will look based on the code in the shaders.
  18483. *
  18484. * @see http://doc.babylonjs.com/how_to/shader_material
  18485. */
  18486. export class ShaderMaterial extends Material {
  18487. private _shaderPath;
  18488. private _options;
  18489. private _textures;
  18490. private _textureArrays;
  18491. private _floats;
  18492. private _ints;
  18493. private _floatsArrays;
  18494. private _colors3;
  18495. private _colors3Arrays;
  18496. private _colors4;
  18497. private _colors4Arrays;
  18498. private _vectors2;
  18499. private _vectors3;
  18500. private _vectors4;
  18501. private _matrices;
  18502. private _matrices3x3;
  18503. private _matrices2x2;
  18504. private _vectors2Arrays;
  18505. private _vectors3Arrays;
  18506. private _vectors4Arrays;
  18507. private _cachedWorldViewMatrix;
  18508. private _cachedWorldViewProjectionMatrix;
  18509. private _renderId;
  18510. /**
  18511. * Instantiate a new shader material.
  18512. * 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.
  18513. * This returned material effects how the mesh will look based on the code in the shaders.
  18514. * @see http://doc.babylonjs.com/how_to/shader_material
  18515. * @param name Define the name of the material in the scene
  18516. * @param scene Define the scene the material belongs to
  18517. * @param shaderPath Defines the route to the shader code in one of three ways:
  18518. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  18519. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  18520. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  18521. * @param options Define the options used to create the shader
  18522. */
  18523. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  18524. /**
  18525. * Gets the options used to compile the shader.
  18526. * They can be modified to trigger a new compilation
  18527. */
  18528. readonly options: IShaderMaterialOptions;
  18529. /**
  18530. * Gets the current class name of the material e.g. "ShaderMaterial"
  18531. * Mainly use in serialization.
  18532. * @returns the class name
  18533. */
  18534. getClassName(): string;
  18535. /**
  18536. * Specifies if the material will require alpha blending
  18537. * @returns a boolean specifying if alpha blending is needed
  18538. */
  18539. needAlphaBlending(): boolean;
  18540. /**
  18541. * Specifies if this material should be rendered in alpha test mode
  18542. * @returns a boolean specifying if an alpha test is needed.
  18543. */
  18544. needAlphaTesting(): boolean;
  18545. private _checkUniform;
  18546. /**
  18547. * Set a texture in the shader.
  18548. * @param name Define the name of the uniform samplers as defined in the shader
  18549. * @param texture Define the texture to bind to this sampler
  18550. * @return the material itself allowing "fluent" like uniform updates
  18551. */
  18552. setTexture(name: string, texture: Texture): ShaderMaterial;
  18553. /**
  18554. * Set a texture array in the shader.
  18555. * @param name Define the name of the uniform sampler array as defined in the shader
  18556. * @param textures Define the list of textures to bind to this sampler
  18557. * @return the material itself allowing "fluent" like uniform updates
  18558. */
  18559. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  18560. /**
  18561. * Set a float in the shader.
  18562. * @param name Define the name of the uniform as defined in the shader
  18563. * @param value Define the value to give to the uniform
  18564. * @return the material itself allowing "fluent" like uniform updates
  18565. */
  18566. setFloat(name: string, value: number): ShaderMaterial;
  18567. /**
  18568. * Set a int in the shader.
  18569. * @param name Define the name of the uniform as defined in the shader
  18570. * @param value Define the value to give to the uniform
  18571. * @return the material itself allowing "fluent" like uniform updates
  18572. */
  18573. setInt(name: string, value: number): ShaderMaterial;
  18574. /**
  18575. * Set an array of floats in the shader.
  18576. * @param name Define the name of the uniform as defined in the shader
  18577. * @param value Define the value to give to the uniform
  18578. * @return the material itself allowing "fluent" like uniform updates
  18579. */
  18580. setFloats(name: string, value: number[]): ShaderMaterial;
  18581. /**
  18582. * Set a vec3 in the shader from a Color3.
  18583. * @param name Define the name of the uniform as defined in the shader
  18584. * @param value Define the value to give to the uniform
  18585. * @return the material itself allowing "fluent" like uniform updates
  18586. */
  18587. setColor3(name: string, value: Color3): ShaderMaterial;
  18588. /**
  18589. * Set a vec3 array in the shader from a Color3 array.
  18590. * @param name Define the name of the uniform as defined in the shader
  18591. * @param value Define the value to give to the uniform
  18592. * @return the material itself allowing "fluent" like uniform updates
  18593. */
  18594. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  18595. /**
  18596. * Set a vec4 in the shader from a Color4.
  18597. * @param name Define the name of the uniform as defined in the shader
  18598. * @param value Define the value to give to the uniform
  18599. * @return the material itself allowing "fluent" like uniform updates
  18600. */
  18601. setColor4(name: string, value: Color4): ShaderMaterial;
  18602. /**
  18603. * Set a vec4 array in the shader from a Color4 array.
  18604. * @param name Define the name of the uniform as defined in the shader
  18605. * @param value Define the value to give to the uniform
  18606. * @return the material itself allowing "fluent" like uniform updates
  18607. */
  18608. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  18609. /**
  18610. * Set a vec2 in the shader from a Vector2.
  18611. * @param name Define the name of the uniform as defined in the shader
  18612. * @param value Define the value to give to the uniform
  18613. * @return the material itself allowing "fluent" like uniform updates
  18614. */
  18615. setVector2(name: string, value: Vector2): ShaderMaterial;
  18616. /**
  18617. * Set a vec3 in the shader from a Vector3.
  18618. * @param name Define the name of the uniform as defined in the shader
  18619. * @param value Define the value to give to the uniform
  18620. * @return the material itself allowing "fluent" like uniform updates
  18621. */
  18622. setVector3(name: string, value: Vector3): ShaderMaterial;
  18623. /**
  18624. * Set a vec4 in the shader from a Vector4.
  18625. * @param name Define the name of the uniform as defined in the shader
  18626. * @param value Define the value to give to the uniform
  18627. * @return the material itself allowing "fluent" like uniform updates
  18628. */
  18629. setVector4(name: string, value: Vector4): ShaderMaterial;
  18630. /**
  18631. * Set a mat4 in the shader from a Matrix.
  18632. * @param name Define the name of the uniform as defined in the shader
  18633. * @param value Define the value to give to the uniform
  18634. * @return the material itself allowing "fluent" like uniform updates
  18635. */
  18636. setMatrix(name: string, value: Matrix): ShaderMaterial;
  18637. /**
  18638. * Set a mat3 in the shader from a Float32Array.
  18639. * @param name Define the name of the uniform as defined in the shader
  18640. * @param value Define the value to give to the uniform
  18641. * @return the material itself allowing "fluent" like uniform updates
  18642. */
  18643. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  18644. /**
  18645. * Set a mat2 in the shader from a Float32Array.
  18646. * @param name Define the name of the uniform as defined in the shader
  18647. * @param value Define the value to give to the uniform
  18648. * @return the material itself allowing "fluent" like uniform updates
  18649. */
  18650. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  18651. /**
  18652. * Set a vec2 array in the shader from a number array.
  18653. * @param name Define the name of the uniform as defined in the shader
  18654. * @param value Define the value to give to the uniform
  18655. * @return the material itself allowing "fluent" like uniform updates
  18656. */
  18657. setArray2(name: string, value: number[]): ShaderMaterial;
  18658. /**
  18659. * Set a vec3 array in the shader from a number array.
  18660. * @param name Define the name of the uniform as defined in the shader
  18661. * @param value Define the value to give to the uniform
  18662. * @return the material itself allowing "fluent" like uniform updates
  18663. */
  18664. setArray3(name: string, value: number[]): ShaderMaterial;
  18665. /**
  18666. * Set a vec4 array in the shader from a number array.
  18667. * @param name Define the name of the uniform as defined in the shader
  18668. * @param value Define the value to give to the uniform
  18669. * @return the material itself allowing "fluent" like uniform updates
  18670. */
  18671. setArray4(name: string, value: number[]): ShaderMaterial;
  18672. private _checkCache;
  18673. /**
  18674. * Specifies that the submesh is ready to be used
  18675. * @param mesh defines the mesh to check
  18676. * @param subMesh defines which submesh to check
  18677. * @param useInstances specifies that instances should be used
  18678. * @returns a boolean indicating that the submesh is ready or not
  18679. */
  18680. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  18681. /**
  18682. * Checks if the material is ready to render the requested mesh
  18683. * @param mesh Define the mesh to render
  18684. * @param useInstances Define whether or not the material is used with instances
  18685. * @returns true if ready, otherwise false
  18686. */
  18687. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  18688. /**
  18689. * Binds the world matrix to the material
  18690. * @param world defines the world transformation matrix
  18691. */
  18692. bindOnlyWorldMatrix(world: Matrix): void;
  18693. /**
  18694. * Binds the material to the mesh
  18695. * @param world defines the world transformation matrix
  18696. * @param mesh defines the mesh to bind the material to
  18697. */
  18698. bind(world: Matrix, mesh?: Mesh): void;
  18699. /**
  18700. * Gets the active textures from the material
  18701. * @returns an array of textures
  18702. */
  18703. getActiveTextures(): BaseTexture[];
  18704. /**
  18705. * Specifies if the material uses a texture
  18706. * @param texture defines the texture to check against the material
  18707. * @returns a boolean specifying if the material uses the texture
  18708. */
  18709. hasTexture(texture: BaseTexture): boolean;
  18710. /**
  18711. * Makes a duplicate of the material, and gives it a new name
  18712. * @param name defines the new name for the duplicated material
  18713. * @returns the cloned material
  18714. */
  18715. clone(name: string): ShaderMaterial;
  18716. /**
  18717. * Disposes the material
  18718. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  18719. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  18720. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  18721. */
  18722. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  18723. /**
  18724. * Serializes this material in a JSON representation
  18725. * @returns the serialized material object
  18726. */
  18727. serialize(): any;
  18728. /**
  18729. * Creates a shader material from parsed shader material data
  18730. * @param source defines the JSON represnetation of the material
  18731. * @param scene defines the hosting scene
  18732. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  18733. * @returns a new material
  18734. */
  18735. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  18736. }
  18737. }
  18738. declare module BABYLON {
  18739. /** @hidden */
  18740. export var colorPixelShader: {
  18741. name: string;
  18742. shader: string;
  18743. };
  18744. }
  18745. declare module BABYLON {
  18746. /** @hidden */
  18747. export var colorVertexShader: {
  18748. name: string;
  18749. shader: string;
  18750. };
  18751. }
  18752. declare module BABYLON {
  18753. /**
  18754. * Line mesh
  18755. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  18756. */
  18757. export class LinesMesh extends Mesh {
  18758. /**
  18759. * If vertex color should be applied to the mesh
  18760. */
  18761. readonly useVertexColor?: boolean | undefined;
  18762. /**
  18763. * If vertex alpha should be applied to the mesh
  18764. */
  18765. readonly useVertexAlpha?: boolean | undefined;
  18766. /**
  18767. * Color of the line (Default: White)
  18768. */
  18769. color: Color3;
  18770. /**
  18771. * Alpha of the line (Default: 1)
  18772. */
  18773. alpha: number;
  18774. /**
  18775. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18776. * This margin is expressed in world space coordinates, so its value may vary.
  18777. * Default value is 0.1
  18778. */
  18779. intersectionThreshold: number;
  18780. private _colorShader;
  18781. private color4;
  18782. /**
  18783. * Creates a new LinesMesh
  18784. * @param name defines the name
  18785. * @param scene defines the hosting scene
  18786. * @param parent defines the parent mesh if any
  18787. * @param source defines the optional source LinesMesh used to clone data from
  18788. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  18789. * When false, achieved by calling a clone(), also passing False.
  18790. * This will make creation of children, recursive.
  18791. * @param useVertexColor defines if this LinesMesh supports vertex color
  18792. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  18793. */
  18794. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  18795. /**
  18796. * If vertex color should be applied to the mesh
  18797. */
  18798. useVertexColor?: boolean | undefined,
  18799. /**
  18800. * If vertex alpha should be applied to the mesh
  18801. */
  18802. useVertexAlpha?: boolean | undefined);
  18803. private _addClipPlaneDefine;
  18804. private _removeClipPlaneDefine;
  18805. isReady(): boolean;
  18806. /**
  18807. * Returns the string "LineMesh"
  18808. */
  18809. getClassName(): string;
  18810. /**
  18811. * @hidden
  18812. */
  18813. /**
  18814. * @hidden
  18815. */
  18816. material: Material;
  18817. /**
  18818. * @hidden
  18819. */
  18820. readonly checkCollisions: boolean;
  18821. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  18822. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  18823. /**
  18824. * Disposes of the line mesh
  18825. * @param doNotRecurse If children should be disposed
  18826. */
  18827. dispose(doNotRecurse?: boolean): void;
  18828. /**
  18829. * Returns a new LineMesh object cloned from the current one.
  18830. */
  18831. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  18832. /**
  18833. * Creates a new InstancedLinesMesh object from the mesh model.
  18834. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  18835. * @param name defines the name of the new instance
  18836. * @returns a new InstancedLinesMesh
  18837. */
  18838. createInstance(name: string): InstancedLinesMesh;
  18839. }
  18840. /**
  18841. * Creates an instance based on a source LinesMesh
  18842. */
  18843. export class InstancedLinesMesh extends InstancedMesh {
  18844. /**
  18845. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  18846. * This margin is expressed in world space coordinates, so its value may vary.
  18847. * Initilized with the intersectionThreshold value of the source LinesMesh
  18848. */
  18849. intersectionThreshold: number;
  18850. constructor(name: string, source: LinesMesh);
  18851. /**
  18852. * Returns the string "InstancedLinesMesh".
  18853. */
  18854. getClassName(): string;
  18855. }
  18856. }
  18857. declare module BABYLON {
  18858. /** @hidden */
  18859. export var linePixelShader: {
  18860. name: string;
  18861. shader: string;
  18862. };
  18863. }
  18864. declare module BABYLON {
  18865. /** @hidden */
  18866. export var lineVertexShader: {
  18867. name: string;
  18868. shader: string;
  18869. };
  18870. }
  18871. declare module BABYLON {
  18872. interface AbstractMesh {
  18873. /**
  18874. * Gets the edgesRenderer associated with the mesh
  18875. */
  18876. edgesRenderer: Nullable<EdgesRenderer>;
  18877. }
  18878. interface LinesMesh {
  18879. /**
  18880. * Enables the edge rendering mode on the mesh.
  18881. * This mode makes the mesh edges visible
  18882. * @param epsilon defines the maximal distance between two angles to detect a face
  18883. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18884. * @returns the currentAbstractMesh
  18885. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18886. */
  18887. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  18888. }
  18889. interface InstancedLinesMesh {
  18890. /**
  18891. * Enables the edge rendering mode on the mesh.
  18892. * This mode makes the mesh edges visible
  18893. * @param epsilon defines the maximal distance between two angles to detect a face
  18894. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  18895. * @returns the current InstancedLinesMesh
  18896. * @see https://www.babylonjs-playground.com/#19O9TU#0
  18897. */
  18898. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  18899. }
  18900. /**
  18901. * Defines the minimum contract an Edges renderer should follow.
  18902. */
  18903. export interface IEdgesRenderer extends IDisposable {
  18904. /**
  18905. * Gets or sets a boolean indicating if the edgesRenderer is active
  18906. */
  18907. isEnabled: boolean;
  18908. /**
  18909. * Renders the edges of the attached mesh,
  18910. */
  18911. render(): void;
  18912. /**
  18913. * Checks wether or not the edges renderer is ready to render.
  18914. * @return true if ready, otherwise false.
  18915. */
  18916. isReady(): boolean;
  18917. }
  18918. /**
  18919. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  18920. */
  18921. export class EdgesRenderer implements IEdgesRenderer {
  18922. /**
  18923. * Define the size of the edges with an orthographic camera
  18924. */
  18925. edgesWidthScalerForOrthographic: number;
  18926. /**
  18927. * Define the size of the edges with a perspective camera
  18928. */
  18929. edgesWidthScalerForPerspective: number;
  18930. protected _source: AbstractMesh;
  18931. protected _linesPositions: number[];
  18932. protected _linesNormals: number[];
  18933. protected _linesIndices: number[];
  18934. protected _epsilon: number;
  18935. protected _indicesCount: number;
  18936. protected _lineShader: ShaderMaterial;
  18937. protected _ib: DataBuffer;
  18938. protected _buffers: {
  18939. [key: string]: Nullable<VertexBuffer>;
  18940. };
  18941. protected _checkVerticesInsteadOfIndices: boolean;
  18942. private _meshRebuildObserver;
  18943. private _meshDisposeObserver;
  18944. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  18945. isEnabled: boolean;
  18946. /**
  18947. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  18948. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  18949. * @param source Mesh used to create edges
  18950. * @param epsilon sum of angles in adjacency to check for edge
  18951. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  18952. * @param generateEdgesLines - should generate Lines or only prepare resources.
  18953. */
  18954. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  18955. protected _prepareRessources(): void;
  18956. /** @hidden */ private _rebuild(): void;
  18957. /**
  18958. * Releases the required resources for the edges renderer
  18959. */
  18960. dispose(): void;
  18961. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  18962. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  18963. /**
  18964. * Checks if the pair of p0 and p1 is en edge
  18965. * @param faceIndex
  18966. * @param edge
  18967. * @param faceNormals
  18968. * @param p0
  18969. * @param p1
  18970. * @private
  18971. */
  18972. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  18973. /**
  18974. * push line into the position, normal and index buffer
  18975. * @protected
  18976. */
  18977. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  18978. /**
  18979. * Generates lines edges from adjacencjes
  18980. * @private
  18981. */ private _generateEdgesLines(): void;
  18982. /**
  18983. * Checks wether or not the edges renderer is ready to render.
  18984. * @return true if ready, otherwise false.
  18985. */
  18986. isReady(): boolean;
  18987. /**
  18988. * Renders the edges of the attached mesh,
  18989. */
  18990. render(): void;
  18991. }
  18992. /**
  18993. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  18994. */
  18995. export class LineEdgesRenderer extends EdgesRenderer {
  18996. /**
  18997. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  18998. * @param source LineMesh used to generate edges
  18999. * @param epsilon not important (specified angle for edge detection)
  19000. * @param checkVerticesInsteadOfIndices not important for LineMesh
  19001. */
  19002. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  19003. /**
  19004. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  19005. */ private _generateEdgesLines(): void;
  19006. }
  19007. }
  19008. declare module BABYLON {
  19009. /**
  19010. * This represents the object necessary to create a rendering group.
  19011. * This is exclusively used and created by the rendering manager.
  19012. * To modify the behavior, you use the available helpers in your scene or meshes.
  19013. * @hidden
  19014. */
  19015. export class RenderingGroup {
  19016. index: number;
  19017. private static _zeroVector;
  19018. private _scene;
  19019. private _opaqueSubMeshes;
  19020. private _transparentSubMeshes;
  19021. private _alphaTestSubMeshes;
  19022. private _depthOnlySubMeshes;
  19023. private _particleSystems;
  19024. private _spriteManagers;
  19025. private _opaqueSortCompareFn;
  19026. private _alphaTestSortCompareFn;
  19027. private _transparentSortCompareFn;
  19028. private _renderOpaque;
  19029. private _renderAlphaTest;
  19030. private _renderTransparent;
  19031. /** @hidden */ private _edgesRenderers: SmartArray<IEdgesRenderer>;
  19032. onBeforeTransparentRendering: () => void;
  19033. /**
  19034. * Set the opaque sort comparison function.
  19035. * If null the sub meshes will be render in the order they were created
  19036. */
  19037. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19038. /**
  19039. * Set the alpha test sort comparison function.
  19040. * If null the sub meshes will be render in the order they were created
  19041. */
  19042. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19043. /**
  19044. * Set the transparent sort comparison function.
  19045. * If null the sub meshes will be render in the order they were created
  19046. */
  19047. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  19048. /**
  19049. * Creates a new rendering group.
  19050. * @param index The rendering group index
  19051. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  19052. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  19053. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  19054. */
  19055. 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>);
  19056. /**
  19057. * Render all the sub meshes contained in the group.
  19058. * @param customRenderFunction Used to override the default render behaviour of the group.
  19059. * @returns true if rendered some submeshes.
  19060. */
  19061. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  19062. /**
  19063. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  19064. * @param subMeshes The submeshes to render
  19065. */
  19066. private renderOpaqueSorted;
  19067. /**
  19068. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  19069. * @param subMeshes The submeshes to render
  19070. */
  19071. private renderAlphaTestSorted;
  19072. /**
  19073. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  19074. * @param subMeshes The submeshes to render
  19075. */
  19076. private renderTransparentSorted;
  19077. /**
  19078. * Renders the submeshes in a specified order.
  19079. * @param subMeshes The submeshes to sort before render
  19080. * @param sortCompareFn The comparison function use to sort
  19081. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  19082. * @param transparent Specifies to activate blending if true
  19083. */
  19084. private static renderSorted;
  19085. /**
  19086. * Renders the submeshes in the order they were dispatched (no sort applied).
  19087. * @param subMeshes The submeshes to render
  19088. */
  19089. private static renderUnsorted;
  19090. /**
  19091. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19092. * are rendered back to front if in the same alpha index.
  19093. *
  19094. * @param a The first submesh
  19095. * @param b The second submesh
  19096. * @returns The result of the comparison
  19097. */
  19098. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  19099. /**
  19100. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19101. * are rendered back to front.
  19102. *
  19103. * @param a The first submesh
  19104. * @param b The second submesh
  19105. * @returns The result of the comparison
  19106. */
  19107. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  19108. /**
  19109. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  19110. * are rendered front to back (prevent overdraw).
  19111. *
  19112. * @param a The first submesh
  19113. * @param b The second submesh
  19114. * @returns The result of the comparison
  19115. */
  19116. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  19117. /**
  19118. * Resets the different lists of submeshes to prepare a new frame.
  19119. */
  19120. prepare(): void;
  19121. dispose(): void;
  19122. /**
  19123. * Inserts the submesh in its correct queue depending on its material.
  19124. * @param subMesh The submesh to dispatch
  19125. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19126. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19127. */
  19128. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19129. dispatchSprites(spriteManager: ISpriteManager): void;
  19130. dispatchParticles(particleSystem: IParticleSystem): void;
  19131. private _renderParticles;
  19132. private _renderSprites;
  19133. }
  19134. }
  19135. declare module BABYLON {
  19136. /**
  19137. * Interface describing the different options available in the rendering manager
  19138. * regarding Auto Clear between groups.
  19139. */
  19140. export interface IRenderingManagerAutoClearSetup {
  19141. /**
  19142. * Defines whether or not autoclear is enable.
  19143. */
  19144. autoClear: boolean;
  19145. /**
  19146. * Defines whether or not to autoclear the depth buffer.
  19147. */
  19148. depth: boolean;
  19149. /**
  19150. * Defines whether or not to autoclear the stencil buffer.
  19151. */
  19152. stencil: boolean;
  19153. }
  19154. /**
  19155. * This class is used by the onRenderingGroupObservable
  19156. */
  19157. export class RenderingGroupInfo {
  19158. /**
  19159. * The Scene that being rendered
  19160. */
  19161. scene: Scene;
  19162. /**
  19163. * The camera currently used for the rendering pass
  19164. */
  19165. camera: Nullable<Camera>;
  19166. /**
  19167. * The ID of the renderingGroup being processed
  19168. */
  19169. renderingGroupId: number;
  19170. }
  19171. /**
  19172. * This is the manager responsible of all the rendering for meshes sprites and particles.
  19173. * It is enable to manage the different groups as well as the different necessary sort functions.
  19174. * This should not be used directly aside of the few static configurations
  19175. */
  19176. export class RenderingManager {
  19177. /**
  19178. * The max id used for rendering groups (not included)
  19179. */
  19180. static MAX_RENDERINGGROUPS: number;
  19181. /**
  19182. * The min id used for rendering groups (included)
  19183. */
  19184. static MIN_RENDERINGGROUPS: number;
  19185. /**
  19186. * Used to globally prevent autoclearing scenes.
  19187. */
  19188. static AUTOCLEAR: boolean;
  19189. /**
  19190. * @hidden
  19191. */ private _useSceneAutoClearSetup: boolean;
  19192. private _scene;
  19193. private _renderingGroups;
  19194. private _depthStencilBufferAlreadyCleaned;
  19195. private _autoClearDepthStencil;
  19196. private _customOpaqueSortCompareFn;
  19197. private _customAlphaTestSortCompareFn;
  19198. private _customTransparentSortCompareFn;
  19199. private _renderingGroupInfo;
  19200. /**
  19201. * Instantiates a new rendering group for a particular scene
  19202. * @param scene Defines the scene the groups belongs to
  19203. */
  19204. constructor(scene: Scene);
  19205. private _clearDepthStencilBuffer;
  19206. /**
  19207. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  19208. * @hidden
  19209. */
  19210. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  19211. /**
  19212. * Resets the different information of the group to prepare a new frame
  19213. * @hidden
  19214. */
  19215. reset(): void;
  19216. /**
  19217. * Dispose and release the group and its associated resources.
  19218. * @hidden
  19219. */
  19220. dispose(): void;
  19221. /**
  19222. * Clear the info related to rendering groups preventing retention points during dispose.
  19223. */
  19224. freeRenderingGroups(): void;
  19225. private _prepareRenderingGroup;
  19226. /**
  19227. * Add a sprite manager to the rendering manager in order to render it this frame.
  19228. * @param spriteManager Define the sprite manager to render
  19229. */
  19230. dispatchSprites(spriteManager: ISpriteManager): void;
  19231. /**
  19232. * Add a particle system to the rendering manager in order to render it this frame.
  19233. * @param particleSystem Define the particle system to render
  19234. */
  19235. dispatchParticles(particleSystem: IParticleSystem): void;
  19236. /**
  19237. * Add a submesh to the manager in order to render it this frame
  19238. * @param subMesh The submesh to dispatch
  19239. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  19240. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  19241. */
  19242. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  19243. /**
  19244. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19245. * This allowed control for front to back rendering or reversly depending of the special needs.
  19246. *
  19247. * @param renderingGroupId The rendering group id corresponding to its index
  19248. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19249. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19250. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19251. */
  19252. 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;
  19253. /**
  19254. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19255. *
  19256. * @param renderingGroupId The rendering group id corresponding to its index
  19257. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19258. * @param depth Automatically clears depth between groups if true and autoClear is true.
  19259. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  19260. */
  19261. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  19262. /**
  19263. * Gets the current auto clear configuration for one rendering group of the rendering
  19264. * manager.
  19265. * @param index the rendering group index to get the information for
  19266. * @returns The auto clear setup for the requested rendering group
  19267. */
  19268. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  19269. }
  19270. }
  19271. declare module BABYLON {
  19272. /**
  19273. * This Helps creating a texture that will be created from a camera in your scene.
  19274. * It is basically a dynamic texture that could be used to create special effects for instance.
  19275. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  19276. */
  19277. export class RenderTargetTexture extends Texture {
  19278. isCube: boolean;
  19279. /**
  19280. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  19281. */
  19282. static readonly REFRESHRATE_RENDER_ONCE: number;
  19283. /**
  19284. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  19285. */
  19286. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  19287. /**
  19288. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  19289. * the central point of your effect and can save a lot of performances.
  19290. */
  19291. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  19292. /**
  19293. * Use this predicate to dynamically define the list of mesh you want to render.
  19294. * If set, the renderList property will be overwritten.
  19295. */
  19296. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  19297. private _renderList;
  19298. /**
  19299. * Use this list to define the list of mesh you want to render.
  19300. */
  19301. renderList: Nullable<Array<AbstractMesh>>;
  19302. private _hookArray;
  19303. /**
  19304. * Define if particles should be rendered in your texture.
  19305. */
  19306. renderParticles: boolean;
  19307. /**
  19308. * Define if sprites should be rendered in your texture.
  19309. */
  19310. renderSprites: boolean;
  19311. /**
  19312. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  19313. */
  19314. coordinatesMode: number;
  19315. /**
  19316. * Define the camera used to render the texture.
  19317. */
  19318. activeCamera: Nullable<Camera>;
  19319. /**
  19320. * Override the render function of the texture with your own one.
  19321. */
  19322. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  19323. /**
  19324. * Define if camera post processes should be use while rendering the texture.
  19325. */
  19326. useCameraPostProcesses: boolean;
  19327. /**
  19328. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  19329. */
  19330. ignoreCameraViewport: boolean;
  19331. private _postProcessManager;
  19332. private _postProcesses;
  19333. private _resizeObserver;
  19334. /**
  19335. * An event triggered when the texture is unbind.
  19336. */
  19337. onBeforeBindObservable: Observable<RenderTargetTexture>;
  19338. /**
  19339. * An event triggered when the texture is unbind.
  19340. */
  19341. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  19342. private _onAfterUnbindObserver;
  19343. /**
  19344. * Set a after unbind callback in the texture.
  19345. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  19346. */
  19347. onAfterUnbind: () => void;
  19348. /**
  19349. * An event triggered before rendering the texture
  19350. */
  19351. onBeforeRenderObservable: Observable<number>;
  19352. private _onBeforeRenderObserver;
  19353. /**
  19354. * Set a before render callback in the texture.
  19355. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  19356. */
  19357. onBeforeRender: (faceIndex: number) => void;
  19358. /**
  19359. * An event triggered after rendering the texture
  19360. */
  19361. onAfterRenderObservable: Observable<number>;
  19362. private _onAfterRenderObserver;
  19363. /**
  19364. * Set a after render callback in the texture.
  19365. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  19366. */
  19367. onAfterRender: (faceIndex: number) => void;
  19368. /**
  19369. * An event triggered after the texture clear
  19370. */
  19371. onClearObservable: Observable<Engine>;
  19372. private _onClearObserver;
  19373. /**
  19374. * Set a clear callback in the texture.
  19375. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  19376. */
  19377. onClear: (Engine: Engine) => void;
  19378. /**
  19379. * An event triggered when the texture is resized.
  19380. */
  19381. onResizeObservable: Observable<RenderTargetTexture>;
  19382. /**
  19383. * Define the clear color of the Render Target if it should be different from the scene.
  19384. */
  19385. clearColor: Color4;
  19386. protected _size: number | {
  19387. width: number;
  19388. height: number;
  19389. };
  19390. protected _initialSizeParameter: number | {
  19391. width: number;
  19392. height: number;
  19393. } | {
  19394. ratio: number;
  19395. };
  19396. protected _sizeRatio: Nullable<number>;
  19397. /** @hidden */ private _generateMipMaps: boolean;
  19398. protected _renderingManager: RenderingManager;
  19399. /** @hidden */ private _waitingRenderList: string[];
  19400. protected _doNotChangeAspectRatio: boolean;
  19401. protected _currentRefreshId: number;
  19402. protected _refreshRate: number;
  19403. protected _textureMatrix: Matrix;
  19404. protected _samples: number;
  19405. protected _renderTargetOptions: RenderTargetCreationOptions;
  19406. /**
  19407. * Gets render target creation options that were used.
  19408. */
  19409. readonly renderTargetOptions: RenderTargetCreationOptions;
  19410. protected _engine: Engine;
  19411. protected _onRatioRescale(): void;
  19412. /**
  19413. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  19414. * It must define where the camera used to render the texture is set
  19415. */
  19416. boundingBoxPosition: Vector3;
  19417. private _boundingBoxSize;
  19418. /**
  19419. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  19420. * When defined, the cubemap will switch to local mode
  19421. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  19422. * @example https://www.babylonjs-playground.com/#RNASML
  19423. */
  19424. boundingBoxSize: Vector3;
  19425. /**
  19426. * In case the RTT has been created with a depth texture, get the associated
  19427. * depth texture.
  19428. * Otherwise, return null.
  19429. */
  19430. depthStencilTexture: Nullable<InternalTexture>;
  19431. /**
  19432. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  19433. * or used a shadow, depth texture...
  19434. * @param name The friendly name of the texture
  19435. * @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)
  19436. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  19437. * @param generateMipMaps True if mip maps need to be generated after render.
  19438. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  19439. * @param type The type of the buffer in the RTT (int, half float, float...)
  19440. * @param isCube True if a cube texture needs to be created
  19441. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  19442. * @param generateDepthBuffer True to generate a depth buffer
  19443. * @param generateStencilBuffer True to generate a stencil buffer
  19444. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  19445. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  19446. * @param delayAllocation if the texture allocation should be delayed (default: false)
  19447. */
  19448. constructor(name: string, size: number | {
  19449. width: number;
  19450. height: number;
  19451. } | {
  19452. ratio: number;
  19453. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  19454. /**
  19455. * Creates a depth stencil texture.
  19456. * This is only available in WebGL 2 or with the depth texture extension available.
  19457. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  19458. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  19459. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  19460. */
  19461. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  19462. private _processSizeParameter;
  19463. /**
  19464. * Define the number of samples to use in case of MSAA.
  19465. * It defaults to one meaning no MSAA has been enabled.
  19466. */
  19467. samples: number;
  19468. /**
  19469. * Resets the refresh counter of the texture and start bak from scratch.
  19470. * Could be useful to regenerate the texture if it is setup to render only once.
  19471. */
  19472. resetRefreshCounter(): void;
  19473. /**
  19474. * Define the refresh rate of the texture or the rendering frequency.
  19475. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  19476. */
  19477. refreshRate: number;
  19478. /**
  19479. * Adds a post process to the render target rendering passes.
  19480. * @param postProcess define the post process to add
  19481. */
  19482. addPostProcess(postProcess: PostProcess): void;
  19483. /**
  19484. * Clear all the post processes attached to the render target
  19485. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  19486. */
  19487. clearPostProcesses(dispose?: boolean): void;
  19488. /**
  19489. * Remove one of the post process from the list of attached post processes to the texture
  19490. * @param postProcess define the post process to remove from the list
  19491. */
  19492. removePostProcess(postProcess: PostProcess): void;
  19493. /** @hidden */ private _shouldRender(): boolean;
  19494. /**
  19495. * Gets the actual render size of the texture.
  19496. * @returns the width of the render size
  19497. */
  19498. getRenderSize(): number;
  19499. /**
  19500. * Gets the actual render width of the texture.
  19501. * @returns the width of the render size
  19502. */
  19503. getRenderWidth(): number;
  19504. /**
  19505. * Gets the actual render height of the texture.
  19506. * @returns the height of the render size
  19507. */
  19508. getRenderHeight(): number;
  19509. /**
  19510. * Get if the texture can be rescaled or not.
  19511. */
  19512. readonly canRescale: boolean;
  19513. /**
  19514. * Resize the texture using a ratio.
  19515. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  19516. */
  19517. scale(ratio: number): void;
  19518. /**
  19519. * Get the texture reflection matrix used to rotate/transform the reflection.
  19520. * @returns the reflection matrix
  19521. */
  19522. getReflectionTextureMatrix(): Matrix;
  19523. /**
  19524. * Resize the texture to a new desired size.
  19525. * Be carrefull as it will recreate all the data in the new texture.
  19526. * @param size Define the new size. It can be:
  19527. * - a number for squared texture,
  19528. * - an object containing { width: number, height: number }
  19529. * - or an object containing a ratio { ratio: number }
  19530. */
  19531. resize(size: number | {
  19532. width: number;
  19533. height: number;
  19534. } | {
  19535. ratio: number;
  19536. }): void;
  19537. /**
  19538. * Renders all the objects from the render list into the texture.
  19539. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  19540. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  19541. */
  19542. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  19543. private _bestReflectionRenderTargetDimension;
  19544. /**
  19545. * @hidden
  19546. * @param faceIndex face index to bind to if this is a cubetexture
  19547. */ private _bindFrameBuffer(faceIndex?: number): void;
  19548. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  19549. private renderToTarget;
  19550. /**
  19551. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  19552. * This allowed control for front to back rendering or reversly depending of the special needs.
  19553. *
  19554. * @param renderingGroupId The rendering group id corresponding to its index
  19555. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  19556. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  19557. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  19558. */
  19559. 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;
  19560. /**
  19561. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  19562. *
  19563. * @param renderingGroupId The rendering group id corresponding to its index
  19564. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  19565. */
  19566. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  19567. /**
  19568. * Clones the texture.
  19569. * @returns the cloned texture
  19570. */
  19571. clone(): RenderTargetTexture;
  19572. /**
  19573. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  19574. * @returns The JSON representation of the texture
  19575. */
  19576. serialize(): any;
  19577. /**
  19578. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  19579. */
  19580. disposeFramebufferObjects(): void;
  19581. /**
  19582. * Dispose the texture and release its associated resources.
  19583. */
  19584. dispose(): void;
  19585. /** @hidden */ private _rebuild(): void;
  19586. /**
  19587. * Clear the info related to rendering groups preventing retention point in material dispose.
  19588. */
  19589. freeRenderingGroups(): void;
  19590. /**
  19591. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  19592. * @returns the view count
  19593. */
  19594. getViewCount(): number;
  19595. }
  19596. }
  19597. declare module BABYLON {
  19598. /**
  19599. * Base class for the main features of a material in Babylon.js
  19600. */
  19601. export class Material implements IAnimatable {
  19602. /**
  19603. * Returns the triangle fill mode
  19604. */
  19605. static readonly TriangleFillMode: number;
  19606. /**
  19607. * Returns the wireframe mode
  19608. */
  19609. static readonly WireFrameFillMode: number;
  19610. /**
  19611. * Returns the point fill mode
  19612. */
  19613. static readonly PointFillMode: number;
  19614. /**
  19615. * Returns the point list draw mode
  19616. */
  19617. static readonly PointListDrawMode: number;
  19618. /**
  19619. * Returns the line list draw mode
  19620. */
  19621. static readonly LineListDrawMode: number;
  19622. /**
  19623. * Returns the line loop draw mode
  19624. */
  19625. static readonly LineLoopDrawMode: number;
  19626. /**
  19627. * Returns the line strip draw mode
  19628. */
  19629. static readonly LineStripDrawMode: number;
  19630. /**
  19631. * Returns the triangle strip draw mode
  19632. */
  19633. static readonly TriangleStripDrawMode: number;
  19634. /**
  19635. * Returns the triangle fan draw mode
  19636. */
  19637. static readonly TriangleFanDrawMode: number;
  19638. /**
  19639. * Stores the clock-wise side orientation
  19640. */
  19641. static readonly ClockWiseSideOrientation: number;
  19642. /**
  19643. * Stores the counter clock-wise side orientation
  19644. */
  19645. static readonly CounterClockWiseSideOrientation: number;
  19646. /**
  19647. * The dirty texture flag value
  19648. */
  19649. static readonly TextureDirtyFlag: number;
  19650. /**
  19651. * The dirty light flag value
  19652. */
  19653. static readonly LightDirtyFlag: number;
  19654. /**
  19655. * The dirty fresnel flag value
  19656. */
  19657. static readonly FresnelDirtyFlag: number;
  19658. /**
  19659. * The dirty attribute flag value
  19660. */
  19661. static readonly AttributesDirtyFlag: number;
  19662. /**
  19663. * The dirty misc flag value
  19664. */
  19665. static readonly MiscDirtyFlag: number;
  19666. /**
  19667. * The all dirty flag value
  19668. */
  19669. static readonly AllDirtyFlag: number;
  19670. /**
  19671. * The ID of the material
  19672. */
  19673. id: string;
  19674. /**
  19675. * Gets or sets the unique id of the material
  19676. */
  19677. uniqueId: number;
  19678. /**
  19679. * The name of the material
  19680. */
  19681. name: string;
  19682. /**
  19683. * Gets or sets user defined metadata
  19684. */
  19685. metadata: any;
  19686. /**
  19687. * For internal use only. Please do not use.
  19688. */
  19689. reservedDataStore: any;
  19690. /**
  19691. * Specifies if the ready state should be checked on each call
  19692. */
  19693. checkReadyOnEveryCall: boolean;
  19694. /**
  19695. * Specifies if the ready state should be checked once
  19696. */
  19697. checkReadyOnlyOnce: boolean;
  19698. /**
  19699. * The state of the material
  19700. */
  19701. state: string;
  19702. /**
  19703. * The alpha value of the material
  19704. */
  19705. protected _alpha: number;
  19706. /**
  19707. * List of inspectable custom properties (used by the Inspector)
  19708. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19709. */
  19710. inspectableCustomProperties: IInspectable[];
  19711. /**
  19712. * Sets the alpha value of the material
  19713. */
  19714. /**
  19715. * Gets the alpha value of the material
  19716. */
  19717. alpha: number;
  19718. /**
  19719. * Specifies if back face culling is enabled
  19720. */
  19721. protected _backFaceCulling: boolean;
  19722. /**
  19723. * Sets the back-face culling state
  19724. */
  19725. /**
  19726. * Gets the back-face culling state
  19727. */
  19728. backFaceCulling: boolean;
  19729. /**
  19730. * Stores the value for side orientation
  19731. */
  19732. sideOrientation: number;
  19733. /**
  19734. * Callback triggered when the material is compiled
  19735. */
  19736. onCompiled: Nullable<(effect: Effect) => void>;
  19737. /**
  19738. * Callback triggered when an error occurs
  19739. */
  19740. onError: Nullable<(effect: Effect, errors: string) => void>;
  19741. /**
  19742. * Callback triggered to get the render target textures
  19743. */
  19744. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  19745. /**
  19746. * Gets a boolean indicating that current material needs to register RTT
  19747. */
  19748. readonly hasRenderTargetTextures: boolean;
  19749. /**
  19750. * Specifies if the material should be serialized
  19751. */
  19752. doNotSerialize: boolean;
  19753. /**
  19754. * @hidden
  19755. */ private _storeEffectOnSubMeshes: boolean;
  19756. /**
  19757. * Stores the animations for the material
  19758. */
  19759. animations: Nullable<Array<Animation>>;
  19760. /**
  19761. * An event triggered when the material is disposed
  19762. */
  19763. onDisposeObservable: Observable<Material>;
  19764. /**
  19765. * An observer which watches for dispose events
  19766. */
  19767. private _onDisposeObserver;
  19768. private _onUnBindObservable;
  19769. /**
  19770. * Called during a dispose event
  19771. */
  19772. onDispose: () => void;
  19773. private _onBindObservable;
  19774. /**
  19775. * An event triggered when the material is bound
  19776. */
  19777. readonly onBindObservable: Observable<AbstractMesh>;
  19778. /**
  19779. * An observer which watches for bind events
  19780. */
  19781. private _onBindObserver;
  19782. /**
  19783. * Called during a bind event
  19784. */
  19785. onBind: (Mesh: AbstractMesh) => void;
  19786. /**
  19787. * An event triggered when the material is unbound
  19788. */
  19789. readonly onUnBindObservable: Observable<Material>;
  19790. /**
  19791. * Stores the value of the alpha mode
  19792. */
  19793. private _alphaMode;
  19794. /**
  19795. * Sets the value of the alpha mode.
  19796. *
  19797. * | Value | Type | Description |
  19798. * | --- | --- | --- |
  19799. * | 0 | ALPHA_DISABLE | |
  19800. * | 1 | ALPHA_ADD | |
  19801. * | 2 | ALPHA_COMBINE | |
  19802. * | 3 | ALPHA_SUBTRACT | |
  19803. * | 4 | ALPHA_MULTIPLY | |
  19804. * | 5 | ALPHA_MAXIMIZED | |
  19805. * | 6 | ALPHA_ONEONE | |
  19806. * | 7 | ALPHA_PREMULTIPLIED | |
  19807. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  19808. * | 9 | ALPHA_INTERPOLATE | |
  19809. * | 10 | ALPHA_SCREENMODE | |
  19810. *
  19811. */
  19812. /**
  19813. * Gets the value of the alpha mode
  19814. */
  19815. alphaMode: number;
  19816. /**
  19817. * Stores the state of the need depth pre-pass value
  19818. */
  19819. private _needDepthPrePass;
  19820. /**
  19821. * Sets the need depth pre-pass value
  19822. */
  19823. /**
  19824. * Gets the depth pre-pass value
  19825. */
  19826. needDepthPrePass: boolean;
  19827. /**
  19828. * Specifies if depth writing should be disabled
  19829. */
  19830. disableDepthWrite: boolean;
  19831. /**
  19832. * Specifies if depth writing should be forced
  19833. */
  19834. forceDepthWrite: boolean;
  19835. /**
  19836. * Specifies if there should be a separate pass for culling
  19837. */
  19838. separateCullingPass: boolean;
  19839. /**
  19840. * Stores the state specifing if fog should be enabled
  19841. */
  19842. private _fogEnabled;
  19843. /**
  19844. * Sets the state for enabling fog
  19845. */
  19846. /**
  19847. * Gets the value of the fog enabled state
  19848. */
  19849. fogEnabled: boolean;
  19850. /**
  19851. * Stores the size of points
  19852. */
  19853. pointSize: number;
  19854. /**
  19855. * Stores the z offset value
  19856. */
  19857. zOffset: number;
  19858. /**
  19859. * Gets a value specifying if wireframe mode is enabled
  19860. */
  19861. /**
  19862. * Sets the state of wireframe mode
  19863. */
  19864. wireframe: boolean;
  19865. /**
  19866. * Gets the value specifying if point clouds are enabled
  19867. */
  19868. /**
  19869. * Sets the state of point cloud mode
  19870. */
  19871. pointsCloud: boolean;
  19872. /**
  19873. * Gets the material fill mode
  19874. */
  19875. /**
  19876. * Sets the material fill mode
  19877. */
  19878. fillMode: number;
  19879. /**
  19880. * @hidden
  19881. * Stores the effects for the material
  19882. */ private _effect: Nullable<Effect>;
  19883. /**
  19884. * @hidden
  19885. * Specifies if the material was previously ready
  19886. */ private _wasPreviouslyReady: boolean;
  19887. /**
  19888. * Specifies if uniform buffers should be used
  19889. */
  19890. private _useUBO;
  19891. /**
  19892. * Stores a reference to the scene
  19893. */
  19894. private _scene;
  19895. /**
  19896. * Stores the fill mode state
  19897. */
  19898. private _fillMode;
  19899. /**
  19900. * Specifies if the depth write state should be cached
  19901. */
  19902. private _cachedDepthWriteState;
  19903. /**
  19904. * Stores the uniform buffer
  19905. */
  19906. protected _uniformBuffer: UniformBuffer;
  19907. /** @hidden */ private _indexInSceneMaterialArray: number;
  19908. /** @hidden */
  19909. meshMap: Nullable<{
  19910. [id: string]: AbstractMesh | undefined;
  19911. }>;
  19912. /**
  19913. * Creates a material instance
  19914. * @param name defines the name of the material
  19915. * @param scene defines the scene to reference
  19916. * @param doNotAdd specifies if the material should be added to the scene
  19917. */
  19918. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  19919. /**
  19920. * Returns a string representation of the current material
  19921. * @param fullDetails defines a boolean indicating which levels of logging is desired
  19922. * @returns a string with material information
  19923. */
  19924. toString(fullDetails?: boolean): string;
  19925. /**
  19926. * Gets the class name of the material
  19927. * @returns a string with the class name of the material
  19928. */
  19929. getClassName(): string;
  19930. /**
  19931. * Specifies if updates for the material been locked
  19932. */
  19933. readonly isFrozen: boolean;
  19934. /**
  19935. * Locks updates for the material
  19936. */
  19937. freeze(): void;
  19938. /**
  19939. * Unlocks updates for the material
  19940. */
  19941. unfreeze(): void;
  19942. /**
  19943. * Specifies if the material is ready to be used
  19944. * @param mesh defines the mesh to check
  19945. * @param useInstances specifies if instances should be used
  19946. * @returns a boolean indicating if the material is ready to be used
  19947. */
  19948. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19949. /**
  19950. * Specifies that the submesh is ready to be used
  19951. * @param mesh defines the mesh to check
  19952. * @param subMesh defines which submesh to check
  19953. * @param useInstances specifies that instances should be used
  19954. * @returns a boolean indicating that the submesh is ready or not
  19955. */
  19956. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19957. /**
  19958. * Returns the material effect
  19959. * @returns the effect associated with the material
  19960. */
  19961. getEffect(): Nullable<Effect>;
  19962. /**
  19963. * Returns the current scene
  19964. * @returns a Scene
  19965. */
  19966. getScene(): Scene;
  19967. /**
  19968. * Specifies if the material will require alpha blending
  19969. * @returns a boolean specifying if alpha blending is needed
  19970. */
  19971. needAlphaBlending(): boolean;
  19972. /**
  19973. * Specifies if the mesh will require alpha blending
  19974. * @param mesh defines the mesh to check
  19975. * @returns a boolean specifying if alpha blending is needed for the mesh
  19976. */
  19977. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  19978. /**
  19979. * Specifies if this material should be rendered in alpha test mode
  19980. * @returns a boolean specifying if an alpha test is needed.
  19981. */
  19982. needAlphaTesting(): boolean;
  19983. /**
  19984. * Gets the texture used for the alpha test
  19985. * @returns the texture to use for alpha testing
  19986. */
  19987. getAlphaTestTexture(): Nullable<BaseTexture>;
  19988. /**
  19989. * Marks the material to indicate that it needs to be re-calculated
  19990. */
  19991. markDirty(): void;
  19992. /** @hidden */ private _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  19993. /**
  19994. * Binds the material to the mesh
  19995. * @param world defines the world transformation matrix
  19996. * @param mesh defines the mesh to bind the material to
  19997. */
  19998. bind(world: Matrix, mesh?: Mesh): void;
  19999. /**
  20000. * Binds the submesh to the material
  20001. * @param world defines the world transformation matrix
  20002. * @param mesh defines the mesh containing the submesh
  20003. * @param subMesh defines the submesh to bind the material to
  20004. */
  20005. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20006. /**
  20007. * Binds the world matrix to the material
  20008. * @param world defines the world transformation matrix
  20009. */
  20010. bindOnlyWorldMatrix(world: Matrix): void;
  20011. /**
  20012. * Binds the scene's uniform buffer to the effect.
  20013. * @param effect defines the effect to bind to the scene uniform buffer
  20014. * @param sceneUbo defines the uniform buffer storing scene data
  20015. */
  20016. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  20017. /**
  20018. * Binds the view matrix to the effect
  20019. * @param effect defines the effect to bind the view matrix to
  20020. */
  20021. bindView(effect: Effect): void;
  20022. /**
  20023. * Binds the view projection matrix to the effect
  20024. * @param effect defines the effect to bind the view projection matrix to
  20025. */
  20026. bindViewProjection(effect: Effect): void;
  20027. /**
  20028. * Specifies if material alpha testing should be turned on for the mesh
  20029. * @param mesh defines the mesh to check
  20030. */
  20031. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  20032. /**
  20033. * Processes to execute after binding the material to a mesh
  20034. * @param mesh defines the rendered mesh
  20035. */
  20036. protected _afterBind(mesh?: Mesh): void;
  20037. /**
  20038. * Unbinds the material from the mesh
  20039. */
  20040. unbind(): void;
  20041. /**
  20042. * Gets the active textures from the material
  20043. * @returns an array of textures
  20044. */
  20045. getActiveTextures(): BaseTexture[];
  20046. /**
  20047. * Specifies if the material uses a texture
  20048. * @param texture defines the texture to check against the material
  20049. * @returns a boolean specifying if the material uses the texture
  20050. */
  20051. hasTexture(texture: BaseTexture): boolean;
  20052. /**
  20053. * Makes a duplicate of the material, and gives it a new name
  20054. * @param name defines the new name for the duplicated material
  20055. * @returns the cloned material
  20056. */
  20057. clone(name: string): Nullable<Material>;
  20058. /**
  20059. * Gets the meshes bound to the material
  20060. * @returns an array of meshes bound to the material
  20061. */
  20062. getBindedMeshes(): AbstractMesh[];
  20063. /**
  20064. * Force shader compilation
  20065. * @param mesh defines the mesh associated with this material
  20066. * @param onCompiled defines a function to execute once the material is compiled
  20067. * @param options defines the options to configure the compilation
  20068. */
  20069. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  20070. clipPlane: boolean;
  20071. }>): void;
  20072. /**
  20073. * Force shader compilation
  20074. * @param mesh defines the mesh that will use this material
  20075. * @param options defines additional options for compiling the shaders
  20076. * @returns a promise that resolves when the compilation completes
  20077. */
  20078. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  20079. clipPlane: boolean;
  20080. }>): Promise<void>;
  20081. private static readonly _AllDirtyCallBack;
  20082. private static readonly _ImageProcessingDirtyCallBack;
  20083. private static readonly _TextureDirtyCallBack;
  20084. private static readonly _FresnelDirtyCallBack;
  20085. private static readonly _MiscDirtyCallBack;
  20086. private static readonly _LightsDirtyCallBack;
  20087. private static readonly _AttributeDirtyCallBack;
  20088. private static _FresnelAndMiscDirtyCallBack;
  20089. private static _TextureAndMiscDirtyCallBack;
  20090. private static readonly _DirtyCallbackArray;
  20091. private static readonly _RunDirtyCallBacks;
  20092. /**
  20093. * Marks a define in the material to indicate that it needs to be re-computed
  20094. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  20095. */
  20096. markAsDirty(flag: number): void;
  20097. /**
  20098. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  20099. * @param func defines a function which checks material defines against the submeshes
  20100. */
  20101. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  20102. /**
  20103. * Indicates that we need to re-calculated for all submeshes
  20104. */
  20105. protected _markAllSubMeshesAsAllDirty(): void;
  20106. /**
  20107. * Indicates that image processing needs to be re-calculated for all submeshes
  20108. */
  20109. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  20110. /**
  20111. * Indicates that textures need to be re-calculated for all submeshes
  20112. */
  20113. protected _markAllSubMeshesAsTexturesDirty(): void;
  20114. /**
  20115. * Indicates that fresnel needs to be re-calculated for all submeshes
  20116. */
  20117. protected _markAllSubMeshesAsFresnelDirty(): void;
  20118. /**
  20119. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  20120. */
  20121. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  20122. /**
  20123. * Indicates that lights need to be re-calculated for all submeshes
  20124. */
  20125. protected _markAllSubMeshesAsLightsDirty(): void;
  20126. /**
  20127. * Indicates that attributes need to be re-calculated for all submeshes
  20128. */
  20129. protected _markAllSubMeshesAsAttributesDirty(): void;
  20130. /**
  20131. * Indicates that misc needs to be re-calculated for all submeshes
  20132. */
  20133. protected _markAllSubMeshesAsMiscDirty(): void;
  20134. /**
  20135. * Indicates that textures and misc need to be re-calculated for all submeshes
  20136. */
  20137. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  20138. /**
  20139. * Disposes the material
  20140. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  20141. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  20142. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  20143. */
  20144. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  20145. /** @hidden */
  20146. private releaseVertexArrayObject;
  20147. /**
  20148. * Serializes this material
  20149. * @returns the serialized material object
  20150. */
  20151. serialize(): any;
  20152. /**
  20153. * Creates a material from parsed material data
  20154. * @param parsedMaterial defines parsed material data
  20155. * @param scene defines the hosting scene
  20156. * @param rootUrl defines the root URL to use to load textures
  20157. * @returns a new material
  20158. */
  20159. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  20160. }
  20161. }
  20162. declare module BABYLON {
  20163. /**
  20164. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20165. * separate meshes. This can be use to improve performances.
  20166. * @see http://doc.babylonjs.com/how_to/multi_materials
  20167. */
  20168. export class MultiMaterial extends Material {
  20169. private _subMaterials;
  20170. /**
  20171. * Gets or Sets the list of Materials used within the multi material.
  20172. * They need to be ordered according to the submeshes order in the associated mesh
  20173. */
  20174. subMaterials: Nullable<Material>[];
  20175. /**
  20176. * Function used to align with Node.getChildren()
  20177. * @returns the list of Materials used within the multi material
  20178. */
  20179. getChildren(): Nullable<Material>[];
  20180. /**
  20181. * Instantiates a new Multi Material
  20182. * A multi-material is used to apply different materials to different parts of the same object without the need of
  20183. * separate meshes. This can be use to improve performances.
  20184. * @see http://doc.babylonjs.com/how_to/multi_materials
  20185. * @param name Define the name in the scene
  20186. * @param scene Define the scene the material belongs to
  20187. */
  20188. constructor(name: string, scene: Scene);
  20189. private _hookArray;
  20190. /**
  20191. * Get one of the submaterial by its index in the submaterials array
  20192. * @param index The index to look the sub material at
  20193. * @returns The Material if the index has been defined
  20194. */
  20195. getSubMaterial(index: number): Nullable<Material>;
  20196. /**
  20197. * Get the list of active textures for the whole sub materials list.
  20198. * @returns All the textures that will be used during the rendering
  20199. */
  20200. getActiveTextures(): BaseTexture[];
  20201. /**
  20202. * Gets the current class name of the material e.g. "MultiMaterial"
  20203. * Mainly use in serialization.
  20204. * @returns the class name
  20205. */
  20206. getClassName(): string;
  20207. /**
  20208. * Checks if the material is ready to render the requested sub mesh
  20209. * @param mesh Define the mesh the submesh belongs to
  20210. * @param subMesh Define the sub mesh to look readyness for
  20211. * @param useInstances Define whether or not the material is used with instances
  20212. * @returns true if ready, otherwise false
  20213. */
  20214. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  20215. /**
  20216. * Clones the current material and its related sub materials
  20217. * @param name Define the name of the newly cloned material
  20218. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  20219. * @returns the cloned material
  20220. */
  20221. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  20222. /**
  20223. * Serializes the materials into a JSON representation.
  20224. * @returns the JSON representation
  20225. */
  20226. serialize(): any;
  20227. /**
  20228. * Dispose the material and release its associated resources
  20229. * @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)
  20230. * @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)
  20231. * @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)
  20232. */
  20233. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  20234. /**
  20235. * Creates a MultiMaterial from parsed MultiMaterial data.
  20236. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  20237. * @param scene defines the hosting scene
  20238. * @returns a new MultiMaterial
  20239. */
  20240. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  20241. }
  20242. }
  20243. declare module BABYLON {
  20244. /**
  20245. * Base class for submeshes
  20246. */
  20247. export class BaseSubMesh {
  20248. /** @hidden */ private _materialDefines: Nullable<MaterialDefines>;
  20249. /** @hidden */ private _materialEffect: Nullable<Effect>;
  20250. /**
  20251. * Gets associated effect
  20252. */
  20253. readonly effect: Nullable<Effect>;
  20254. /**
  20255. * Sets associated effect (effect used to render this submesh)
  20256. * @param effect defines the effect to associate with
  20257. * @param defines defines the set of defines used to compile this effect
  20258. */
  20259. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  20260. }
  20261. /**
  20262. * Defines a subdivision inside a mesh
  20263. */
  20264. export class SubMesh extends BaseSubMesh implements ICullable {
  20265. /** the material index to use */
  20266. materialIndex: number;
  20267. /** vertex index start */
  20268. verticesStart: number;
  20269. /** vertices count */
  20270. verticesCount: number;
  20271. /** index start */
  20272. indexStart: number;
  20273. /** indices count */
  20274. indexCount: number;
  20275. /** @hidden */ private _linesIndexCount: number;
  20276. private _mesh;
  20277. private _renderingMesh;
  20278. private _boundingInfo;
  20279. private _linesIndexBuffer;
  20280. /** @hidden */ private _lastColliderWorldVertices: Nullable<Vector3[]>;
  20281. /** @hidden */ private _trianglePlanes: Plane[];
  20282. /** @hidden */ private _lastColliderTransformMatrix: Nullable<Matrix>;
  20283. /** @hidden */ private _renderId: number;
  20284. /** @hidden */ private _alphaIndex: number;
  20285. /** @hidden */ private _distanceToCamera: number;
  20286. /** @hidden */ private _id: number;
  20287. private _currentMaterial;
  20288. /**
  20289. * Add a new submesh to a mesh
  20290. * @param materialIndex defines the material index to use
  20291. * @param verticesStart defines vertex index start
  20292. * @param verticesCount defines vertices count
  20293. * @param indexStart defines index start
  20294. * @param indexCount defines indices count
  20295. * @param mesh defines the parent mesh
  20296. * @param renderingMesh defines an optional rendering mesh
  20297. * @param createBoundingBox defines if bounding box should be created for this submesh
  20298. * @returns the new submesh
  20299. */
  20300. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  20301. /**
  20302. * Creates a new submesh
  20303. * @param materialIndex defines the material index to use
  20304. * @param verticesStart defines vertex index start
  20305. * @param verticesCount defines vertices count
  20306. * @param indexStart defines index start
  20307. * @param indexCount defines indices count
  20308. * @param mesh defines the parent mesh
  20309. * @param renderingMesh defines an optional rendering mesh
  20310. * @param createBoundingBox defines if bounding box should be created for this submesh
  20311. */
  20312. constructor(
  20313. /** the material index to use */
  20314. materialIndex: number,
  20315. /** vertex index start */
  20316. verticesStart: number,
  20317. /** vertices count */
  20318. verticesCount: number,
  20319. /** index start */
  20320. indexStart: number,
  20321. /** indices count */
  20322. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  20323. /**
  20324. * Returns true if this submesh covers the entire parent mesh
  20325. * @ignorenaming
  20326. */
  20327. readonly IsGlobal: boolean;
  20328. /**
  20329. * Returns the submesh BoudingInfo object
  20330. * @returns current bounding info (or mesh's one if the submesh is global)
  20331. */
  20332. getBoundingInfo(): BoundingInfo;
  20333. /**
  20334. * Sets the submesh BoundingInfo
  20335. * @param boundingInfo defines the new bounding info to use
  20336. * @returns the SubMesh
  20337. */
  20338. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  20339. /**
  20340. * Returns the mesh of the current submesh
  20341. * @return the parent mesh
  20342. */
  20343. getMesh(): AbstractMesh;
  20344. /**
  20345. * Returns the rendering mesh of the submesh
  20346. * @returns the rendering mesh (could be different from parent mesh)
  20347. */
  20348. getRenderingMesh(): Mesh;
  20349. /**
  20350. * Returns the submesh material
  20351. * @returns null or the current material
  20352. */
  20353. getMaterial(): Nullable<Material>;
  20354. /**
  20355. * Sets a new updated BoundingInfo object to the submesh
  20356. * @param data defines an optional position array to use to determine the bounding info
  20357. * @returns the SubMesh
  20358. */
  20359. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  20360. /** @hidden */ private _checkCollision(collider: Collider): boolean;
  20361. /**
  20362. * Updates the submesh BoundingInfo
  20363. * @param world defines the world matrix to use to update the bounding info
  20364. * @returns the submesh
  20365. */
  20366. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  20367. /**
  20368. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  20369. * @param frustumPlanes defines the frustum planes
  20370. * @returns true if the submesh is intersecting with the frustum
  20371. */
  20372. isInFrustum(frustumPlanes: Plane[]): boolean;
  20373. /**
  20374. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  20375. * @param frustumPlanes defines the frustum planes
  20376. * @returns true if the submesh is inside the frustum
  20377. */
  20378. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  20379. /**
  20380. * Renders the submesh
  20381. * @param enableAlphaMode defines if alpha needs to be used
  20382. * @returns the submesh
  20383. */
  20384. render(enableAlphaMode: boolean): SubMesh;
  20385. /**
  20386. * @hidden
  20387. */ private _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  20388. /**
  20389. * Checks if the submesh intersects with a ray
  20390. * @param ray defines the ray to test
  20391. * @returns true is the passed ray intersects the submesh bounding box
  20392. */
  20393. canIntersects(ray: Ray): boolean;
  20394. /**
  20395. * Intersects current submesh with a ray
  20396. * @param ray defines the ray to test
  20397. * @param positions defines mesh's positions array
  20398. * @param indices defines mesh's indices array
  20399. * @param fastCheck defines if only bounding info should be used
  20400. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  20401. * @returns intersection info or null if no intersection
  20402. */
  20403. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  20404. /** @hidden */
  20405. private _intersectLines;
  20406. /** @hidden */
  20407. private _intersectUnIndexedLines;
  20408. /** @hidden */
  20409. private _intersectTriangles;
  20410. /** @hidden */
  20411. private _intersectUnIndexedTriangles;
  20412. /** @hidden */ private _rebuild(): void;
  20413. /**
  20414. * Creates a new submesh from the passed mesh
  20415. * @param newMesh defines the new hosting mesh
  20416. * @param newRenderingMesh defines an optional rendering mesh
  20417. * @returns the new submesh
  20418. */
  20419. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  20420. /**
  20421. * Release associated resources
  20422. */
  20423. dispose(): void;
  20424. /**
  20425. * Gets the class name
  20426. * @returns the string "SubMesh".
  20427. */
  20428. getClassName(): string;
  20429. /**
  20430. * Creates a new submesh from indices data
  20431. * @param materialIndex the index of the main mesh material
  20432. * @param startIndex the index where to start the copy in the mesh indices array
  20433. * @param indexCount the number of indices to copy then from the startIndex
  20434. * @param mesh the main mesh to create the submesh from
  20435. * @param renderingMesh the optional rendering mesh
  20436. * @returns a new submesh
  20437. */
  20438. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  20439. }
  20440. }
  20441. declare module BABYLON {
  20442. /**
  20443. * Class used to represent data loading progression
  20444. */
  20445. export class SceneLoaderFlags {
  20446. private static _ForceFullSceneLoadingForIncremental;
  20447. private static _ShowLoadingScreen;
  20448. private static _CleanBoneMatrixWeights;
  20449. private static _loggingLevel;
  20450. /**
  20451. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  20452. */
  20453. static ForceFullSceneLoadingForIncremental: boolean;
  20454. /**
  20455. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  20456. */
  20457. static ShowLoadingScreen: boolean;
  20458. /**
  20459. * Defines the current logging level (while loading the scene)
  20460. * @ignorenaming
  20461. */
  20462. static loggingLevel: number;
  20463. /**
  20464. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  20465. */
  20466. static CleanBoneMatrixWeights: boolean;
  20467. }
  20468. }
  20469. declare module BABYLON {
  20470. /**
  20471. * Class used to store geometry data (vertex buffers + index buffer)
  20472. */
  20473. export class Geometry implements IGetSetVerticesData {
  20474. /**
  20475. * Gets or sets the ID of the geometry
  20476. */
  20477. id: string;
  20478. /**
  20479. * Gets or sets the unique ID of the geometry
  20480. */
  20481. uniqueId: number;
  20482. /**
  20483. * Gets the delay loading state of the geometry (none by default which means not delayed)
  20484. */
  20485. delayLoadState: number;
  20486. /**
  20487. * Gets the file containing the data to load when running in delay load state
  20488. */
  20489. delayLoadingFile: Nullable<string>;
  20490. /**
  20491. * Callback called when the geometry is updated
  20492. */
  20493. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  20494. private _scene;
  20495. private _engine;
  20496. private _meshes;
  20497. private _totalVertices;
  20498. /** @hidden */ private _indices: IndicesArray;
  20499. /** @hidden */ private _vertexBuffers: {
  20500. [key: string]: VertexBuffer;
  20501. };
  20502. private _isDisposed;
  20503. private _extend;
  20504. private _boundingBias;
  20505. /** @hidden */ private _delayInfo: Array<string>;
  20506. private _indexBuffer;
  20507. private _indexBufferIsUpdatable;
  20508. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  20509. /** @hidden */ private _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  20510. /** @hidden */ private _softwareSkinningFrameId: number;
  20511. private _vertexArrayObjects;
  20512. private _updatable;
  20513. /** @hidden */ private _positions: Nullable<Vector3[]>;
  20514. /**
  20515. * 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
  20516. */
  20517. /**
  20518. * 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
  20519. */
  20520. boundingBias: Vector2;
  20521. /**
  20522. * Static function used to attach a new empty geometry to a mesh
  20523. * @param mesh defines the mesh to attach the geometry to
  20524. * @returns the new Geometry
  20525. */
  20526. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  20527. /**
  20528. * Creates a new geometry
  20529. * @param id defines the unique ID
  20530. * @param scene defines the hosting scene
  20531. * @param vertexData defines the VertexData used to get geometry data
  20532. * @param updatable defines if geometry must be updatable (false by default)
  20533. * @param mesh defines the mesh that will be associated with the geometry
  20534. */
  20535. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  20536. /**
  20537. * Gets the current extend of the geometry
  20538. */
  20539. readonly extend: {
  20540. minimum: Vector3;
  20541. maximum: Vector3;
  20542. };
  20543. /**
  20544. * Gets the hosting scene
  20545. * @returns the hosting Scene
  20546. */
  20547. getScene(): Scene;
  20548. /**
  20549. * Gets the hosting engine
  20550. * @returns the hosting Engine
  20551. */
  20552. getEngine(): Engine;
  20553. /**
  20554. * Defines if the geometry is ready to use
  20555. * @returns true if the geometry is ready to be used
  20556. */
  20557. isReady(): boolean;
  20558. /**
  20559. * Gets a value indicating that the geometry should not be serialized
  20560. */
  20561. readonly doNotSerialize: boolean;
  20562. /** @hidden */ private _rebuild(): void;
  20563. /**
  20564. * Affects all geometry data in one call
  20565. * @param vertexData defines the geometry data
  20566. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  20567. */
  20568. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  20569. /**
  20570. * Set specific vertex data
  20571. * @param kind defines the data kind (Position, normal, etc...)
  20572. * @param data defines the vertex data to use
  20573. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20574. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20575. */
  20576. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  20577. /**
  20578. * Removes a specific vertex data
  20579. * @param kind defines the data kind (Position, normal, etc...)
  20580. */
  20581. removeVerticesData(kind: string): void;
  20582. /**
  20583. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  20584. * @param buffer defines the vertex buffer to use
  20585. * @param totalVertices defines the total number of vertices for position kind (could be null)
  20586. */
  20587. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  20588. /**
  20589. * Update a specific vertex buffer
  20590. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  20591. * It will do nothing if the buffer is not updatable
  20592. * @param kind defines the data kind (Position, normal, etc...)
  20593. * @param data defines the data to use
  20594. * @param offset defines the offset in the target buffer where to store the data
  20595. * @param useBytes set to true if the offset is in bytes
  20596. */
  20597. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  20598. /**
  20599. * Update a specific vertex buffer
  20600. * This function will create a new buffer if the current one is not updatable
  20601. * @param kind defines the data kind (Position, normal, etc...)
  20602. * @param data defines the data to use
  20603. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  20604. */
  20605. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  20606. private _updateBoundingInfo;
  20607. /** @hidden */ private _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  20608. /**
  20609. * Gets total number of vertices
  20610. * @returns the total number of vertices
  20611. */
  20612. getTotalVertices(): number;
  20613. /**
  20614. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20615. * @param kind defines the data kind (Position, normal, etc...)
  20616. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20617. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20618. * @returns a float array containing vertex data
  20619. */
  20620. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20621. /**
  20622. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  20623. * @param kind defines the data kind (Position, normal, etc...)
  20624. * @returns true if the vertex buffer with the specified kind is updatable
  20625. */
  20626. isVertexBufferUpdatable(kind: string): boolean;
  20627. /**
  20628. * Gets a specific vertex buffer
  20629. * @param kind defines the data kind (Position, normal, etc...)
  20630. * @returns a VertexBuffer
  20631. */
  20632. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  20633. /**
  20634. * Returns all vertex buffers
  20635. * @return an object holding all vertex buffers indexed by kind
  20636. */
  20637. getVertexBuffers(): Nullable<{
  20638. [key: string]: VertexBuffer;
  20639. }>;
  20640. /**
  20641. * Gets a boolean indicating if specific vertex buffer is present
  20642. * @param kind defines the data kind (Position, normal, etc...)
  20643. * @returns true if data is present
  20644. */
  20645. isVerticesDataPresent(kind: string): boolean;
  20646. /**
  20647. * Gets a list of all attached data kinds (Position, normal, etc...)
  20648. * @returns a list of string containing all kinds
  20649. */
  20650. getVerticesDataKinds(): string[];
  20651. /**
  20652. * Update index buffer
  20653. * @param indices defines the indices to store in the index buffer
  20654. * @param offset defines the offset in the target buffer where to store the data
  20655. * @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)
  20656. */
  20657. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  20658. /**
  20659. * Creates a new index buffer
  20660. * @param indices defines the indices to store in the index buffer
  20661. * @param totalVertices defines the total number of vertices (could be null)
  20662. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20663. */
  20664. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  20665. /**
  20666. * Return the total number of indices
  20667. * @returns the total number of indices
  20668. */
  20669. getTotalIndices(): number;
  20670. /**
  20671. * Gets the index buffer array
  20672. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20673. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20674. * @returns the index buffer array
  20675. */
  20676. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20677. /**
  20678. * Gets the index buffer
  20679. * @return the index buffer
  20680. */
  20681. getIndexBuffer(): Nullable<DataBuffer>;
  20682. /** @hidden */ private _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  20683. /**
  20684. * Release the associated resources for a specific mesh
  20685. * @param mesh defines the source mesh
  20686. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  20687. */
  20688. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  20689. /**
  20690. * Apply current geometry to a given mesh
  20691. * @param mesh defines the mesh to apply geometry to
  20692. */
  20693. applyToMesh(mesh: Mesh): void;
  20694. private _updateExtend;
  20695. private _applyToMesh;
  20696. private notifyUpdate;
  20697. /**
  20698. * Load the geometry if it was flagged as delay loaded
  20699. * @param scene defines the hosting scene
  20700. * @param onLoaded defines a callback called when the geometry is loaded
  20701. */
  20702. load(scene: Scene, onLoaded?: () => void): void;
  20703. private _queueLoad;
  20704. /**
  20705. * Invert the geometry to move from a right handed system to a left handed one.
  20706. */
  20707. toLeftHanded(): void;
  20708. /** @hidden */ private _resetPointsArrayCache(): void;
  20709. /** @hidden */ private _generatePointsArray(): boolean;
  20710. /**
  20711. * Gets a value indicating if the geometry is disposed
  20712. * @returns true if the geometry was disposed
  20713. */
  20714. isDisposed(): boolean;
  20715. private _disposeVertexArrayObjects;
  20716. /**
  20717. * Free all associated resources
  20718. */
  20719. dispose(): void;
  20720. /**
  20721. * Clone the current geometry into a new geometry
  20722. * @param id defines the unique ID of the new geometry
  20723. * @returns a new geometry object
  20724. */
  20725. copy(id: string): Geometry;
  20726. /**
  20727. * Serialize the current geometry info (and not the vertices data) into a JSON object
  20728. * @return a JSON representation of the current geometry data (without the vertices data)
  20729. */
  20730. serialize(): any;
  20731. private toNumberArray;
  20732. /**
  20733. * Serialize all vertices data into a JSON oject
  20734. * @returns a JSON representation of the current geometry data
  20735. */
  20736. serializeVerticeData(): any;
  20737. /**
  20738. * Extracts a clone of a mesh geometry
  20739. * @param mesh defines the source mesh
  20740. * @param id defines the unique ID of the new geometry object
  20741. * @returns the new geometry object
  20742. */
  20743. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  20744. /**
  20745. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  20746. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  20747. * Be aware Math.random() could cause collisions, but:
  20748. * "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"
  20749. * @returns a string containing a new GUID
  20750. */
  20751. static RandomId(): string;
  20752. /** @hidden */ private static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  20753. private static _CleanMatricesWeights;
  20754. /**
  20755. * Create a new geometry from persisted data (Using .babylon file format)
  20756. * @param parsedVertexData defines the persisted data
  20757. * @param scene defines the hosting scene
  20758. * @param rootUrl defines the root url to use to load assets (like delayed data)
  20759. * @returns the new geometry object
  20760. */
  20761. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  20762. }
  20763. }
  20764. declare module BABYLON {
  20765. /**
  20766. * Define an interface for all classes that will get and set the data on vertices
  20767. */
  20768. export interface IGetSetVerticesData {
  20769. /**
  20770. * Gets a boolean indicating if specific vertex data is present
  20771. * @param kind defines the vertex data kind to use
  20772. * @returns true is data kind is present
  20773. */
  20774. isVerticesDataPresent(kind: string): boolean;
  20775. /**
  20776. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  20777. * @param kind defines the data kind (Position, normal, etc...)
  20778. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  20779. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20780. * @returns a float array containing vertex data
  20781. */
  20782. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  20783. /**
  20784. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  20785. * @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.
  20786. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  20787. * @returns the indices array or an empty array if the mesh has no geometry
  20788. */
  20789. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  20790. /**
  20791. * Set specific vertex data
  20792. * @param kind defines the data kind (Position, normal, etc...)
  20793. * @param data defines the vertex data to use
  20794. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  20795. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  20796. */
  20797. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  20798. /**
  20799. * Update a specific associated vertex buffer
  20800. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  20801. * - VertexBuffer.PositionKind
  20802. * - VertexBuffer.UVKind
  20803. * - VertexBuffer.UV2Kind
  20804. * - VertexBuffer.UV3Kind
  20805. * - VertexBuffer.UV4Kind
  20806. * - VertexBuffer.UV5Kind
  20807. * - VertexBuffer.UV6Kind
  20808. * - VertexBuffer.ColorKind
  20809. * - VertexBuffer.MatricesIndicesKind
  20810. * - VertexBuffer.MatricesIndicesExtraKind
  20811. * - VertexBuffer.MatricesWeightsKind
  20812. * - VertexBuffer.MatricesWeightsExtraKind
  20813. * @param data defines the data source
  20814. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  20815. * @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)
  20816. */
  20817. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  20818. /**
  20819. * Creates a new index buffer
  20820. * @param indices defines the indices to store in the index buffer
  20821. * @param totalVertices defines the total number of vertices (could be null)
  20822. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  20823. */
  20824. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  20825. }
  20826. /**
  20827. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  20828. */
  20829. export class VertexData {
  20830. /**
  20831. * Mesh side orientation : usually the external or front surface
  20832. */
  20833. static readonly FRONTSIDE: number;
  20834. /**
  20835. * Mesh side orientation : usually the internal or back surface
  20836. */
  20837. static readonly BACKSIDE: number;
  20838. /**
  20839. * Mesh side orientation : both internal and external or front and back surfaces
  20840. */
  20841. static readonly DOUBLESIDE: number;
  20842. /**
  20843. * Mesh side orientation : by default, `FRONTSIDE`
  20844. */
  20845. static readonly DEFAULTSIDE: number;
  20846. /**
  20847. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  20848. */
  20849. positions: Nullable<FloatArray>;
  20850. /**
  20851. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  20852. */
  20853. normals: Nullable<FloatArray>;
  20854. /**
  20855. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  20856. */
  20857. tangents: Nullable<FloatArray>;
  20858. /**
  20859. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20860. */
  20861. uvs: Nullable<FloatArray>;
  20862. /**
  20863. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20864. */
  20865. uvs2: Nullable<FloatArray>;
  20866. /**
  20867. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20868. */
  20869. uvs3: Nullable<FloatArray>;
  20870. /**
  20871. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20872. */
  20873. uvs4: Nullable<FloatArray>;
  20874. /**
  20875. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20876. */
  20877. uvs5: Nullable<FloatArray>;
  20878. /**
  20879. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  20880. */
  20881. uvs6: Nullable<FloatArray>;
  20882. /**
  20883. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  20884. */
  20885. colors: Nullable<FloatArray>;
  20886. /**
  20887. * 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).
  20888. */
  20889. matricesIndices: Nullable<FloatArray>;
  20890. /**
  20891. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  20892. */
  20893. matricesWeights: Nullable<FloatArray>;
  20894. /**
  20895. * An array extending the number of possible indices
  20896. */
  20897. matricesIndicesExtra: Nullable<FloatArray>;
  20898. /**
  20899. * An array extending the number of possible weights when the number of indices is extended
  20900. */
  20901. matricesWeightsExtra: Nullable<FloatArray>;
  20902. /**
  20903. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  20904. */
  20905. indices: Nullable<IndicesArray>;
  20906. /**
  20907. * Uses the passed data array to set the set the values for the specified kind of data
  20908. * @param data a linear array of floating numbers
  20909. * @param kind the type of data that is being set, eg positions, colors etc
  20910. */
  20911. set(data: FloatArray, kind: string): void;
  20912. /**
  20913. * Associates the vertexData to the passed Mesh.
  20914. * Sets it as updatable or not (default `false`)
  20915. * @param mesh the mesh the vertexData is applied to
  20916. * @param updatable when used and having the value true allows new data to update the vertexData
  20917. * @returns the VertexData
  20918. */
  20919. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  20920. /**
  20921. * Associates the vertexData to the passed Geometry.
  20922. * Sets it as updatable or not (default `false`)
  20923. * @param geometry the geometry the vertexData is applied to
  20924. * @param updatable when used and having the value true allows new data to update the vertexData
  20925. * @returns VertexData
  20926. */
  20927. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  20928. /**
  20929. * Updates the associated mesh
  20930. * @param mesh the mesh to be updated
  20931. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20932. * @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
  20933. * @returns VertexData
  20934. */
  20935. updateMesh(mesh: Mesh): VertexData;
  20936. /**
  20937. * Updates the associated geometry
  20938. * @param geometry the geometry to be updated
  20939. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  20940. * @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
  20941. * @returns VertexData.
  20942. */
  20943. updateGeometry(geometry: Geometry): VertexData;
  20944. private _applyTo;
  20945. private _update;
  20946. /**
  20947. * Transforms each position and each normal of the vertexData according to the passed Matrix
  20948. * @param matrix the transforming matrix
  20949. * @returns the VertexData
  20950. */
  20951. transform(matrix: Matrix): VertexData;
  20952. /**
  20953. * Merges the passed VertexData into the current one
  20954. * @param other the VertexData to be merged into the current one
  20955. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  20956. * @returns the modified VertexData
  20957. */
  20958. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  20959. private _mergeElement;
  20960. private _validate;
  20961. /**
  20962. * Serializes the VertexData
  20963. * @returns a serialized object
  20964. */
  20965. serialize(): any;
  20966. /**
  20967. * Extracts the vertexData from a mesh
  20968. * @param mesh the mesh from which to extract the VertexData
  20969. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  20970. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20971. * @returns the object VertexData associated to the passed mesh
  20972. */
  20973. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20974. /**
  20975. * Extracts the vertexData from the geometry
  20976. * @param geometry the geometry from which to extract the VertexData
  20977. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  20978. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  20979. * @returns the object VertexData associated to the passed mesh
  20980. */
  20981. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  20982. private static _ExtractFrom;
  20983. /**
  20984. * Creates the VertexData for a Ribbon
  20985. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  20986. * * pathArray array of paths, each of which an array of successive Vector3
  20987. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  20988. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  20989. * * 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
  20990. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  20991. * * 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)
  20992. * * 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)
  20993. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  20994. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  20995. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  20996. * @returns the VertexData of the ribbon
  20997. */
  20998. static CreateRibbon(options: {
  20999. pathArray: Vector3[][];
  21000. closeArray?: boolean;
  21001. closePath?: boolean;
  21002. offset?: number;
  21003. sideOrientation?: number;
  21004. frontUVs?: Vector4;
  21005. backUVs?: Vector4;
  21006. invertUV?: boolean;
  21007. uvs?: Vector2[];
  21008. colors?: Color4[];
  21009. }): VertexData;
  21010. /**
  21011. * Creates the VertexData for a box
  21012. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21013. * * size sets the width, height and depth of the box to the value of size, optional default 1
  21014. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  21015. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  21016. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  21017. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21018. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21019. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21020. * * 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)
  21021. * * 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)
  21022. * @returns the VertexData of the box
  21023. */
  21024. static CreateBox(options: {
  21025. size?: number;
  21026. width?: number;
  21027. height?: number;
  21028. depth?: number;
  21029. faceUV?: Vector4[];
  21030. faceColors?: Color4[];
  21031. sideOrientation?: number;
  21032. frontUVs?: Vector4;
  21033. backUVs?: Vector4;
  21034. }): VertexData;
  21035. /**
  21036. * Creates the VertexData for a tiled box
  21037. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21038. * * faceTiles sets the pattern, tile size and number of tiles for a face
  21039. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  21040. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  21041. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21042. * @returns the VertexData of the box
  21043. */
  21044. static CreateTiledBox(options: {
  21045. pattern?: number;
  21046. width?: number;
  21047. height?: number;
  21048. depth?: number;
  21049. tileSize?: number;
  21050. tileWidth?: number;
  21051. tileHeight?: number;
  21052. alignHorizontal?: number;
  21053. alignVertical?: number;
  21054. faceUV?: Vector4[];
  21055. faceColors?: Color4[];
  21056. sideOrientation?: number;
  21057. }): VertexData;
  21058. /**
  21059. * Creates the VertexData for a tiled plane
  21060. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21061. * * pattern a limited pattern arrangement depending on the number
  21062. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  21063. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  21064. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  21065. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21066. * * 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)
  21067. * * 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)
  21068. * @returns the VertexData of the tiled plane
  21069. */
  21070. static CreateTiledPlane(options: {
  21071. pattern?: number;
  21072. tileSize?: number;
  21073. tileWidth?: number;
  21074. tileHeight?: number;
  21075. size?: number;
  21076. width?: number;
  21077. height?: number;
  21078. alignHorizontal?: number;
  21079. alignVertical?: number;
  21080. sideOrientation?: number;
  21081. frontUVs?: Vector4;
  21082. backUVs?: Vector4;
  21083. }): VertexData;
  21084. /**
  21085. * Creates the VertexData for an ellipsoid, defaults to a sphere
  21086. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21087. * * segments sets the number of horizontal strips optional, default 32
  21088. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  21089. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  21090. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  21091. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  21092. * * 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
  21093. * * 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
  21094. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21095. * * 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)
  21096. * * 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)
  21097. * @returns the VertexData of the ellipsoid
  21098. */
  21099. static CreateSphere(options: {
  21100. segments?: number;
  21101. diameter?: number;
  21102. diameterX?: number;
  21103. diameterY?: number;
  21104. diameterZ?: number;
  21105. arc?: number;
  21106. slice?: number;
  21107. sideOrientation?: number;
  21108. frontUVs?: Vector4;
  21109. backUVs?: Vector4;
  21110. }): VertexData;
  21111. /**
  21112. * Creates the VertexData for a cylinder, cone or prism
  21113. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21114. * * height sets the height (y direction) of the cylinder, optional, default 2
  21115. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  21116. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  21117. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  21118. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21119. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  21120. * * 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
  21121. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21122. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21123. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  21124. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  21125. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21126. * * 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)
  21127. * * 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)
  21128. * @returns the VertexData of the cylinder, cone or prism
  21129. */
  21130. static CreateCylinder(options: {
  21131. height?: number;
  21132. diameterTop?: number;
  21133. diameterBottom?: number;
  21134. diameter?: number;
  21135. tessellation?: number;
  21136. subdivisions?: number;
  21137. arc?: number;
  21138. faceColors?: Color4[];
  21139. faceUV?: Vector4[];
  21140. hasRings?: boolean;
  21141. enclose?: boolean;
  21142. sideOrientation?: number;
  21143. frontUVs?: Vector4;
  21144. backUVs?: Vector4;
  21145. }): VertexData;
  21146. /**
  21147. * Creates the VertexData for a torus
  21148. * @param options an object used to set the following optional parameters for the box, required but can be empty
  21149. * * diameter the diameter of the torus, optional default 1
  21150. * * thickness the diameter of the tube forming the torus, optional default 0.5
  21151. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  21152. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21153. * * 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)
  21154. * * 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)
  21155. * @returns the VertexData of the torus
  21156. */
  21157. static CreateTorus(options: {
  21158. diameter?: number;
  21159. thickness?: number;
  21160. tessellation?: number;
  21161. sideOrientation?: number;
  21162. frontUVs?: Vector4;
  21163. backUVs?: Vector4;
  21164. }): VertexData;
  21165. /**
  21166. * Creates the VertexData of the LineSystem
  21167. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  21168. * - lines an array of lines, each line being an array of successive Vector3
  21169. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  21170. * @returns the VertexData of the LineSystem
  21171. */
  21172. static CreateLineSystem(options: {
  21173. lines: Vector3[][];
  21174. colors?: Nullable<Color4[][]>;
  21175. }): VertexData;
  21176. /**
  21177. * Create the VertexData for a DashedLines
  21178. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  21179. * - points an array successive Vector3
  21180. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  21181. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  21182. * - dashNb the intended total number of dashes, optional, default 200
  21183. * @returns the VertexData for the DashedLines
  21184. */
  21185. static CreateDashedLines(options: {
  21186. points: Vector3[];
  21187. dashSize?: number;
  21188. gapSize?: number;
  21189. dashNb?: number;
  21190. }): VertexData;
  21191. /**
  21192. * Creates the VertexData for a Ground
  21193. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21194. * - width the width (x direction) of the ground, optional, default 1
  21195. * - height the height (z direction) of the ground, optional, default 1
  21196. * - subdivisions the number of subdivisions per side, optional, default 1
  21197. * @returns the VertexData of the Ground
  21198. */
  21199. static CreateGround(options: {
  21200. width?: number;
  21201. height?: number;
  21202. subdivisions?: number;
  21203. subdivisionsX?: number;
  21204. subdivisionsY?: number;
  21205. }): VertexData;
  21206. /**
  21207. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  21208. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  21209. * * xmin the ground minimum X coordinate, optional, default -1
  21210. * * zmin the ground minimum Z coordinate, optional, default -1
  21211. * * xmax the ground maximum X coordinate, optional, default 1
  21212. * * zmax the ground maximum Z coordinate, optional, default 1
  21213. * * 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}
  21214. * * 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}
  21215. * @returns the VertexData of the TiledGround
  21216. */
  21217. static CreateTiledGround(options: {
  21218. xmin: number;
  21219. zmin: number;
  21220. xmax: number;
  21221. zmax: number;
  21222. subdivisions?: {
  21223. w: number;
  21224. h: number;
  21225. };
  21226. precision?: {
  21227. w: number;
  21228. h: number;
  21229. };
  21230. }): VertexData;
  21231. /**
  21232. * Creates the VertexData of the Ground designed from a heightmap
  21233. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  21234. * * width the width (x direction) of the ground
  21235. * * height the height (z direction) of the ground
  21236. * * subdivisions the number of subdivisions per side
  21237. * * minHeight the minimum altitude on the ground, optional, default 0
  21238. * * maxHeight the maximum altitude on the ground, optional default 1
  21239. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  21240. * * buffer the array holding the image color data
  21241. * * bufferWidth the width of image
  21242. * * bufferHeight the height of image
  21243. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  21244. * @returns the VertexData of the Ground designed from a heightmap
  21245. */
  21246. static CreateGroundFromHeightMap(options: {
  21247. width: number;
  21248. height: number;
  21249. subdivisions: number;
  21250. minHeight: number;
  21251. maxHeight: number;
  21252. colorFilter: Color3;
  21253. buffer: Uint8Array;
  21254. bufferWidth: number;
  21255. bufferHeight: number;
  21256. alphaFilter: number;
  21257. }): VertexData;
  21258. /**
  21259. * Creates the VertexData for a Plane
  21260. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  21261. * * size sets the width and height of the plane to the value of size, optional default 1
  21262. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  21263. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  21264. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21265. * * 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)
  21266. * * 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)
  21267. * @returns the VertexData of the box
  21268. */
  21269. static CreatePlane(options: {
  21270. size?: number;
  21271. width?: number;
  21272. height?: number;
  21273. sideOrientation?: number;
  21274. frontUVs?: Vector4;
  21275. backUVs?: Vector4;
  21276. }): VertexData;
  21277. /**
  21278. * Creates the VertexData of the Disc or regular Polygon
  21279. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  21280. * * radius the radius of the disc, optional default 0.5
  21281. * * tessellation the number of polygon sides, optional, default 64
  21282. * * 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
  21283. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21284. * * 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)
  21285. * * 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)
  21286. * @returns the VertexData of the box
  21287. */
  21288. static CreateDisc(options: {
  21289. radius?: number;
  21290. tessellation?: number;
  21291. arc?: number;
  21292. sideOrientation?: number;
  21293. frontUVs?: Vector4;
  21294. backUVs?: Vector4;
  21295. }): VertexData;
  21296. /**
  21297. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  21298. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  21299. * @param polygon a mesh built from polygonTriangulation.build()
  21300. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21301. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21302. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21303. * @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)
  21304. * @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)
  21305. * @returns the VertexData of the Polygon
  21306. */
  21307. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  21308. /**
  21309. * Creates the VertexData of the IcoSphere
  21310. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  21311. * * radius the radius of the IcoSphere, optional default 1
  21312. * * radiusX allows stretching in the x direction, optional, default radius
  21313. * * radiusY allows stretching in the y direction, optional, default radius
  21314. * * radiusZ allows stretching in the z direction, optional, default radius
  21315. * * flat when true creates a flat shaded mesh, optional, default true
  21316. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21318. * * 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)
  21319. * * 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)
  21320. * @returns the VertexData of the IcoSphere
  21321. */
  21322. static CreateIcoSphere(options: {
  21323. radius?: number;
  21324. radiusX?: number;
  21325. radiusY?: number;
  21326. radiusZ?: number;
  21327. flat?: boolean;
  21328. subdivisions?: number;
  21329. sideOrientation?: number;
  21330. frontUVs?: Vector4;
  21331. backUVs?: Vector4;
  21332. }): VertexData;
  21333. /**
  21334. * Creates the VertexData for a Polyhedron
  21335. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  21336. * * type provided types are:
  21337. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  21338. * * 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)
  21339. * * size the size of the IcoSphere, optional default 1
  21340. * * sizeX allows stretching in the x direction, optional, default size
  21341. * * sizeY allows stretching in the y direction, optional, default size
  21342. * * sizeZ allows stretching in the z direction, optional, default size
  21343. * * 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
  21344. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  21345. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  21346. * * flat when true creates a flat shaded mesh, optional, default true
  21347. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  21348. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21349. * * 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)
  21350. * * 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)
  21351. * @returns the VertexData of the Polyhedron
  21352. */
  21353. static CreatePolyhedron(options: {
  21354. type?: number;
  21355. size?: number;
  21356. sizeX?: number;
  21357. sizeY?: number;
  21358. sizeZ?: number;
  21359. custom?: any;
  21360. faceUV?: Vector4[];
  21361. faceColors?: Color4[];
  21362. flat?: boolean;
  21363. sideOrientation?: number;
  21364. frontUVs?: Vector4;
  21365. backUVs?: Vector4;
  21366. }): VertexData;
  21367. /**
  21368. * Creates the VertexData for a TorusKnot
  21369. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  21370. * * radius the radius of the torus knot, optional, default 2
  21371. * * tube the thickness of the tube, optional, default 0.5
  21372. * * radialSegments the number of sides on each tube segments, optional, default 32
  21373. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  21374. * * p the number of windings around the z axis, optional, default 2
  21375. * * q the number of windings around the x axis, optional, default 3
  21376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21377. * * 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)
  21378. * * 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)
  21379. * @returns the VertexData of the Torus Knot
  21380. */
  21381. static CreateTorusKnot(options: {
  21382. radius?: number;
  21383. tube?: number;
  21384. radialSegments?: number;
  21385. tubularSegments?: number;
  21386. p?: number;
  21387. q?: number;
  21388. sideOrientation?: number;
  21389. frontUVs?: Vector4;
  21390. backUVs?: Vector4;
  21391. }): VertexData;
  21392. /**
  21393. * Compute normals for given positions and indices
  21394. * @param positions an array of vertex positions, [...., x, y, z, ......]
  21395. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  21396. * @param normals an array of vertex normals, [...., x, y, z, ......]
  21397. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  21398. * * facetNormals : optional array of facet normals (vector3)
  21399. * * facetPositions : optional array of facet positions (vector3)
  21400. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  21401. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  21402. * * bInfo : optional bounding info, required for facetPartitioning computation
  21403. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  21404. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  21405. * * useRightHandedSystem: optional boolean to for right handed system computation
  21406. * * depthSort : optional boolean to enable the facet depth sort computation
  21407. * * distanceTo : optional Vector3 to compute the facet depth from this location
  21408. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  21409. */
  21410. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  21411. facetNormals?: any;
  21412. facetPositions?: any;
  21413. facetPartitioning?: any;
  21414. ratio?: number;
  21415. bInfo?: any;
  21416. bbSize?: Vector3;
  21417. subDiv?: any;
  21418. useRightHandedSystem?: boolean;
  21419. depthSort?: boolean;
  21420. distanceTo?: Vector3;
  21421. depthSortedFacets?: any;
  21422. }): void;
  21423. /** @hidden */ private static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  21424. /**
  21425. * Applies VertexData created from the imported parameters to the geometry
  21426. * @param parsedVertexData the parsed data from an imported file
  21427. * @param geometry the geometry to apply the VertexData to
  21428. */
  21429. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  21430. }
  21431. }
  21432. declare module BABYLON {
  21433. /**
  21434. * Defines a target to use with MorphTargetManager
  21435. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21436. */
  21437. export class MorphTarget implements IAnimatable {
  21438. /** defines the name of the target */
  21439. name: string;
  21440. /**
  21441. * Gets or sets the list of animations
  21442. */
  21443. animations: Animation[];
  21444. private _scene;
  21445. private _positions;
  21446. private _normals;
  21447. private _tangents;
  21448. private _uvs;
  21449. private _influence;
  21450. /**
  21451. * Observable raised when the influence changes
  21452. */
  21453. onInfluenceChanged: Observable<boolean>;
  21454. /** @hidden */ private _onDataLayoutChanged: Observable<void>;
  21455. /**
  21456. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  21457. */
  21458. influence: number;
  21459. /**
  21460. * Gets or sets the id of the morph Target
  21461. */
  21462. id: string;
  21463. private _animationPropertiesOverride;
  21464. /**
  21465. * Gets or sets the animation properties override
  21466. */
  21467. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  21468. /**
  21469. * Creates a new MorphTarget
  21470. * @param name defines the name of the target
  21471. * @param influence defines the influence to use
  21472. * @param scene defines the scene the morphtarget belongs to
  21473. */
  21474. constructor(
  21475. /** defines the name of the target */
  21476. name: string, influence?: number, scene?: Nullable<Scene>);
  21477. /**
  21478. * Gets a boolean defining if the target contains position data
  21479. */
  21480. readonly hasPositions: boolean;
  21481. /**
  21482. * Gets a boolean defining if the target contains normal data
  21483. */
  21484. readonly hasNormals: boolean;
  21485. /**
  21486. * Gets a boolean defining if the target contains tangent data
  21487. */
  21488. readonly hasTangents: boolean;
  21489. /**
  21490. * Gets a boolean defining if the target contains texture coordinates data
  21491. */
  21492. readonly hasUVs: boolean;
  21493. /**
  21494. * Affects position data to this target
  21495. * @param data defines the position data to use
  21496. */
  21497. setPositions(data: Nullable<FloatArray>): void;
  21498. /**
  21499. * Gets the position data stored in this target
  21500. * @returns a FloatArray containing the position data (or null if not present)
  21501. */
  21502. getPositions(): Nullable<FloatArray>;
  21503. /**
  21504. * Affects normal data to this target
  21505. * @param data defines the normal data to use
  21506. */
  21507. setNormals(data: Nullable<FloatArray>): void;
  21508. /**
  21509. * Gets the normal data stored in this target
  21510. * @returns a FloatArray containing the normal data (or null if not present)
  21511. */
  21512. getNormals(): Nullable<FloatArray>;
  21513. /**
  21514. * Affects tangent data to this target
  21515. * @param data defines the tangent data to use
  21516. */
  21517. setTangents(data: Nullable<FloatArray>): void;
  21518. /**
  21519. * Gets the tangent data stored in this target
  21520. * @returns a FloatArray containing the tangent data (or null if not present)
  21521. */
  21522. getTangents(): Nullable<FloatArray>;
  21523. /**
  21524. * Affects texture coordinates data to this target
  21525. * @param data defines the texture coordinates data to use
  21526. */
  21527. setUVs(data: Nullable<FloatArray>): void;
  21528. /**
  21529. * Gets the texture coordinates data stored in this target
  21530. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  21531. */
  21532. getUVs(): Nullable<FloatArray>;
  21533. /**
  21534. * Serializes the current target into a Serialization object
  21535. * @returns the serialized object
  21536. */
  21537. serialize(): any;
  21538. /**
  21539. * Returns the string "MorphTarget"
  21540. * @returns "MorphTarget"
  21541. */
  21542. getClassName(): string;
  21543. /**
  21544. * Creates a new target from serialized data
  21545. * @param serializationObject defines the serialized data to use
  21546. * @returns a new MorphTarget
  21547. */
  21548. static Parse(serializationObject: any): MorphTarget;
  21549. /**
  21550. * Creates a MorphTarget from mesh data
  21551. * @param mesh defines the source mesh
  21552. * @param name defines the name to use for the new target
  21553. * @param influence defines the influence to attach to the target
  21554. * @returns a new MorphTarget
  21555. */
  21556. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  21557. }
  21558. }
  21559. declare module BABYLON {
  21560. /**
  21561. * This class is used to deform meshes using morphing between different targets
  21562. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21563. */
  21564. export class MorphTargetManager {
  21565. private _targets;
  21566. private _targetInfluenceChangedObservers;
  21567. private _targetDataLayoutChangedObservers;
  21568. private _activeTargets;
  21569. private _scene;
  21570. private _influences;
  21571. private _supportsNormals;
  21572. private _supportsTangents;
  21573. private _supportsUVs;
  21574. private _vertexCount;
  21575. private _uniqueId;
  21576. private _tempInfluences;
  21577. /**
  21578. * Gets or sets a boolean indicating if normals must be morphed
  21579. */
  21580. enableNormalMorphing: boolean;
  21581. /**
  21582. * Gets or sets a boolean indicating if tangents must be morphed
  21583. */
  21584. enableTangentMorphing: boolean;
  21585. /**
  21586. * Gets or sets a boolean indicating if UV must be morphed
  21587. */
  21588. enableUVMorphing: boolean;
  21589. /**
  21590. * Creates a new MorphTargetManager
  21591. * @param scene defines the current scene
  21592. */
  21593. constructor(scene?: Nullable<Scene>);
  21594. /**
  21595. * Gets the unique ID of this manager
  21596. */
  21597. readonly uniqueId: number;
  21598. /**
  21599. * Gets the number of vertices handled by this manager
  21600. */
  21601. readonly vertexCount: number;
  21602. /**
  21603. * Gets a boolean indicating if this manager supports morphing of normals
  21604. */
  21605. readonly supportsNormals: boolean;
  21606. /**
  21607. * Gets a boolean indicating if this manager supports morphing of tangents
  21608. */
  21609. readonly supportsTangents: boolean;
  21610. /**
  21611. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  21612. */
  21613. readonly supportsUVs: boolean;
  21614. /**
  21615. * Gets the number of targets stored in this manager
  21616. */
  21617. readonly numTargets: number;
  21618. /**
  21619. * Gets the number of influencers (ie. the number of targets with influences > 0)
  21620. */
  21621. readonly numInfluencers: number;
  21622. /**
  21623. * Gets the list of influences (one per target)
  21624. */
  21625. readonly influences: Float32Array;
  21626. /**
  21627. * Gets the active target at specified index. An active target is a target with an influence > 0
  21628. * @param index defines the index to check
  21629. * @returns the requested target
  21630. */
  21631. getActiveTarget(index: number): MorphTarget;
  21632. /**
  21633. * Gets the target at specified index
  21634. * @param index defines the index to check
  21635. * @returns the requested target
  21636. */
  21637. getTarget(index: number): MorphTarget;
  21638. /**
  21639. * Add a new target to this manager
  21640. * @param target defines the target to add
  21641. */
  21642. addTarget(target: MorphTarget): void;
  21643. /**
  21644. * Removes a target from the manager
  21645. * @param target defines the target to remove
  21646. */
  21647. removeTarget(target: MorphTarget): void;
  21648. /**
  21649. * Serializes the current manager into a Serialization object
  21650. * @returns the serialized object
  21651. */
  21652. serialize(): any;
  21653. private _syncActiveTargets;
  21654. /**
  21655. * Syncrhonize the targets with all the meshes using this morph target manager
  21656. */
  21657. synchronize(): void;
  21658. /**
  21659. * Creates a new MorphTargetManager from serialized data
  21660. * @param serializationObject defines the serialized data
  21661. * @param scene defines the hosting scene
  21662. * @returns the new MorphTargetManager
  21663. */
  21664. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  21665. }
  21666. }
  21667. declare module BABYLON {
  21668. /**
  21669. * Class used to represent a specific level of detail of a mesh
  21670. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21671. */
  21672. export class MeshLODLevel {
  21673. /** Defines the distance where this level should star being displayed */
  21674. distance: number;
  21675. /** Defines the mesh to use to render this level */
  21676. mesh: Nullable<Mesh>;
  21677. /**
  21678. * Creates a new LOD level
  21679. * @param distance defines the distance where this level should star being displayed
  21680. * @param mesh defines the mesh to use to render this level
  21681. */
  21682. constructor(
  21683. /** Defines the distance where this level should star being displayed */
  21684. distance: number,
  21685. /** Defines the mesh to use to render this level */
  21686. mesh: Nullable<Mesh>);
  21687. }
  21688. }
  21689. declare module BABYLON {
  21690. /**
  21691. * Mesh representing the gorund
  21692. */
  21693. export class GroundMesh extends Mesh {
  21694. /** If octree should be generated */
  21695. generateOctree: boolean;
  21696. private _heightQuads;
  21697. /** @hidden */ private _subdivisionsX: number;
  21698. /** @hidden */ private _subdivisionsY: number;
  21699. /** @hidden */ private _width: number;
  21700. /** @hidden */ private _height: number;
  21701. /** @hidden */ private _minX: number;
  21702. /** @hidden */ private _maxX: number;
  21703. /** @hidden */ private _minZ: number;
  21704. /** @hidden */ private _maxZ: number;
  21705. constructor(name: string, scene: Scene);
  21706. /**
  21707. * "GroundMesh"
  21708. * @returns "GroundMesh"
  21709. */
  21710. getClassName(): string;
  21711. /**
  21712. * The minimum of x and y subdivisions
  21713. */
  21714. readonly subdivisions: number;
  21715. /**
  21716. * X subdivisions
  21717. */
  21718. readonly subdivisionsX: number;
  21719. /**
  21720. * Y subdivisions
  21721. */
  21722. readonly subdivisionsY: number;
  21723. /**
  21724. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  21725. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  21726. * @param chunksCount the number of subdivisions for x and y
  21727. * @param octreeBlocksSize (Default: 32)
  21728. */
  21729. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  21730. /**
  21731. * Returns a height (y) value in the Worl system :
  21732. * the ground altitude at the coordinates (x, z) expressed in the World system.
  21733. * @param x x coordinate
  21734. * @param z z coordinate
  21735. * @returns the ground y position if (x, z) are outside the ground surface.
  21736. */
  21737. getHeightAtCoordinates(x: number, z: number): number;
  21738. /**
  21739. * Returns a normalized vector (Vector3) orthogonal to the ground
  21740. * at the ground coordinates (x, z) expressed in the World system.
  21741. * @param x x coordinate
  21742. * @param z z coordinate
  21743. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  21744. */
  21745. getNormalAtCoordinates(x: number, z: number): Vector3;
  21746. /**
  21747. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  21748. * at the ground coordinates (x, z) expressed in the World system.
  21749. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  21750. * @param x x coordinate
  21751. * @param z z coordinate
  21752. * @param ref vector to store the result
  21753. * @returns the GroundMesh.
  21754. */
  21755. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  21756. /**
  21757. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  21758. * if the ground has been updated.
  21759. * This can be used in the render loop.
  21760. * @returns the GroundMesh.
  21761. */
  21762. updateCoordinateHeights(): GroundMesh;
  21763. private _getFacetAt;
  21764. private _initHeightQuads;
  21765. private _computeHeightQuads;
  21766. /**
  21767. * Serializes this ground mesh
  21768. * @param serializationObject object to write serialization to
  21769. */
  21770. serialize(serializationObject: any): void;
  21771. /**
  21772. * Parses a serialized ground mesh
  21773. * @param parsedMesh the serialized mesh
  21774. * @param scene the scene to create the ground mesh in
  21775. * @returns the created ground mesh
  21776. */
  21777. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  21778. }
  21779. }
  21780. declare module BABYLON {
  21781. /**
  21782. * Interface for Physics-Joint data
  21783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21784. */
  21785. export interface PhysicsJointData {
  21786. /**
  21787. * The main pivot of the joint
  21788. */
  21789. mainPivot?: Vector3;
  21790. /**
  21791. * The connected pivot of the joint
  21792. */
  21793. connectedPivot?: Vector3;
  21794. /**
  21795. * The main axis of the joint
  21796. */
  21797. mainAxis?: Vector3;
  21798. /**
  21799. * The connected axis of the joint
  21800. */
  21801. connectedAxis?: Vector3;
  21802. /**
  21803. * The collision of the joint
  21804. */
  21805. collision?: boolean;
  21806. /**
  21807. * Native Oimo/Cannon/Energy data
  21808. */
  21809. nativeParams?: any;
  21810. }
  21811. /**
  21812. * This is a holder class for the physics joint created by the physics plugin
  21813. * It holds a set of functions to control the underlying joint
  21814. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21815. */
  21816. export class PhysicsJoint {
  21817. /**
  21818. * The type of the physics joint
  21819. */
  21820. type: number;
  21821. /**
  21822. * The data for the physics joint
  21823. */
  21824. jointData: PhysicsJointData;
  21825. private _physicsJoint;
  21826. protected _physicsPlugin: IPhysicsEnginePlugin;
  21827. /**
  21828. * Initializes the physics joint
  21829. * @param type The type of the physics joint
  21830. * @param jointData The data for the physics joint
  21831. */
  21832. constructor(
  21833. /**
  21834. * The type of the physics joint
  21835. */
  21836. type: number,
  21837. /**
  21838. * The data for the physics joint
  21839. */
  21840. jointData: PhysicsJointData);
  21841. /**
  21842. * Gets the physics joint
  21843. */
  21844. /**
  21845. * Sets the physics joint
  21846. */
  21847. physicsJoint: any;
  21848. /**
  21849. * Sets the physics plugin
  21850. */
  21851. physicsPlugin: IPhysicsEnginePlugin;
  21852. /**
  21853. * Execute a function that is physics-plugin specific.
  21854. * @param {Function} func the function that will be executed.
  21855. * It accepts two parameters: the physics world and the physics joint
  21856. */
  21857. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  21858. /**
  21859. * Distance-Joint type
  21860. */
  21861. static DistanceJoint: number;
  21862. /**
  21863. * Hinge-Joint type
  21864. */
  21865. static HingeJoint: number;
  21866. /**
  21867. * Ball-and-Socket joint type
  21868. */
  21869. static BallAndSocketJoint: number;
  21870. /**
  21871. * Wheel-Joint type
  21872. */
  21873. static WheelJoint: number;
  21874. /**
  21875. * Slider-Joint type
  21876. */
  21877. static SliderJoint: number;
  21878. /**
  21879. * Prismatic-Joint type
  21880. */
  21881. static PrismaticJoint: number;
  21882. /**
  21883. * Universal-Joint type
  21884. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  21885. */
  21886. static UniversalJoint: number;
  21887. /**
  21888. * Hinge-Joint 2 type
  21889. */
  21890. static Hinge2Joint: number;
  21891. /**
  21892. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  21893. */
  21894. static PointToPointJoint: number;
  21895. /**
  21896. * Spring-Joint type
  21897. */
  21898. static SpringJoint: number;
  21899. /**
  21900. * Lock-Joint type
  21901. */
  21902. static LockJoint: number;
  21903. }
  21904. /**
  21905. * A class representing a physics distance joint
  21906. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21907. */
  21908. export class DistanceJoint extends PhysicsJoint {
  21909. /**
  21910. *
  21911. * @param jointData The data for the Distance-Joint
  21912. */
  21913. constructor(jointData: DistanceJointData);
  21914. /**
  21915. * Update the predefined distance.
  21916. * @param maxDistance The maximum preferred distance
  21917. * @param minDistance The minimum preferred distance
  21918. */
  21919. updateDistance(maxDistance: number, minDistance?: number): void;
  21920. }
  21921. /**
  21922. * Represents a Motor-Enabled Joint
  21923. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21924. */
  21925. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  21926. /**
  21927. * Initializes the Motor-Enabled Joint
  21928. * @param type The type of the joint
  21929. * @param jointData The physica joint data for the joint
  21930. */
  21931. constructor(type: number, jointData: PhysicsJointData);
  21932. /**
  21933. * Set the motor values.
  21934. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21935. * @param force the force to apply
  21936. * @param maxForce max force for this motor.
  21937. */
  21938. setMotor(force?: number, maxForce?: number): void;
  21939. /**
  21940. * Set the motor's limits.
  21941. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21942. * @param upperLimit The upper limit of the motor
  21943. * @param lowerLimit The lower limit of the motor
  21944. */
  21945. setLimit(upperLimit: number, lowerLimit?: number): void;
  21946. }
  21947. /**
  21948. * This class represents a single physics Hinge-Joint
  21949. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21950. */
  21951. export class HingeJoint extends MotorEnabledJoint {
  21952. /**
  21953. * Initializes the Hinge-Joint
  21954. * @param jointData The joint data for the Hinge-Joint
  21955. */
  21956. constructor(jointData: PhysicsJointData);
  21957. /**
  21958. * Set the motor values.
  21959. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21960. * @param {number} force the force to apply
  21961. * @param {number} maxForce max force for this motor.
  21962. */
  21963. setMotor(force?: number, maxForce?: number): void;
  21964. /**
  21965. * Set the motor's limits.
  21966. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21967. * @param upperLimit The upper limit of the motor
  21968. * @param lowerLimit The lower limit of the motor
  21969. */
  21970. setLimit(upperLimit: number, lowerLimit?: number): void;
  21971. }
  21972. /**
  21973. * This class represents a dual hinge physics joint (same as wheel joint)
  21974. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  21975. */
  21976. export class Hinge2Joint extends MotorEnabledJoint {
  21977. /**
  21978. * Initializes the Hinge2-Joint
  21979. * @param jointData The joint data for the Hinge2-Joint
  21980. */
  21981. constructor(jointData: PhysicsJointData);
  21982. /**
  21983. * Set the motor values.
  21984. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21985. * @param {number} targetSpeed the speed the motor is to reach
  21986. * @param {number} maxForce max force for this motor.
  21987. * @param {motorIndex} the motor's index, 0 or 1.
  21988. */
  21989. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  21990. /**
  21991. * Set the motor limits.
  21992. * Attention, this function is plugin specific. Engines won't react 100% the same.
  21993. * @param {number} upperLimit the upper limit
  21994. * @param {number} lowerLimit lower limit
  21995. * @param {motorIndex} the motor's index, 0 or 1.
  21996. */
  21997. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  21998. }
  21999. /**
  22000. * Interface for a motor enabled joint
  22001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22002. */
  22003. export interface IMotorEnabledJoint {
  22004. /**
  22005. * Physics joint
  22006. */
  22007. physicsJoint: any;
  22008. /**
  22009. * Sets the motor of the motor-enabled joint
  22010. * @param force The force of the motor
  22011. * @param maxForce The maximum force of the motor
  22012. * @param motorIndex The index of the motor
  22013. */
  22014. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  22015. /**
  22016. * Sets the limit of the motor
  22017. * @param upperLimit The upper limit of the motor
  22018. * @param lowerLimit The lower limit of the motor
  22019. * @param motorIndex The index of the motor
  22020. */
  22021. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22022. }
  22023. /**
  22024. * Joint data for a Distance-Joint
  22025. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22026. */
  22027. export interface DistanceJointData extends PhysicsJointData {
  22028. /**
  22029. * Max distance the 2 joint objects can be apart
  22030. */
  22031. maxDistance: number;
  22032. }
  22033. /**
  22034. * Joint data from a spring joint
  22035. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22036. */
  22037. export interface SpringJointData extends PhysicsJointData {
  22038. /**
  22039. * Length of the spring
  22040. */
  22041. length: number;
  22042. /**
  22043. * Stiffness of the spring
  22044. */
  22045. stiffness: number;
  22046. /**
  22047. * Damping of the spring
  22048. */
  22049. damping: number;
  22050. /** this callback will be called when applying the force to the impostors. */
  22051. forceApplicationCallback: () => void;
  22052. }
  22053. }
  22054. declare module BABYLON {
  22055. /**
  22056. * Holds the data for the raycast result
  22057. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22058. */
  22059. export class PhysicsRaycastResult {
  22060. private _hasHit;
  22061. private _hitDistance;
  22062. private _hitNormalWorld;
  22063. private _hitPointWorld;
  22064. private _rayFromWorld;
  22065. private _rayToWorld;
  22066. /**
  22067. * Gets if there was a hit
  22068. */
  22069. readonly hasHit: boolean;
  22070. /**
  22071. * Gets the distance from the hit
  22072. */
  22073. readonly hitDistance: number;
  22074. /**
  22075. * Gets the hit normal/direction in the world
  22076. */
  22077. readonly hitNormalWorld: Vector3;
  22078. /**
  22079. * Gets the hit point in the world
  22080. */
  22081. readonly hitPointWorld: Vector3;
  22082. /**
  22083. * Gets the ray "start point" of the ray in the world
  22084. */
  22085. readonly rayFromWorld: Vector3;
  22086. /**
  22087. * Gets the ray "end point" of the ray in the world
  22088. */
  22089. readonly rayToWorld: Vector3;
  22090. /**
  22091. * Sets the hit data (normal & point in world space)
  22092. * @param hitNormalWorld defines the normal in world space
  22093. * @param hitPointWorld defines the point in world space
  22094. */
  22095. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  22096. /**
  22097. * Sets the distance from the start point to the hit point
  22098. * @param distance
  22099. */
  22100. setHitDistance(distance: number): void;
  22101. /**
  22102. * Calculates the distance manually
  22103. */
  22104. calculateHitDistance(): void;
  22105. /**
  22106. * Resets all the values to default
  22107. * @param from The from point on world space
  22108. * @param to The to point on world space
  22109. */
  22110. reset(from?: Vector3, to?: Vector3): void;
  22111. }
  22112. /**
  22113. * Interface for the size containing width and height
  22114. */
  22115. interface IXYZ {
  22116. /**
  22117. * X
  22118. */
  22119. x: number;
  22120. /**
  22121. * Y
  22122. */
  22123. y: number;
  22124. /**
  22125. * Z
  22126. */
  22127. z: number;
  22128. }
  22129. }
  22130. declare module BABYLON {
  22131. /**
  22132. * Interface used to describe a physics joint
  22133. */
  22134. export interface PhysicsImpostorJoint {
  22135. /** Defines the main impostor to which the joint is linked */
  22136. mainImpostor: PhysicsImpostor;
  22137. /** Defines the impostor that is connected to the main impostor using this joint */
  22138. connectedImpostor: PhysicsImpostor;
  22139. /** Defines the joint itself */
  22140. joint: PhysicsJoint;
  22141. }
  22142. /** @hidden */
  22143. export interface IPhysicsEnginePlugin {
  22144. world: any;
  22145. name: string;
  22146. setGravity(gravity: Vector3): void;
  22147. setTimeStep(timeStep: number): void;
  22148. getTimeStep(): number;
  22149. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22150. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22151. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22152. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22153. removePhysicsBody(impostor: PhysicsImpostor): void;
  22154. generateJoint(joint: PhysicsImpostorJoint): void;
  22155. removeJoint(joint: PhysicsImpostorJoint): void;
  22156. isSupported(): boolean;
  22157. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22158. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22159. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22160. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  22161. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22162. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22163. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22164. getBodyMass(impostor: PhysicsImpostor): number;
  22165. getBodyFriction(impostor: PhysicsImpostor): number;
  22166. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22167. getBodyRestitution(impostor: PhysicsImpostor): number;
  22168. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22169. getBodyPressure?(impostor: PhysicsImpostor): number;
  22170. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  22171. getBodyStiffness?(impostor: PhysicsImpostor): number;
  22172. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  22173. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  22174. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  22175. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  22176. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  22177. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22178. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  22179. sleepBody(impostor: PhysicsImpostor): void;
  22180. wakeUpBody(impostor: PhysicsImpostor): void;
  22181. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22182. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22183. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22184. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22185. getRadius(impostor: PhysicsImpostor): number;
  22186. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22187. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22188. dispose(): void;
  22189. }
  22190. /**
  22191. * Interface used to define a physics engine
  22192. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  22193. */
  22194. export interface IPhysicsEngine {
  22195. /**
  22196. * Gets the gravity vector used by the simulation
  22197. */
  22198. gravity: Vector3;
  22199. /**
  22200. * Sets the gravity vector used by the simulation
  22201. * @param gravity defines the gravity vector to use
  22202. */
  22203. setGravity(gravity: Vector3): void;
  22204. /**
  22205. * Set the time step of the physics engine.
  22206. * Default is 1/60.
  22207. * To slow it down, enter 1/600 for example.
  22208. * To speed it up, 1/30
  22209. * @param newTimeStep the new timestep to apply to this world.
  22210. */
  22211. setTimeStep(newTimeStep: number): void;
  22212. /**
  22213. * Get the time step of the physics engine.
  22214. * @returns the current time step
  22215. */
  22216. getTimeStep(): number;
  22217. /**
  22218. * Release all resources
  22219. */
  22220. dispose(): void;
  22221. /**
  22222. * Gets the name of the current physics plugin
  22223. * @returns the name of the plugin
  22224. */
  22225. getPhysicsPluginName(): string;
  22226. /**
  22227. * Adding a new impostor for the impostor tracking.
  22228. * This will be done by the impostor itself.
  22229. * @param impostor the impostor to add
  22230. */
  22231. addImpostor(impostor: PhysicsImpostor): void;
  22232. /**
  22233. * Remove an impostor from the engine.
  22234. * This impostor and its mesh will not longer be updated by the physics engine.
  22235. * @param impostor the impostor to remove
  22236. */
  22237. removeImpostor(impostor: PhysicsImpostor): void;
  22238. /**
  22239. * Add a joint to the physics engine
  22240. * @param mainImpostor defines the main impostor to which the joint is added.
  22241. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  22242. * @param joint defines the joint that will connect both impostors.
  22243. */
  22244. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22245. /**
  22246. * Removes a joint from the simulation
  22247. * @param mainImpostor defines the impostor used with the joint
  22248. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  22249. * @param joint defines the joint to remove
  22250. */
  22251. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  22252. /**
  22253. * Gets the current plugin used to run the simulation
  22254. * @returns current plugin
  22255. */
  22256. getPhysicsPlugin(): IPhysicsEnginePlugin;
  22257. /**
  22258. * Gets the list of physic impostors
  22259. * @returns an array of PhysicsImpostor
  22260. */
  22261. getImpostors(): Array<PhysicsImpostor>;
  22262. /**
  22263. * Gets the impostor for a physics enabled object
  22264. * @param object defines the object impersonated by the impostor
  22265. * @returns the PhysicsImpostor or null if not found
  22266. */
  22267. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22268. /**
  22269. * Gets the impostor for a physics body object
  22270. * @param body defines physics body used by the impostor
  22271. * @returns the PhysicsImpostor or null if not found
  22272. */
  22273. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  22274. /**
  22275. * Does a raycast in the physics world
  22276. * @param from when should the ray start?
  22277. * @param to when should the ray end?
  22278. * @returns PhysicsRaycastResult
  22279. */
  22280. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  22281. /**
  22282. * Called by the scene. No need to call it.
  22283. * @param delta defines the timespam between frames
  22284. */ private _step(delta: number): void;
  22285. }
  22286. }
  22287. declare module BABYLON {
  22288. /**
  22289. * The interface for the physics imposter parameters
  22290. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22291. */
  22292. export interface PhysicsImpostorParameters {
  22293. /**
  22294. * The mass of the physics imposter
  22295. */
  22296. mass: number;
  22297. /**
  22298. * The friction of the physics imposter
  22299. */
  22300. friction?: number;
  22301. /**
  22302. * The coefficient of restitution of the physics imposter
  22303. */
  22304. restitution?: number;
  22305. /**
  22306. * The native options of the physics imposter
  22307. */
  22308. nativeOptions?: any;
  22309. /**
  22310. * Specifies if the parent should be ignored
  22311. */
  22312. ignoreParent?: boolean;
  22313. /**
  22314. * Specifies if bi-directional transformations should be disabled
  22315. */
  22316. disableBidirectionalTransformation?: boolean;
  22317. /**
  22318. * The pressure inside the physics imposter, soft object only
  22319. */
  22320. pressure?: number;
  22321. /**
  22322. * The stiffness the physics imposter, soft object only
  22323. */
  22324. stiffness?: number;
  22325. /**
  22326. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  22327. */
  22328. velocityIterations?: number;
  22329. /**
  22330. * The number of iterations used in maintaining consistent vertex positions, soft object only
  22331. */
  22332. positionIterations?: number;
  22333. /**
  22334. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  22335. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  22336. * Add to fix multiple points
  22337. */
  22338. fixedPoints?: number;
  22339. /**
  22340. * The collision margin around a soft object
  22341. */
  22342. margin?: number;
  22343. /**
  22344. * The collision margin around a soft object
  22345. */
  22346. damping?: number;
  22347. /**
  22348. * The path for a rope based on an extrusion
  22349. */
  22350. path?: any;
  22351. /**
  22352. * The shape of an extrusion used for a rope based on an extrusion
  22353. */
  22354. shape?: any;
  22355. }
  22356. /**
  22357. * Interface for a physics-enabled object
  22358. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22359. */
  22360. export interface IPhysicsEnabledObject {
  22361. /**
  22362. * The position of the physics-enabled object
  22363. */
  22364. position: Vector3;
  22365. /**
  22366. * The rotation of the physics-enabled object
  22367. */
  22368. rotationQuaternion: Nullable<Quaternion>;
  22369. /**
  22370. * The scale of the physics-enabled object
  22371. */
  22372. scaling: Vector3;
  22373. /**
  22374. * The rotation of the physics-enabled object
  22375. */
  22376. rotation?: Vector3;
  22377. /**
  22378. * The parent of the physics-enabled object
  22379. */
  22380. parent?: any;
  22381. /**
  22382. * The bounding info of the physics-enabled object
  22383. * @returns The bounding info of the physics-enabled object
  22384. */
  22385. getBoundingInfo(): BoundingInfo;
  22386. /**
  22387. * Computes the world matrix
  22388. * @param force Specifies if the world matrix should be computed by force
  22389. * @returns A world matrix
  22390. */
  22391. computeWorldMatrix(force: boolean): Matrix;
  22392. /**
  22393. * Gets the world matrix
  22394. * @returns A world matrix
  22395. */
  22396. getWorldMatrix?(): Matrix;
  22397. /**
  22398. * Gets the child meshes
  22399. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  22400. * @returns An array of abstract meshes
  22401. */
  22402. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  22403. /**
  22404. * Gets the vertex data
  22405. * @param kind The type of vertex data
  22406. * @returns A nullable array of numbers, or a float32 array
  22407. */
  22408. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  22409. /**
  22410. * Gets the indices from the mesh
  22411. * @returns A nullable array of index arrays
  22412. */
  22413. getIndices?(): Nullable<IndicesArray>;
  22414. /**
  22415. * Gets the scene from the mesh
  22416. * @returns the indices array or null
  22417. */
  22418. getScene?(): Scene;
  22419. /**
  22420. * Gets the absolute position from the mesh
  22421. * @returns the absolute position
  22422. */
  22423. getAbsolutePosition(): Vector3;
  22424. /**
  22425. * Gets the absolute pivot point from the mesh
  22426. * @returns the absolute pivot point
  22427. */
  22428. getAbsolutePivotPoint(): Vector3;
  22429. /**
  22430. * Rotates the mesh
  22431. * @param axis The axis of rotation
  22432. * @param amount The amount of rotation
  22433. * @param space The space of the rotation
  22434. * @returns The rotation transform node
  22435. */
  22436. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  22437. /**
  22438. * Translates the mesh
  22439. * @param axis The axis of translation
  22440. * @param distance The distance of translation
  22441. * @param space The space of the translation
  22442. * @returns The transform node
  22443. */
  22444. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  22445. /**
  22446. * Sets the absolute position of the mesh
  22447. * @param absolutePosition The absolute position of the mesh
  22448. * @returns The transform node
  22449. */
  22450. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  22451. /**
  22452. * Gets the class name of the mesh
  22453. * @returns The class name
  22454. */
  22455. getClassName(): string;
  22456. }
  22457. /**
  22458. * Represents a physics imposter
  22459. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  22460. */
  22461. export class PhysicsImpostor {
  22462. /**
  22463. * The physics-enabled object used as the physics imposter
  22464. */
  22465. object: IPhysicsEnabledObject;
  22466. /**
  22467. * The type of the physics imposter
  22468. */
  22469. type: number;
  22470. private _options;
  22471. private _scene?;
  22472. /**
  22473. * The default object size of the imposter
  22474. */
  22475. static DEFAULT_OBJECT_SIZE: Vector3;
  22476. /**
  22477. * The identity quaternion of the imposter
  22478. */
  22479. static IDENTITY_QUATERNION: Quaternion;
  22480. /** @hidden */ private _pluginData: any;
  22481. private _physicsEngine;
  22482. private _physicsBody;
  22483. private _bodyUpdateRequired;
  22484. private _onBeforePhysicsStepCallbacks;
  22485. private _onAfterPhysicsStepCallbacks;
  22486. /** @hidden */ private _onPhysicsCollideCallbacks: Array<{
  22487. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  22488. otherImpostors: Array<PhysicsImpostor>;
  22489. }>;
  22490. private _deltaPosition;
  22491. private _deltaRotation;
  22492. private _deltaRotationConjugated;
  22493. /** @hidden */ private _isFromLine: boolean;
  22494. private _parent;
  22495. private _isDisposed;
  22496. private static _tmpVecs;
  22497. private static _tmpQuat;
  22498. /**
  22499. * Specifies if the physics imposter is disposed
  22500. */
  22501. readonly isDisposed: boolean;
  22502. /**
  22503. * Gets the mass of the physics imposter
  22504. */
  22505. mass: number;
  22506. /**
  22507. * Gets the coefficient of friction
  22508. */
  22509. /**
  22510. * Sets the coefficient of friction
  22511. */
  22512. friction: number;
  22513. /**
  22514. * Gets the coefficient of restitution
  22515. */
  22516. /**
  22517. * Sets the coefficient of restitution
  22518. */
  22519. restitution: number;
  22520. /**
  22521. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  22522. */
  22523. /**
  22524. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  22525. */
  22526. pressure: number;
  22527. /**
  22528. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22529. */
  22530. /**
  22531. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  22532. */
  22533. stiffness: number;
  22534. /**
  22535. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22536. */
  22537. /**
  22538. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  22539. */
  22540. velocityIterations: number;
  22541. /**
  22542. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22543. */
  22544. /**
  22545. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  22546. */
  22547. positionIterations: number;
  22548. /**
  22549. * The unique id of the physics imposter
  22550. * set by the physics engine when adding this impostor to the array
  22551. */
  22552. uniqueId: number;
  22553. /**
  22554. * @hidden
  22555. */
  22556. soft: boolean;
  22557. /**
  22558. * @hidden
  22559. */
  22560. segments: number;
  22561. private _joints;
  22562. /**
  22563. * Initializes the physics imposter
  22564. * @param object The physics-enabled object used as the physics imposter
  22565. * @param type The type of the physics imposter
  22566. * @param _options The options for the physics imposter
  22567. * @param _scene The Babylon scene
  22568. */
  22569. constructor(
  22570. /**
  22571. * The physics-enabled object used as the physics imposter
  22572. */
  22573. object: IPhysicsEnabledObject,
  22574. /**
  22575. * The type of the physics imposter
  22576. */
  22577. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  22578. /**
  22579. * This function will completly initialize this impostor.
  22580. * It will create a new body - but only if this mesh has no parent.
  22581. * If it has, this impostor will not be used other than to define the impostor
  22582. * of the child mesh.
  22583. * @hidden
  22584. */ private _init(): void;
  22585. private _getPhysicsParent;
  22586. /**
  22587. * Should a new body be generated.
  22588. * @returns boolean specifying if body initialization is required
  22589. */
  22590. isBodyInitRequired(): boolean;
  22591. /**
  22592. * Sets the updated scaling
  22593. * @param updated Specifies if the scaling is updated
  22594. */
  22595. setScalingUpdated(): void;
  22596. /**
  22597. * Force a regeneration of this or the parent's impostor's body.
  22598. * Use under cautious - This will remove all joints already implemented.
  22599. */
  22600. forceUpdate(): void;
  22601. /**
  22602. * Gets the body that holds this impostor. Either its own, or its parent.
  22603. */
  22604. /**
  22605. * Set the physics body. Used mainly by the physics engine/plugin
  22606. */
  22607. physicsBody: any;
  22608. /**
  22609. * Get the parent of the physics imposter
  22610. * @returns Physics imposter or null
  22611. */
  22612. /**
  22613. * Sets the parent of the physics imposter
  22614. */
  22615. parent: Nullable<PhysicsImpostor>;
  22616. /**
  22617. * Resets the update flags
  22618. */
  22619. resetUpdateFlags(): void;
  22620. /**
  22621. * Gets the object extend size
  22622. * @returns the object extend size
  22623. */
  22624. getObjectExtendSize(): Vector3;
  22625. /**
  22626. * Gets the object center
  22627. * @returns The object center
  22628. */
  22629. getObjectCenter(): Vector3;
  22630. /**
  22631. * Get a specific parametes from the options parameter
  22632. * @param paramName The object parameter name
  22633. * @returns The object parameter
  22634. */
  22635. getParam(paramName: string): any;
  22636. /**
  22637. * Sets a specific parameter in the options given to the physics plugin
  22638. * @param paramName The parameter name
  22639. * @param value The value of the parameter
  22640. */
  22641. setParam(paramName: string, value: number): void;
  22642. /**
  22643. * Specifically change the body's mass option. Won't recreate the physics body object
  22644. * @param mass The mass of the physics imposter
  22645. */
  22646. setMass(mass: number): void;
  22647. /**
  22648. * Gets the linear velocity
  22649. * @returns linear velocity or null
  22650. */
  22651. getLinearVelocity(): Nullable<Vector3>;
  22652. /**
  22653. * Sets the linear velocity
  22654. * @param velocity linear velocity or null
  22655. */
  22656. setLinearVelocity(velocity: Nullable<Vector3>): void;
  22657. /**
  22658. * Gets the angular velocity
  22659. * @returns angular velocity or null
  22660. */
  22661. getAngularVelocity(): Nullable<Vector3>;
  22662. /**
  22663. * Sets the angular velocity
  22664. * @param velocity The velocity or null
  22665. */
  22666. setAngularVelocity(velocity: Nullable<Vector3>): void;
  22667. /**
  22668. * Execute a function with the physics plugin native code
  22669. * Provide a function the will have two variables - the world object and the physics body object
  22670. * @param func The function to execute with the physics plugin native code
  22671. */
  22672. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  22673. /**
  22674. * Register a function that will be executed before the physics world is stepping forward
  22675. * @param func The function to execute before the physics world is stepped forward
  22676. */
  22677. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22678. /**
  22679. * Unregister a function that will be executed before the physics world is stepping forward
  22680. * @param func The function to execute before the physics world is stepped forward
  22681. */
  22682. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22683. /**
  22684. * Register a function that will be executed after the physics step
  22685. * @param func The function to execute after physics step
  22686. */
  22687. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22688. /**
  22689. * Unregisters a function that will be executed after the physics step
  22690. * @param func The function to execute after physics step
  22691. */
  22692. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  22693. /**
  22694. * register a function that will be executed when this impostor collides against a different body
  22695. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  22696. * @param func Callback that is executed on collision
  22697. */
  22698. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  22699. /**
  22700. * Unregisters the physics imposter on contact
  22701. * @param collideAgainst The physics object to collide against
  22702. * @param func Callback to execute on collision
  22703. */
  22704. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  22705. private _tmpQuat;
  22706. private _tmpQuat2;
  22707. /**
  22708. * Get the parent rotation
  22709. * @returns The parent rotation
  22710. */
  22711. getParentsRotation(): Quaternion;
  22712. /**
  22713. * this function is executed by the physics engine.
  22714. */
  22715. beforeStep: () => void;
  22716. /**
  22717. * this function is executed by the physics engine
  22718. */
  22719. afterStep: () => void;
  22720. /**
  22721. * Legacy collision detection event support
  22722. */
  22723. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  22724. /**
  22725. * event and body object due to cannon's event-based architecture.
  22726. */
  22727. onCollide: (e: {
  22728. body: any;
  22729. }) => void;
  22730. /**
  22731. * Apply a force
  22732. * @param force The force to apply
  22733. * @param contactPoint The contact point for the force
  22734. * @returns The physics imposter
  22735. */
  22736. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22737. /**
  22738. * Apply an impulse
  22739. * @param force The impulse force
  22740. * @param contactPoint The contact point for the impulse force
  22741. * @returns The physics imposter
  22742. */
  22743. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  22744. /**
  22745. * A help function to create a joint
  22746. * @param otherImpostor A physics imposter used to create a joint
  22747. * @param jointType The type of joint
  22748. * @param jointData The data for the joint
  22749. * @returns The physics imposter
  22750. */
  22751. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  22752. /**
  22753. * Add a joint to this impostor with a different impostor
  22754. * @param otherImpostor A physics imposter used to add a joint
  22755. * @param joint The joint to add
  22756. * @returns The physics imposter
  22757. */
  22758. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  22759. /**
  22760. * Add an anchor to a cloth impostor
  22761. * @param otherImpostor rigid impostor to anchor to
  22762. * @param width ratio across width from 0 to 1
  22763. * @param height ratio up height from 0 to 1
  22764. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  22765. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  22766. * @returns impostor the soft imposter
  22767. */
  22768. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22769. /**
  22770. * Add a hook to a rope impostor
  22771. * @param otherImpostor rigid impostor to anchor to
  22772. * @param length ratio across rope from 0 to 1
  22773. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  22774. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  22775. * @returns impostor the rope imposter
  22776. */
  22777. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  22778. /**
  22779. * Will keep this body still, in a sleep mode.
  22780. * @returns the physics imposter
  22781. */
  22782. sleep(): PhysicsImpostor;
  22783. /**
  22784. * Wake the body up.
  22785. * @returns The physics imposter
  22786. */
  22787. wakeUp(): PhysicsImpostor;
  22788. /**
  22789. * Clones the physics imposter
  22790. * @param newObject The physics imposter clones to this physics-enabled object
  22791. * @returns A nullable physics imposter
  22792. */
  22793. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  22794. /**
  22795. * Disposes the physics imposter
  22796. */
  22797. dispose(): void;
  22798. /**
  22799. * Sets the delta position
  22800. * @param position The delta position amount
  22801. */
  22802. setDeltaPosition(position: Vector3): void;
  22803. /**
  22804. * Sets the delta rotation
  22805. * @param rotation The delta rotation amount
  22806. */
  22807. setDeltaRotation(rotation: Quaternion): void;
  22808. /**
  22809. * Gets the box size of the physics imposter and stores the result in the input parameter
  22810. * @param result Stores the box size
  22811. * @returns The physics imposter
  22812. */
  22813. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  22814. /**
  22815. * Gets the radius of the physics imposter
  22816. * @returns Radius of the physics imposter
  22817. */
  22818. getRadius(): number;
  22819. /**
  22820. * Sync a bone with this impostor
  22821. * @param bone The bone to sync to the impostor.
  22822. * @param boneMesh The mesh that the bone is influencing.
  22823. * @param jointPivot The pivot of the joint / bone in local space.
  22824. * @param distToJoint Optional distance from the impostor to the joint.
  22825. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22826. */
  22827. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  22828. /**
  22829. * Sync impostor to a bone
  22830. * @param bone The bone that the impostor will be synced to.
  22831. * @param boneMesh The mesh that the bone is influencing.
  22832. * @param jointPivot The pivot of the joint / bone in local space.
  22833. * @param distToJoint Optional distance from the impostor to the joint.
  22834. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  22835. * @param boneAxis Optional vector3 axis the bone is aligned with
  22836. */
  22837. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  22838. /**
  22839. * No-Imposter type
  22840. */
  22841. static NoImpostor: number;
  22842. /**
  22843. * Sphere-Imposter type
  22844. */
  22845. static SphereImpostor: number;
  22846. /**
  22847. * Box-Imposter type
  22848. */
  22849. static BoxImpostor: number;
  22850. /**
  22851. * Plane-Imposter type
  22852. */
  22853. static PlaneImpostor: number;
  22854. /**
  22855. * Mesh-imposter type
  22856. */
  22857. static MeshImpostor: number;
  22858. /**
  22859. * Capsule-Impostor type (Ammo.js plugin only)
  22860. */
  22861. static CapsuleImpostor: number;
  22862. /**
  22863. * Cylinder-Imposter type
  22864. */
  22865. static CylinderImpostor: number;
  22866. /**
  22867. * Particle-Imposter type
  22868. */
  22869. static ParticleImpostor: number;
  22870. /**
  22871. * Heightmap-Imposter type
  22872. */
  22873. static HeightmapImpostor: number;
  22874. /**
  22875. * ConvexHull-Impostor type (Ammo.js plugin only)
  22876. */
  22877. static ConvexHullImpostor: number;
  22878. /**
  22879. * Rope-Imposter type
  22880. */
  22881. static RopeImpostor: number;
  22882. /**
  22883. * Cloth-Imposter type
  22884. */
  22885. static ClothImpostor: number;
  22886. /**
  22887. * Softbody-Imposter type
  22888. */
  22889. static SoftbodyImpostor: number;
  22890. }
  22891. }
  22892. declare module BABYLON {
  22893. /**
  22894. * @hidden
  22895. **/
  22896. export class _CreationDataStorage {
  22897. closePath?: boolean;
  22898. closeArray?: boolean;
  22899. idx: number[];
  22900. dashSize: number;
  22901. gapSize: number;
  22902. path3D: Path3D;
  22903. pathArray: Vector3[][];
  22904. arc: number;
  22905. radius: number;
  22906. cap: number;
  22907. tessellation: number;
  22908. }
  22909. /**
  22910. * @hidden
  22911. **/ private class _InstanceDataStorage {
  22912. visibleInstances: any;
  22913. batchCache: _InstancesBatch;
  22914. instancesBufferSize: number;
  22915. instancesBuffer: Nullable<Buffer>;
  22916. instancesData: Float32Array;
  22917. overridenInstanceCount: number;
  22918. isFrozen: boolean;
  22919. previousBatch: Nullable<_InstancesBatch>;
  22920. hardwareInstancedRendering: boolean;
  22921. sideOrientation: number;
  22922. }
  22923. /**
  22924. * @hidden
  22925. **/
  22926. export class _InstancesBatch {
  22927. mustReturn: boolean;
  22928. visibleInstances: Nullable<InstancedMesh[]>[];
  22929. renderSelf: boolean[];
  22930. hardwareInstancedRendering: boolean[];
  22931. }
  22932. /**
  22933. * Class used to represent renderable models
  22934. */
  22935. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  22936. /**
  22937. * Mesh side orientation : usually the external or front surface
  22938. */
  22939. static readonly FRONTSIDE: number;
  22940. /**
  22941. * Mesh side orientation : usually the internal or back surface
  22942. */
  22943. static readonly BACKSIDE: number;
  22944. /**
  22945. * Mesh side orientation : both internal and external or front and back surfaces
  22946. */
  22947. static readonly DOUBLESIDE: number;
  22948. /**
  22949. * Mesh side orientation : by default, `FRONTSIDE`
  22950. */
  22951. static readonly DEFAULTSIDE: number;
  22952. /**
  22953. * Mesh cap setting : no cap
  22954. */
  22955. static readonly NO_CAP: number;
  22956. /**
  22957. * Mesh cap setting : one cap at the beginning of the mesh
  22958. */
  22959. static readonly CAP_START: number;
  22960. /**
  22961. * Mesh cap setting : one cap at the end of the mesh
  22962. */
  22963. static readonly CAP_END: number;
  22964. /**
  22965. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  22966. */
  22967. static readonly CAP_ALL: number;
  22968. /**
  22969. * Mesh pattern setting : no flip or rotate
  22970. */
  22971. static readonly NO_FLIP: number;
  22972. /**
  22973. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  22974. */
  22975. static readonly FLIP_TILE: number;
  22976. /**
  22977. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  22978. */
  22979. static readonly ROTATE_TILE: number;
  22980. /**
  22981. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  22982. */
  22983. static readonly FLIP_ROW: number;
  22984. /**
  22985. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  22986. */
  22987. static readonly ROTATE_ROW: number;
  22988. /**
  22989. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  22990. */
  22991. static readonly FLIP_N_ROTATE_TILE: number;
  22992. /**
  22993. * Mesh pattern setting : rotate pattern and rotate
  22994. */
  22995. static readonly FLIP_N_ROTATE_ROW: number;
  22996. /**
  22997. * Mesh tile positioning : part tiles same on left/right or top/bottom
  22998. */
  22999. static readonly CENTER: number;
  23000. /**
  23001. * Mesh tile positioning : part tiles on left
  23002. */
  23003. static readonly LEFT: number;
  23004. /**
  23005. * Mesh tile positioning : part tiles on right
  23006. */
  23007. static readonly RIGHT: number;
  23008. /**
  23009. * Mesh tile positioning : part tiles on top
  23010. */
  23011. static readonly TOP: number;
  23012. /**
  23013. * Mesh tile positioning : part tiles on bottom
  23014. */
  23015. static readonly BOTTOM: number;
  23016. /**
  23017. * Gets the default side orientation.
  23018. * @param orientation the orientation to value to attempt to get
  23019. * @returns the default orientation
  23020. * @hidden
  23021. */ private static _GetDefaultSideOrientation(orientation?: number): number;
  23022. private _internalMeshDataInfo;
  23023. /**
  23024. * An event triggered before rendering the mesh
  23025. */
  23026. readonly onBeforeRenderObservable: Observable<Mesh>;
  23027. /**
  23028. * An event triggered before binding the mesh
  23029. */
  23030. readonly onBeforeBindObservable: Observable<Mesh>;
  23031. /**
  23032. * An event triggered after rendering the mesh
  23033. */
  23034. readonly onAfterRenderObservable: Observable<Mesh>;
  23035. /**
  23036. * An event triggered before drawing the mesh
  23037. */
  23038. readonly onBeforeDrawObservable: Observable<Mesh>;
  23039. private _onBeforeDrawObserver;
  23040. /**
  23041. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  23042. */
  23043. onBeforeDraw: () => void;
  23044. readonly hasInstances: boolean;
  23045. /**
  23046. * Gets the delay loading state of the mesh (when delay loading is turned on)
  23047. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  23048. */
  23049. delayLoadState: number;
  23050. /**
  23051. * Gets the list of instances created from this mesh
  23052. * it is not supposed to be modified manually.
  23053. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  23054. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23055. */
  23056. instances: InstancedMesh[];
  23057. /**
  23058. * Gets the file containing delay loading data for this mesh
  23059. */
  23060. delayLoadingFile: string;
  23061. /** @hidden */ private _binaryInfo: any;
  23062. /**
  23063. * User defined function used to change how LOD level selection is done
  23064. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  23065. */
  23066. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  23067. /**
  23068. * Gets or sets the morph target manager
  23069. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  23070. */
  23071. morphTargetManager: Nullable<MorphTargetManager>;
  23072. /** @hidden */ private _creationDataStorage: Nullable<_CreationDataStorage>;
  23073. /** @hidden */ private _geometry: Nullable<Geometry>;
  23074. /** @hidden */ private _delayInfo: Array<string>;
  23075. /** @hidden */ private _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  23076. /** @hidden */ private _instanceDataStorage: _InstanceDataStorage;
  23077. private _effectiveMaterial;
  23078. /** @hidden */ private _shouldGenerateFlatShading: boolean;
  23079. /** @hidden */ private _originalBuilderSideOrientation: number;
  23080. /**
  23081. * Use this property to change the original side orientation defined at construction time
  23082. */
  23083. overrideMaterialSideOrientation: Nullable<number>;
  23084. /**
  23085. * Gets the source mesh (the one used to clone this one from)
  23086. */
  23087. readonly source: Nullable<Mesh>;
  23088. /**
  23089. * Gets or sets a boolean indicating that this mesh does not use index buffer
  23090. */
  23091. isUnIndexed: boolean;
  23092. /**
  23093. * @constructor
  23094. * @param name The value used by scene.getMeshByName() to do a lookup.
  23095. * @param scene The scene to add this mesh to.
  23096. * @param parent The parent of this mesh, if it has one
  23097. * @param source An optional Mesh from which geometry is shared, cloned.
  23098. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  23099. * When false, achieved by calling a clone(), also passing False.
  23100. * This will make creation of children, recursive.
  23101. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  23102. */
  23103. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  23104. /**
  23105. * Gets the class name
  23106. * @returns the string "Mesh".
  23107. */
  23108. getClassName(): string;
  23109. /** @hidden */ protected readonly _isMesh: boolean;
  23110. /**
  23111. * Returns a description of this mesh
  23112. * @param fullDetails define if full details about this mesh must be used
  23113. * @returns a descriptive string representing this mesh
  23114. */
  23115. toString(fullDetails?: boolean): string;
  23116. /** @hidden */ private _unBindEffect(): void;
  23117. /**
  23118. * Gets a boolean indicating if this mesh has LOD
  23119. */
  23120. readonly hasLODLevels: boolean;
  23121. /**
  23122. * Gets the list of MeshLODLevel associated with the current mesh
  23123. * @returns an array of MeshLODLevel
  23124. */
  23125. getLODLevels(): MeshLODLevel[];
  23126. private _sortLODLevels;
  23127. /**
  23128. * Add a mesh as LOD level triggered at the given distance.
  23129. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23130. * @param distance The distance from the center of the object to show this level
  23131. * @param mesh The mesh to be added as LOD level (can be null)
  23132. * @return This mesh (for chaining)
  23133. */
  23134. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  23135. /**
  23136. * Returns the LOD level mesh at the passed distance or null if not found.
  23137. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23138. * @param distance The distance from the center of the object to show this level
  23139. * @returns a Mesh or `null`
  23140. */
  23141. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  23142. /**
  23143. * Remove a mesh from the LOD array
  23144. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23145. * @param mesh defines the mesh to be removed
  23146. * @return This mesh (for chaining)
  23147. */
  23148. removeLODLevel(mesh: Mesh): Mesh;
  23149. /**
  23150. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  23151. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  23152. * @param camera defines the camera to use to compute distance
  23153. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  23154. * @return This mesh (for chaining)
  23155. */
  23156. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  23157. /**
  23158. * Gets the mesh internal Geometry object
  23159. */
  23160. readonly geometry: Nullable<Geometry>;
  23161. /**
  23162. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  23163. * @returns the total number of vertices
  23164. */
  23165. getTotalVertices(): number;
  23166. /**
  23167. * Returns the content of an associated vertex buffer
  23168. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23169. * - VertexBuffer.PositionKind
  23170. * - VertexBuffer.UVKind
  23171. * - VertexBuffer.UV2Kind
  23172. * - VertexBuffer.UV3Kind
  23173. * - VertexBuffer.UV4Kind
  23174. * - VertexBuffer.UV5Kind
  23175. * - VertexBuffer.UV6Kind
  23176. * - VertexBuffer.ColorKind
  23177. * - VertexBuffer.MatricesIndicesKind
  23178. * - VertexBuffer.MatricesIndicesExtraKind
  23179. * - VertexBuffer.MatricesWeightsKind
  23180. * - VertexBuffer.MatricesWeightsExtraKind
  23181. * @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
  23182. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  23183. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  23184. */
  23185. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23186. /**
  23187. * Returns the mesh VertexBuffer object from the requested `kind`
  23188. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23189. * - VertexBuffer.PositionKind
  23190. * - VertexBuffer.NormalKind
  23191. * - VertexBuffer.UVKind
  23192. * - VertexBuffer.UV2Kind
  23193. * - VertexBuffer.UV3Kind
  23194. * - VertexBuffer.UV4Kind
  23195. * - VertexBuffer.UV5Kind
  23196. * - VertexBuffer.UV6Kind
  23197. * - VertexBuffer.ColorKind
  23198. * - VertexBuffer.MatricesIndicesKind
  23199. * - VertexBuffer.MatricesIndicesExtraKind
  23200. * - VertexBuffer.MatricesWeightsKind
  23201. * - VertexBuffer.MatricesWeightsExtraKind
  23202. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  23203. */
  23204. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23205. /**
  23206. * Tests if a specific vertex buffer is associated with this mesh
  23207. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23208. * - VertexBuffer.PositionKind
  23209. * - VertexBuffer.NormalKind
  23210. * - VertexBuffer.UVKind
  23211. * - VertexBuffer.UV2Kind
  23212. * - VertexBuffer.UV3Kind
  23213. * - VertexBuffer.UV4Kind
  23214. * - VertexBuffer.UV5Kind
  23215. * - VertexBuffer.UV6Kind
  23216. * - VertexBuffer.ColorKind
  23217. * - VertexBuffer.MatricesIndicesKind
  23218. * - VertexBuffer.MatricesIndicesExtraKind
  23219. * - VertexBuffer.MatricesWeightsKind
  23220. * - VertexBuffer.MatricesWeightsExtraKind
  23221. * @returns a boolean
  23222. */
  23223. isVerticesDataPresent(kind: string): boolean;
  23224. /**
  23225. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  23226. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  23227. * - VertexBuffer.PositionKind
  23228. * - VertexBuffer.UVKind
  23229. * - VertexBuffer.UV2Kind
  23230. * - VertexBuffer.UV3Kind
  23231. * - VertexBuffer.UV4Kind
  23232. * - VertexBuffer.UV5Kind
  23233. * - VertexBuffer.UV6Kind
  23234. * - VertexBuffer.ColorKind
  23235. * - VertexBuffer.MatricesIndicesKind
  23236. * - VertexBuffer.MatricesIndicesExtraKind
  23237. * - VertexBuffer.MatricesWeightsKind
  23238. * - VertexBuffer.MatricesWeightsExtraKind
  23239. * @returns a boolean
  23240. */
  23241. isVertexBufferUpdatable(kind: string): boolean;
  23242. /**
  23243. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  23244. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  23245. * - VertexBuffer.PositionKind
  23246. * - VertexBuffer.NormalKind
  23247. * - VertexBuffer.UVKind
  23248. * - VertexBuffer.UV2Kind
  23249. * - VertexBuffer.UV3Kind
  23250. * - VertexBuffer.UV4Kind
  23251. * - VertexBuffer.UV5Kind
  23252. * - VertexBuffer.UV6Kind
  23253. * - VertexBuffer.ColorKind
  23254. * - VertexBuffer.MatricesIndicesKind
  23255. * - VertexBuffer.MatricesIndicesExtraKind
  23256. * - VertexBuffer.MatricesWeightsKind
  23257. * - VertexBuffer.MatricesWeightsExtraKind
  23258. * @returns an array of strings
  23259. */
  23260. getVerticesDataKinds(): string[];
  23261. /**
  23262. * Returns a positive integer : the total number of indices in this mesh geometry.
  23263. * @returns the numner of indices or zero if the mesh has no geometry.
  23264. */
  23265. getTotalIndices(): number;
  23266. /**
  23267. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23268. * @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.
  23269. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23270. * @returns the indices array or an empty array if the mesh has no geometry
  23271. */
  23272. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23273. readonly isBlocked: boolean;
  23274. /**
  23275. * Determine if the current mesh is ready to be rendered
  23276. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  23277. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  23278. * @returns true if all associated assets are ready (material, textures, shaders)
  23279. */
  23280. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  23281. /**
  23282. * 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.
  23283. */
  23284. readonly areNormalsFrozen: boolean;
  23285. /**
  23286. * 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.
  23287. * @returns the current mesh
  23288. */
  23289. freezeNormals(): Mesh;
  23290. /**
  23291. * 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
  23292. * @returns the current mesh
  23293. */
  23294. unfreezeNormals(): Mesh;
  23295. /**
  23296. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  23297. */
  23298. overridenInstanceCount: number;
  23299. /** @hidden */ private _preActivate(): Mesh;
  23300. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): Mesh;
  23301. /** @hidden */ private _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  23302. /**
  23303. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  23304. * This means the mesh underlying bounding box and sphere are recomputed.
  23305. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  23306. * @returns the current mesh
  23307. */
  23308. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  23309. /** @hidden */ private _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  23310. /**
  23311. * This function will subdivide the mesh into multiple submeshes
  23312. * @param count defines the expected number of submeshes
  23313. */
  23314. subdivide(count: number): void;
  23315. /**
  23316. * Copy a FloatArray into a specific associated vertex buffer
  23317. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23318. * - VertexBuffer.PositionKind
  23319. * - VertexBuffer.UVKind
  23320. * - VertexBuffer.UV2Kind
  23321. * - VertexBuffer.UV3Kind
  23322. * - VertexBuffer.UV4Kind
  23323. * - VertexBuffer.UV5Kind
  23324. * - VertexBuffer.UV6Kind
  23325. * - VertexBuffer.ColorKind
  23326. * - VertexBuffer.MatricesIndicesKind
  23327. * - VertexBuffer.MatricesIndicesExtraKind
  23328. * - VertexBuffer.MatricesWeightsKind
  23329. * - VertexBuffer.MatricesWeightsExtraKind
  23330. * @param data defines the data source
  23331. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23332. * @param stride defines the data stride size (can be null)
  23333. * @returns the current mesh
  23334. */
  23335. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  23336. /**
  23337. * Flags an associated vertex buffer as updatable
  23338. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  23339. * - VertexBuffer.PositionKind
  23340. * - VertexBuffer.UVKind
  23341. * - VertexBuffer.UV2Kind
  23342. * - VertexBuffer.UV3Kind
  23343. * - VertexBuffer.UV4Kind
  23344. * - VertexBuffer.UV5Kind
  23345. * - VertexBuffer.UV6Kind
  23346. * - VertexBuffer.ColorKind
  23347. * - VertexBuffer.MatricesIndicesKind
  23348. * - VertexBuffer.MatricesIndicesExtraKind
  23349. * - VertexBuffer.MatricesWeightsKind
  23350. * - VertexBuffer.MatricesWeightsExtraKind
  23351. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  23352. */
  23353. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  23354. /**
  23355. * Sets the mesh global Vertex Buffer
  23356. * @param buffer defines the buffer to use
  23357. * @returns the current mesh
  23358. */
  23359. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  23360. /**
  23361. * Update a specific associated vertex buffer
  23362. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23363. * - VertexBuffer.PositionKind
  23364. * - VertexBuffer.UVKind
  23365. * - VertexBuffer.UV2Kind
  23366. * - VertexBuffer.UV3Kind
  23367. * - VertexBuffer.UV4Kind
  23368. * - VertexBuffer.UV5Kind
  23369. * - VertexBuffer.UV6Kind
  23370. * - VertexBuffer.ColorKind
  23371. * - VertexBuffer.MatricesIndicesKind
  23372. * - VertexBuffer.MatricesIndicesExtraKind
  23373. * - VertexBuffer.MatricesWeightsKind
  23374. * - VertexBuffer.MatricesWeightsExtraKind
  23375. * @param data defines the data source
  23376. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23377. * @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)
  23378. * @returns the current mesh
  23379. */
  23380. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  23381. /**
  23382. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  23383. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  23384. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  23385. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  23386. * @returns the current mesh
  23387. */
  23388. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  23389. /**
  23390. * Creates a un-shared specific occurence of the geometry for the mesh.
  23391. * @returns the current mesh
  23392. */
  23393. makeGeometryUnique(): Mesh;
  23394. /**
  23395. * Set the index buffer of this mesh
  23396. * @param indices defines the source data
  23397. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  23398. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  23399. * @returns the current mesh
  23400. */
  23401. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  23402. /**
  23403. * Update the current index buffer
  23404. * @param indices defines the source data
  23405. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  23406. * @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)
  23407. * @returns the current mesh
  23408. */
  23409. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  23410. /**
  23411. * Invert the geometry to move from a right handed system to a left handed one.
  23412. * @returns the current mesh
  23413. */
  23414. toLeftHanded(): Mesh;
  23415. /** @hidden */ private _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  23416. /** @hidden */ private _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  23417. /**
  23418. * Registers for this mesh a javascript function called just before the rendering process
  23419. * @param func defines the function to call before rendering this mesh
  23420. * @returns the current mesh
  23421. */
  23422. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23423. /**
  23424. * Disposes a previously registered javascript function called before the rendering
  23425. * @param func defines the function to remove
  23426. * @returns the current mesh
  23427. */
  23428. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  23429. /**
  23430. * Registers for this mesh a javascript function called just after the rendering is complete
  23431. * @param func defines the function to call after rendering this mesh
  23432. * @returns the current mesh
  23433. */
  23434. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23435. /**
  23436. * Disposes a previously registered javascript function called after the rendering.
  23437. * @param func defines the function to remove
  23438. * @returns the current mesh
  23439. */
  23440. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  23441. /** @hidden */ private _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  23442. /** @hidden */ private _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  23443. /** @hidden */ private _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  23444. /** @hidden */ private _rebuild(): void;
  23445. /** @hidden */ private _freeze(): void;
  23446. /** @hidden */ private _unFreeze(): void;
  23447. /**
  23448. * 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
  23449. * @param subMesh defines the subMesh to render
  23450. * @param enableAlphaMode defines if alpha mode can be changed
  23451. * @returns the current mesh
  23452. */
  23453. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  23454. private _onBeforeDraw;
  23455. /**
  23456. * Renormalize the mesh and patch it up if there are no weights
  23457. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  23458. * However in the case of zero weights then we set just a single influence to 1.
  23459. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  23460. */
  23461. cleanMatrixWeights(): void;
  23462. private normalizeSkinFourWeights;
  23463. private normalizeSkinWeightsAndExtra;
  23464. /**
  23465. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  23466. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  23467. * the user know there was an issue with importing the mesh
  23468. * @returns a validation object with skinned, valid and report string
  23469. */
  23470. validateSkinning(): {
  23471. skinned: boolean;
  23472. valid: boolean;
  23473. report: string;
  23474. };
  23475. /** @hidden */ private _checkDelayState(): Mesh;
  23476. private _queueLoad;
  23477. /**
  23478. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  23479. * A mesh is in the frustum if its bounding box intersects the frustum
  23480. * @param frustumPlanes defines the frustum to test
  23481. * @returns true if the mesh is in the frustum planes
  23482. */
  23483. isInFrustum(frustumPlanes: Plane[]): boolean;
  23484. /**
  23485. * Sets the mesh material by the material or multiMaterial `id` property
  23486. * @param id is a string identifying the material or the multiMaterial
  23487. * @returns the current mesh
  23488. */
  23489. setMaterialByID(id: string): Mesh;
  23490. /**
  23491. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  23492. * @returns an array of IAnimatable
  23493. */
  23494. getAnimatables(): IAnimatable[];
  23495. /**
  23496. * Modifies the mesh geometry according to the passed transformation matrix.
  23497. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  23498. * The mesh normals are modified using the same transformation.
  23499. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23500. * @param transform defines the transform matrix to use
  23501. * @see http://doc.babylonjs.com/resources/baking_transformations
  23502. * @returns the current mesh
  23503. */
  23504. bakeTransformIntoVertices(transform: Matrix): Mesh;
  23505. /**
  23506. * Modifies the mesh geometry according to its own current World Matrix.
  23507. * The mesh World Matrix is then reset.
  23508. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  23509. * Note that, under the hood, this method sets a new VertexBuffer each call.
  23510. * @see http://doc.babylonjs.com/resources/baking_transformations
  23511. * @returns the current mesh
  23512. */
  23513. bakeCurrentTransformIntoVertices(): Mesh;
  23514. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  23515. /** @hidden */ private _resetPointsArrayCache(): Mesh;
  23516. /** @hidden */ private _generatePointsArray(): boolean;
  23517. /**
  23518. * Returns a new Mesh object generated from the current mesh properties.
  23519. * This method must not get confused with createInstance()
  23520. * @param name is a string, the name given to the new mesh
  23521. * @param newParent can be any Node object (default `null`)
  23522. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  23523. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  23524. * @returns a new mesh
  23525. */
  23526. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  23527. /**
  23528. * Releases resources associated with this mesh.
  23529. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  23530. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  23531. */
  23532. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  23533. /**
  23534. * Modifies the mesh geometry according to a displacement map.
  23535. * 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.
  23536. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23537. * @param url is a string, the URL from the image file is to be downloaded.
  23538. * @param minHeight is the lower limit of the displacement.
  23539. * @param maxHeight is the upper limit of the displacement.
  23540. * @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.
  23541. * @param uvOffset is an optional vector2 used to offset UV.
  23542. * @param uvScale is an optional vector2 used to scale UV.
  23543. * @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.
  23544. * @returns the Mesh.
  23545. */
  23546. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23547. /**
  23548. * Modifies the mesh geometry according to a displacementMap buffer.
  23549. * 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.
  23550. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  23551. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  23552. * @param heightMapWidth is the width of the buffer image.
  23553. * @param heightMapHeight is the height of the buffer image.
  23554. * @param minHeight is the lower limit of the displacement.
  23555. * @param maxHeight is the upper limit of the displacement.
  23556. * @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.
  23557. * @param uvOffset is an optional vector2 used to offset UV.
  23558. * @param uvScale is an optional vector2 used to scale UV.
  23559. * @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.
  23560. * @returns the Mesh.
  23561. */
  23562. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  23563. /**
  23564. * Modify the mesh to get a flat shading rendering.
  23565. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  23566. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  23567. * @returns current mesh
  23568. */
  23569. convertToFlatShadedMesh(): Mesh;
  23570. /**
  23571. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  23572. * In other words, more vertices, no more indices and a single bigger VBO.
  23573. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  23574. * @returns current mesh
  23575. */
  23576. convertToUnIndexedMesh(): Mesh;
  23577. /**
  23578. * Inverses facet orientations.
  23579. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23580. * @param flipNormals will also inverts the normals
  23581. * @returns current mesh
  23582. */
  23583. flipFaces(flipNormals?: boolean): Mesh;
  23584. /**
  23585. * Increase the number of facets and hence vertices in a mesh
  23586. * Vertex normals are interpolated from existing vertex normals
  23587. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23588. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  23589. */
  23590. increaseVertices(numberPerEdge: number): void;
  23591. /**
  23592. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  23593. * This will undo any application of covertToFlatShadedMesh
  23594. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  23595. */
  23596. forceSharedVertices(): void;
  23597. /** @hidden */ private static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  23598. /** @hidden */ private static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  23599. /**
  23600. * Creates a new InstancedMesh object from the mesh model.
  23601. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  23602. * @param name defines the name of the new instance
  23603. * @returns a new InstancedMesh
  23604. */
  23605. createInstance(name: string): InstancedMesh;
  23606. /**
  23607. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  23608. * After this call, all the mesh instances have the same submeshes than the current mesh.
  23609. * @returns the current mesh
  23610. */
  23611. synchronizeInstances(): Mesh;
  23612. /**
  23613. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  23614. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  23615. * This should be used together with the simplification to avoid disappearing triangles.
  23616. * @param successCallback an optional success callback to be called after the optimization finished.
  23617. * @returns the current mesh
  23618. */
  23619. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  23620. /**
  23621. * Serialize current mesh
  23622. * @param serializationObject defines the object which will receive the serialization data
  23623. */
  23624. serialize(serializationObject: any): void;
  23625. /** @hidden */ private _syncGeometryWithMorphTargetManager(): void;
  23626. /** @hidden */ private static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  23627. /**
  23628. * Returns a new Mesh object parsed from the source provided.
  23629. * @param parsedMesh is the source
  23630. * @param scene defines the hosting scene
  23631. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  23632. * @returns a new Mesh
  23633. */
  23634. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  23635. /**
  23636. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  23637. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23638. * @param name defines the name of the mesh to create
  23639. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  23640. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  23641. * @param closePath creates a seam between the first and the last points of each path of the path array
  23642. * @param offset is taken in account only if the `pathArray` is containing a single path
  23643. * @param scene defines the hosting scene
  23644. * @param updatable defines if the mesh must be flagged as updatable
  23645. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23646. * @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)
  23647. * @returns a new Mesh
  23648. */
  23649. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23650. /**
  23651. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  23652. * @param name defines the name of the mesh to create
  23653. * @param radius sets the radius size (float) of the polygon (default 0.5)
  23654. * @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
  23655. * @param scene defines the hosting scene
  23656. * @param updatable defines if the mesh must be flagged as updatable
  23657. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23658. * @returns a new Mesh
  23659. */
  23660. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23661. /**
  23662. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  23663. * @param name defines the name of the mesh to create
  23664. * @param size sets the size (float) of each box side (default 1)
  23665. * @param scene defines the hosting scene
  23666. * @param updatable defines if the mesh must be flagged as updatable
  23667. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23668. * @returns a new Mesh
  23669. */
  23670. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  23671. /**
  23672. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  23673. * @param name defines the name of the mesh to create
  23674. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23675. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23676. * @param scene defines the hosting scene
  23677. * @param updatable defines if the mesh must be flagged as updatable
  23678. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23679. * @returns a new Mesh
  23680. */
  23681. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23682. /**
  23683. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  23684. * @param name defines the name of the mesh to create
  23685. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  23686. * @param diameter sets the diameter size (float) of the sphere (default 1)
  23687. * @param scene defines the hosting scene
  23688. * @returns a new Mesh
  23689. */
  23690. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  23691. /**
  23692. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  23693. * @param name defines the name of the mesh to create
  23694. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  23695. * @param diameterTop set the top cap diameter (floats, default 1)
  23696. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  23697. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  23698. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  23699. * @param scene defines the hosting scene
  23700. * @param updatable defines if the mesh must be flagged as updatable
  23701. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23702. * @returns a new Mesh
  23703. */
  23704. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  23705. /**
  23706. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  23707. * @param name defines the name of the mesh to create
  23708. * @param diameter sets the diameter size (float) of the torus (default 1)
  23709. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  23710. * @param tessellation sets the number of torus sides (postive integer, default 16)
  23711. * @param scene defines the hosting scene
  23712. * @param updatable defines if the mesh must be flagged as updatable
  23713. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23714. * @returns a new Mesh
  23715. */
  23716. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23717. /**
  23718. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  23719. * @param name defines the name of the mesh to create
  23720. * @param radius sets the global radius size (float) of the torus knot (default 2)
  23721. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  23722. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  23723. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  23724. * @param p the number of windings on X axis (positive integers, default 2)
  23725. * @param q the number of windings on Y axis (positive integers, default 3)
  23726. * @param scene defines the hosting scene
  23727. * @param updatable defines if the mesh must be flagged as updatable
  23728. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23729. * @returns a new Mesh
  23730. */
  23731. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23732. /**
  23733. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  23734. * @param name defines the name of the mesh to create
  23735. * @param points is an array successive Vector3
  23736. * @param scene defines the hosting scene
  23737. * @param updatable defines if the mesh must be flagged as updatable
  23738. * @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).
  23739. * @returns a new Mesh
  23740. */
  23741. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  23742. /**
  23743. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  23744. * @param name defines the name of the mesh to create
  23745. * @param points is an array successive Vector3
  23746. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  23747. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  23748. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  23749. * @param scene defines the hosting scene
  23750. * @param updatable defines if the mesh must be flagged as updatable
  23751. * @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)
  23752. * @returns a new Mesh
  23753. */
  23754. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  23755. /**
  23756. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  23757. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  23758. * 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.
  23759. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23760. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  23761. * Remember you can only change the shape positions, not their number when updating a polygon.
  23762. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  23763. * @param name defines the name of the mesh to create
  23764. * @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
  23765. * @param scene defines the hosting scene
  23766. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23767. * @param updatable defines if the mesh must be flagged as updatable
  23768. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23769. * @param earcutInjection can be used to inject your own earcut reference
  23770. * @returns a new Mesh
  23771. */
  23772. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23773. /**
  23774. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  23775. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  23776. * @param name defines the name of the mesh to create
  23777. * @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
  23778. * @param depth defines the height of extrusion
  23779. * @param scene defines the hosting scene
  23780. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  23781. * @param updatable defines if the mesh must be flagged as updatable
  23782. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23783. * @param earcutInjection can be used to inject your own earcut reference
  23784. * @returns a new Mesh
  23785. */
  23786. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  23787. /**
  23788. * Creates an extruded shape mesh.
  23789. * 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
  23790. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23791. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23792. * @param name defines the name of the mesh to create
  23793. * @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
  23794. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23795. * @param scale is the value to scale the shape
  23796. * @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
  23797. * @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
  23798. * @param scene defines the hosting scene
  23799. * @param updatable defines if the mesh must be flagged as updatable
  23800. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23801. * @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)
  23802. * @returns a new Mesh
  23803. */
  23804. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23805. /**
  23806. * Creates an custom extruded shape mesh.
  23807. * The custom extrusion is a parametric shape.
  23808. * It has no predefined shape. Its final shape will depend on the input parameters.
  23809. * Please consider using the same method from the MeshBuilder class instead
  23810. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  23811. * @param name defines the name of the mesh to create
  23812. * @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
  23813. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  23814. * @param scaleFunction is a custom Javascript function called on each path point
  23815. * @param rotationFunction is a custom Javascript function called on each path point
  23816. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  23817. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  23818. * @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
  23819. * @param scene defines the hosting scene
  23820. * @param updatable defines if the mesh must be flagged as updatable
  23821. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23822. * @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)
  23823. * @returns a new Mesh
  23824. */
  23825. 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;
  23826. /**
  23827. * Creates lathe mesh.
  23828. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  23829. * Please consider using the same method from the MeshBuilder class instead
  23830. * @param name defines the name of the mesh to create
  23831. * @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
  23832. * @param radius is the radius value of the lathe
  23833. * @param tessellation is the side number of the lathe.
  23834. * @param scene defines the hosting scene
  23835. * @param updatable defines if the mesh must be flagged as updatable
  23836. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23837. * @returns a new Mesh
  23838. */
  23839. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23840. /**
  23841. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  23842. * @param name defines the name of the mesh to create
  23843. * @param size sets the size (float) of both sides of the plane at once (default 1)
  23844. * @param scene defines the hosting scene
  23845. * @param updatable defines if the mesh must be flagged as updatable
  23846. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23847. * @returns a new Mesh
  23848. */
  23849. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  23850. /**
  23851. * Creates a ground mesh.
  23852. * Please consider using the same method from the MeshBuilder class instead
  23853. * @param name defines the name of the mesh to create
  23854. * @param width set the width of the ground
  23855. * @param height set the height of the ground
  23856. * @param subdivisions sets the number of subdivisions per side
  23857. * @param scene defines the hosting scene
  23858. * @param updatable defines if the mesh must be flagged as updatable
  23859. * @returns a new Mesh
  23860. */
  23861. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  23862. /**
  23863. * Creates a tiled ground mesh.
  23864. * Please consider using the same method from the MeshBuilder class instead
  23865. * @param name defines the name of the mesh to create
  23866. * @param xmin set the ground minimum X coordinate
  23867. * @param zmin set the ground minimum Y coordinate
  23868. * @param xmax set the ground maximum X coordinate
  23869. * @param zmax set the ground maximum Z coordinate
  23870. * @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
  23871. * @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
  23872. * @param scene defines the hosting scene
  23873. * @param updatable defines if the mesh must be flagged as updatable
  23874. * @returns a new Mesh
  23875. */
  23876. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  23877. w: number;
  23878. h: number;
  23879. }, precision: {
  23880. w: number;
  23881. h: number;
  23882. }, scene: Scene, updatable?: boolean): Mesh;
  23883. /**
  23884. * Creates a ground mesh from a height map.
  23885. * Please consider using the same method from the MeshBuilder class instead
  23886. * @see http://doc.babylonjs.com/babylon101/height_map
  23887. * @param name defines the name of the mesh to create
  23888. * @param url sets the URL of the height map image resource
  23889. * @param width set the ground width size
  23890. * @param height set the ground height size
  23891. * @param subdivisions sets the number of subdivision per side
  23892. * @param minHeight is the minimum altitude on the ground
  23893. * @param maxHeight is the maximum altitude on the ground
  23894. * @param scene defines the hosting scene
  23895. * @param updatable defines if the mesh must be flagged as updatable
  23896. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  23897. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  23898. * @returns a new Mesh
  23899. */
  23900. 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;
  23901. /**
  23902. * Creates a tube mesh.
  23903. * The tube is a parametric shape.
  23904. * It has no predefined shape. Its final shape will depend on the input parameters.
  23905. * Please consider using the same method from the MeshBuilder class instead
  23906. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  23907. * @param name defines the name of the mesh to create
  23908. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  23909. * @param radius sets the tube radius size
  23910. * @param tessellation is the number of sides on the tubular surface
  23911. * @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
  23912. * @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
  23913. * @param scene defines the hosting scene
  23914. * @param updatable defines if the mesh must be flagged as updatable
  23915. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  23916. * @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)
  23917. * @returns a new Mesh
  23918. */
  23919. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  23920. (i: number, distance: number): number;
  23921. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  23922. /**
  23923. * Creates a polyhedron mesh.
  23924. * Please consider using the same method from the MeshBuilder class instead.
  23925. * * 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
  23926. * * The parameter `size` (positive float, default 1) sets the polygon size
  23927. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  23928. * * 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`
  23929. * * 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
  23930. * * 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)`)
  23931. * * 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
  23932. * * 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
  23933. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23934. * * 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
  23935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23936. * @param name defines the name of the mesh to create
  23937. * @param options defines the options used to create the mesh
  23938. * @param scene defines the hosting scene
  23939. * @returns a new Mesh
  23940. */
  23941. static CreatePolyhedron(name: string, options: {
  23942. type?: number;
  23943. size?: number;
  23944. sizeX?: number;
  23945. sizeY?: number;
  23946. sizeZ?: number;
  23947. custom?: any;
  23948. faceUV?: Vector4[];
  23949. faceColors?: Color4[];
  23950. updatable?: boolean;
  23951. sideOrientation?: number;
  23952. }, scene: Scene): Mesh;
  23953. /**
  23954. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  23955. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  23956. * * 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`)
  23957. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  23958. * * 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
  23959. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23960. * * 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
  23961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  23962. * @param name defines the name of the mesh
  23963. * @param options defines the options used to create the mesh
  23964. * @param scene defines the hosting scene
  23965. * @returns a new Mesh
  23966. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  23967. */
  23968. static CreateIcoSphere(name: string, options: {
  23969. radius?: number;
  23970. flat?: boolean;
  23971. subdivisions?: number;
  23972. sideOrientation?: number;
  23973. updatable?: boolean;
  23974. }, scene: Scene): Mesh;
  23975. /**
  23976. * Creates a decal mesh.
  23977. * Please consider using the same method from the MeshBuilder class instead.
  23978. * A decal is a mesh usually applied as a model onto the surface of another mesh
  23979. * @param name defines the name of the mesh
  23980. * @param sourceMesh defines the mesh receiving the decal
  23981. * @param position sets the position of the decal in world coordinates
  23982. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  23983. * @param size sets the decal scaling
  23984. * @param angle sets the angle to rotate the decal
  23985. * @returns a new Mesh
  23986. */
  23987. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  23988. /**
  23989. * Prepare internal position array for software CPU skinning
  23990. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  23991. */
  23992. setPositionsForCPUSkinning(): Float32Array;
  23993. /**
  23994. * Prepare internal normal array for software CPU skinning
  23995. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  23996. */
  23997. setNormalsForCPUSkinning(): Float32Array;
  23998. /**
  23999. * Updates the vertex buffer by applying transformation from the bones
  24000. * @param skeleton defines the skeleton to apply to current mesh
  24001. * @returns the current mesh
  24002. */
  24003. applySkeleton(skeleton: Skeleton): Mesh;
  24004. /**
  24005. * 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
  24006. * @param meshes defines the list of meshes to scan
  24007. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  24008. */
  24009. static MinMax(meshes: AbstractMesh[]): {
  24010. min: Vector3;
  24011. max: Vector3;
  24012. };
  24013. /**
  24014. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  24015. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  24016. * @returns a vector3
  24017. */
  24018. static Center(meshesOrMinMaxVector: {
  24019. min: Vector3;
  24020. max: Vector3;
  24021. } | AbstractMesh[]): Vector3;
  24022. /**
  24023. * Merge the array of meshes into a single mesh for performance reasons.
  24024. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  24025. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  24026. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  24027. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  24028. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  24029. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  24030. * @returns a new mesh
  24031. */
  24032. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  24033. /** @hidden */
  24034. addInstance(instance: InstancedMesh): void;
  24035. /** @hidden */
  24036. removeInstance(instance: InstancedMesh): void;
  24037. }
  24038. }
  24039. declare module BABYLON {
  24040. /**
  24041. * This is the base class of all the camera used in the application.
  24042. * @see http://doc.babylonjs.com/features/cameras
  24043. */
  24044. export class Camera extends Node {
  24045. /** @hidden */ private static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  24046. /**
  24047. * This is the default projection mode used by the cameras.
  24048. * It helps recreating a feeling of perspective and better appreciate depth.
  24049. * This is the best way to simulate real life cameras.
  24050. */
  24051. static readonly PERSPECTIVE_CAMERA: number;
  24052. /**
  24053. * This helps creating camera with an orthographic mode.
  24054. * 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.
  24055. */
  24056. static readonly ORTHOGRAPHIC_CAMERA: number;
  24057. /**
  24058. * This is the default FOV mode for perspective cameras.
  24059. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  24060. */
  24061. static readonly FOVMODE_VERTICAL_FIXED: number;
  24062. /**
  24063. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  24064. */
  24065. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  24066. /**
  24067. * This specifies ther is no need for a camera rig.
  24068. * Basically only one eye is rendered corresponding to the camera.
  24069. */
  24070. static readonly RIG_MODE_NONE: number;
  24071. /**
  24072. * Simulates a camera Rig with one blue eye and one red eye.
  24073. * This can be use with 3d blue and red glasses.
  24074. */
  24075. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  24076. /**
  24077. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  24078. */
  24079. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  24080. /**
  24081. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  24082. */
  24083. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  24084. /**
  24085. * Defines that both eyes of the camera will be rendered over under each other.
  24086. */
  24087. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  24088. /**
  24089. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  24090. */
  24091. static readonly RIG_MODE_VR: number;
  24092. /**
  24093. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  24094. */
  24095. static readonly RIG_MODE_WEBVR: number;
  24096. /**
  24097. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  24098. */
  24099. static readonly RIG_MODE_CUSTOM: number;
  24100. /**
  24101. * Defines if by default attaching controls should prevent the default javascript event to continue.
  24102. */
  24103. static ForceAttachControlToAlwaysPreventDefault: boolean;
  24104. /**
  24105. * Define the input manager associated with the camera.
  24106. */
  24107. inputs: CameraInputsManager<Camera>;
  24108. /** @hidden */ private _position: Vector3;
  24109. /**
  24110. * Define the current local position of the camera in the scene
  24111. */
  24112. position: Vector3;
  24113. /**
  24114. * The vector the camera should consider as up.
  24115. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  24116. */
  24117. upVector: Vector3;
  24118. /**
  24119. * Define the current limit on the left side for an orthographic camera
  24120. * In scene unit
  24121. */
  24122. orthoLeft: Nullable<number>;
  24123. /**
  24124. * Define the current limit on the right side for an orthographic camera
  24125. * In scene unit
  24126. */
  24127. orthoRight: Nullable<number>;
  24128. /**
  24129. * Define the current limit on the bottom side for an orthographic camera
  24130. * In scene unit
  24131. */
  24132. orthoBottom: Nullable<number>;
  24133. /**
  24134. * Define the current limit on the top side for an orthographic camera
  24135. * In scene unit
  24136. */
  24137. orthoTop: Nullable<number>;
  24138. /**
  24139. * Field Of View is set in Radians. (default is 0.8)
  24140. */
  24141. fov: number;
  24142. /**
  24143. * Define the minimum distance the camera can see from.
  24144. * This is important to note that the depth buffer are not infinite and the closer it starts
  24145. * the more your scene might encounter depth fighting issue.
  24146. */
  24147. minZ: number;
  24148. /**
  24149. * Define the maximum distance the camera can see to.
  24150. * This is important to note that the depth buffer are not infinite and the further it end
  24151. * the more your scene might encounter depth fighting issue.
  24152. */
  24153. maxZ: number;
  24154. /**
  24155. * Define the default inertia of the camera.
  24156. * This helps giving a smooth feeling to the camera movement.
  24157. */
  24158. inertia: number;
  24159. /**
  24160. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  24161. */
  24162. mode: number;
  24163. /**
  24164. * Define wether the camera is intermediate.
  24165. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  24166. */
  24167. isIntermediate: boolean;
  24168. /**
  24169. * Define the viewport of the camera.
  24170. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  24171. */
  24172. viewport: Viewport;
  24173. /**
  24174. * Restricts the camera to viewing objects with the same layerMask.
  24175. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  24176. */
  24177. layerMask: number;
  24178. /**
  24179. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  24180. */
  24181. fovMode: number;
  24182. /**
  24183. * Rig mode of the camera.
  24184. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  24185. * This is normally controlled byt the camera themselves as internal use.
  24186. */
  24187. cameraRigMode: number;
  24188. /**
  24189. * Defines the distance between both "eyes" in case of a RIG
  24190. */
  24191. interaxialDistance: number;
  24192. /**
  24193. * Defines if stereoscopic rendering is done side by side or over under.
  24194. */
  24195. isStereoscopicSideBySide: boolean;
  24196. /**
  24197. * 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
  24198. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  24199. * else in the scene. (Eg. security camera)
  24200. *
  24201. * 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)
  24202. */
  24203. customRenderTargets: RenderTargetTexture[];
  24204. /**
  24205. * When set, the camera will render to this render target instead of the default canvas
  24206. *
  24207. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  24208. */
  24209. outputRenderTarget: Nullable<RenderTargetTexture>;
  24210. /**
  24211. * Observable triggered when the camera view matrix has changed.
  24212. */
  24213. onViewMatrixChangedObservable: Observable<Camera>;
  24214. /**
  24215. * Observable triggered when the camera Projection matrix has changed.
  24216. */
  24217. onProjectionMatrixChangedObservable: Observable<Camera>;
  24218. /**
  24219. * Observable triggered when the inputs have been processed.
  24220. */
  24221. onAfterCheckInputsObservable: Observable<Camera>;
  24222. /**
  24223. * Observable triggered when reset has been called and applied to the camera.
  24224. */
  24225. onRestoreStateObservable: Observable<Camera>;
  24226. /** @hidden */ private _cameraRigParams: any;
  24227. /** @hidden */ private _rigCameras: Camera[];
  24228. /** @hidden */ private _rigPostProcess: Nullable<PostProcess>;
  24229. protected _webvrViewMatrix: Matrix;
  24230. /** @hidden */ private _skipRendering: boolean;
  24231. /** @hidden */ private _projectionMatrix: Matrix;
  24232. /** @hidden */ private _postProcesses: Nullable<PostProcess>[];
  24233. /** @hidden */ private _activeMeshes: SmartArray<AbstractMesh>;
  24234. protected _globalPosition: Vector3;
  24235. /** @hidden */ private _computedViewMatrix: Matrix;
  24236. private _doNotComputeProjectionMatrix;
  24237. private _transformMatrix;
  24238. private _frustumPlanes;
  24239. private _refreshFrustumPlanes;
  24240. private _storedFov;
  24241. private _stateStored;
  24242. /**
  24243. * Instantiates a new camera object.
  24244. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  24245. * @see http://doc.babylonjs.com/features/cameras
  24246. * @param name Defines the name of the camera in the scene
  24247. * @param position Defines the position of the camera
  24248. * @param scene Defines the scene the camera belongs too
  24249. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  24250. */
  24251. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  24252. /**
  24253. * Store current camera state (fov, position, etc..)
  24254. * @returns the camera
  24255. */
  24256. storeState(): Camera;
  24257. /**
  24258. * Restores the camera state values if it has been stored. You must call storeState() first
  24259. */
  24260. protected _restoreStateValues(): boolean;
  24261. /**
  24262. * Restored camera state. You must call storeState() first.
  24263. * @returns true if restored and false otherwise
  24264. */
  24265. restoreState(): boolean;
  24266. /**
  24267. * Gets the class name of the camera.
  24268. * @returns the class name
  24269. */
  24270. getClassName(): string;
  24271. /** @hidden */ protected readonly _isCamera: boolean;
  24272. /**
  24273. * Gets a string representation of the camera useful for debug purpose.
  24274. * @param fullDetails Defines that a more verboe level of logging is required
  24275. * @returns the string representation
  24276. */
  24277. toString(fullDetails?: boolean): string;
  24278. /**
  24279. * Gets the current world space position of the camera.
  24280. */
  24281. readonly globalPosition: Vector3;
  24282. /**
  24283. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  24284. * @returns the active meshe list
  24285. */
  24286. getActiveMeshes(): SmartArray<AbstractMesh>;
  24287. /**
  24288. * Check wether a mesh is part of the current active mesh list of the camera
  24289. * @param mesh Defines the mesh to check
  24290. * @returns true if active, false otherwise
  24291. */
  24292. isActiveMesh(mesh: Mesh): boolean;
  24293. /**
  24294. * Is this camera ready to be used/rendered
  24295. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  24296. * @return true if the camera is ready
  24297. */
  24298. isReady(completeCheck?: boolean): boolean;
  24299. /** @hidden */ private _initCache(): void;
  24300. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  24301. /** @hidden */ private _isSynchronized(): boolean;
  24302. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  24303. /** @hidden */ private _isSynchronizedProjectionMatrix(): boolean;
  24304. /**
  24305. * Attach the input controls to a specific dom element to get the input from.
  24306. * @param element Defines the element the controls should be listened from
  24307. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  24308. */
  24309. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  24310. /**
  24311. * Detach the current controls from the specified dom element.
  24312. * @param element Defines the element to stop listening the inputs from
  24313. */
  24314. detachControl(element: HTMLElement): void;
  24315. /**
  24316. * Update the camera state according to the different inputs gathered during the frame.
  24317. */
  24318. update(): void;
  24319. /** @hidden */ private _checkInputs(): void;
  24320. /** @hidden */
  24321. readonly rigCameras: Camera[];
  24322. /**
  24323. * Gets the post process used by the rig cameras
  24324. */
  24325. readonly rigPostProcess: Nullable<PostProcess>;
  24326. /**
  24327. * Internal, gets the first post proces.
  24328. * @returns the first post process to be run on this camera.
  24329. */ private _getFirstPostProcess(): Nullable<PostProcess>;
  24330. private _cascadePostProcessesToRigCams;
  24331. /**
  24332. * Attach a post process to the camera.
  24333. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24334. * @param postProcess The post process to attach to the camera
  24335. * @param insertAt The position of the post process in case several of them are in use in the scene
  24336. * @returns the position the post process has been inserted at
  24337. */
  24338. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  24339. /**
  24340. * Detach a post process to the camera.
  24341. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  24342. * @param postProcess The post process to detach from the camera
  24343. */
  24344. detachPostProcess(postProcess: PostProcess): void;
  24345. /**
  24346. * Gets the current world matrix of the camera
  24347. */
  24348. getWorldMatrix(): Matrix;
  24349. /** @hidden */ private _getViewMatrix(): Matrix;
  24350. /**
  24351. * Gets the current view matrix of the camera.
  24352. * @param force forces the camera to recompute the matrix without looking at the cached state
  24353. * @returns the view matrix
  24354. */
  24355. getViewMatrix(force?: boolean): Matrix;
  24356. /**
  24357. * Freeze the projection matrix.
  24358. * It will prevent the cache check of the camera projection compute and can speed up perf
  24359. * if no parameter of the camera are meant to change
  24360. * @param projection Defines manually a projection if necessary
  24361. */
  24362. freezeProjectionMatrix(projection?: Matrix): void;
  24363. /**
  24364. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  24365. */
  24366. unfreezeProjectionMatrix(): void;
  24367. /**
  24368. * Gets the current projection matrix of the camera.
  24369. * @param force forces the camera to recompute the matrix without looking at the cached state
  24370. * @returns the projection matrix
  24371. */
  24372. getProjectionMatrix(force?: boolean): Matrix;
  24373. /**
  24374. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  24375. * @returns a Matrix
  24376. */
  24377. getTransformationMatrix(): Matrix;
  24378. private _updateFrustumPlanes;
  24379. /**
  24380. * Checks if a cullable object (mesh...) is in the camera frustum
  24381. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  24382. * @param target The object to check
  24383. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  24384. * @returns true if the object is in frustum otherwise false
  24385. */
  24386. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  24387. /**
  24388. * Checks if a cullable object (mesh...) is in the camera frustum
  24389. * Unlike isInFrustum this cheks the full bounding box
  24390. * @param target The object to check
  24391. * @returns true if the object is in frustum otherwise false
  24392. */
  24393. isCompletelyInFrustum(target: ICullable): boolean;
  24394. /**
  24395. * Gets a ray in the forward direction from the camera.
  24396. * @param length Defines the length of the ray to create
  24397. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  24398. * @param origin Defines the start point of the ray which defaults to the camera position
  24399. * @returns the forward ray
  24400. */
  24401. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  24402. /**
  24403. * Releases resources associated with this node.
  24404. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24405. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24406. */
  24407. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24408. /** @hidden */ private _isLeftCamera: boolean;
  24409. /**
  24410. * Gets the left camera of a rig setup in case of Rigged Camera
  24411. */
  24412. readonly isLeftCamera: boolean;
  24413. /** @hidden */ private _isRightCamera: boolean;
  24414. /**
  24415. * Gets the right camera of a rig setup in case of Rigged Camera
  24416. */
  24417. readonly isRightCamera: boolean;
  24418. /**
  24419. * Gets the left camera of a rig setup in case of Rigged Camera
  24420. */
  24421. readonly leftCamera: Nullable<FreeCamera>;
  24422. /**
  24423. * Gets the right camera of a rig setup in case of Rigged Camera
  24424. */
  24425. readonly rightCamera: Nullable<FreeCamera>;
  24426. /**
  24427. * Gets the left camera target of a rig setup in case of Rigged Camera
  24428. * @returns the target position
  24429. */
  24430. getLeftTarget(): Nullable<Vector3>;
  24431. /**
  24432. * Gets the right camera target of a rig setup in case of Rigged Camera
  24433. * @returns the target position
  24434. */
  24435. getRightTarget(): Nullable<Vector3>;
  24436. /**
  24437. * @hidden
  24438. */
  24439. setCameraRigMode(mode: number, rigParams: any): void;
  24440. /** @hidden */ private static _setStereoscopicRigMode(camera: Camera): void;
  24441. /** @hidden */ private static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  24442. /** @hidden */ private static _setVRRigMode(camera: Camera, rigParams: any): void;
  24443. /** @hidden */ private static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  24444. /** @hidden */ private _getVRProjectionMatrix(): Matrix;
  24445. protected _updateCameraRotationMatrix(): void;
  24446. protected _updateWebVRCameraRotationMatrix(): void;
  24447. /**
  24448. * This function MUST be overwritten by the different WebVR cameras available.
  24449. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24450. * @hidden
  24451. */ private _getWebVRProjectionMatrix(): Matrix;
  24452. /**
  24453. * This function MUST be overwritten by the different WebVR cameras available.
  24454. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  24455. * @hidden
  24456. */ private _getWebVRViewMatrix(): Matrix;
  24457. /** @hidden */
  24458. setCameraRigParameter(name: string, value: any): void;
  24459. /**
  24460. * needs to be overridden by children so sub has required properties to be copied
  24461. * @hidden
  24462. */
  24463. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  24464. /**
  24465. * May need to be overridden by children
  24466. * @hidden
  24467. */ private _updateRigCameras(): void;
  24468. /** @hidden */ private _setupInputs(): void;
  24469. /**
  24470. * Serialiaze the camera setup to a json represention
  24471. * @returns the JSON representation
  24472. */
  24473. serialize(): any;
  24474. /**
  24475. * Clones the current camera.
  24476. * @param name The cloned camera name
  24477. * @returns the cloned camera
  24478. */
  24479. clone(name: string): Camera;
  24480. /**
  24481. * Gets the direction of the camera relative to a given local axis.
  24482. * @param localAxis Defines the reference axis to provide a relative direction.
  24483. * @return the direction
  24484. */
  24485. getDirection(localAxis: Vector3): Vector3;
  24486. /**
  24487. * Gets the direction of the camera relative to a given local axis into a passed vector.
  24488. * @param localAxis Defines the reference axis to provide a relative direction.
  24489. * @param result Defines the vector to store the result in
  24490. */
  24491. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  24492. /**
  24493. * Gets a camera constructor for a given camera type
  24494. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  24495. * @param name The name of the camera the result will be able to instantiate
  24496. * @param scene The scene the result will construct the camera in
  24497. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  24498. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  24499. * @returns a factory method to construc the camera
  24500. */
  24501. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  24502. /**
  24503. * Compute the world matrix of the camera.
  24504. * @returns the camera workd matrix
  24505. */
  24506. computeWorldMatrix(): Matrix;
  24507. /**
  24508. * Parse a JSON and creates the camera from the parsed information
  24509. * @param parsedCamera The JSON to parse
  24510. * @param scene The scene to instantiate the camera in
  24511. * @returns the newly constructed camera
  24512. */
  24513. static Parse(parsedCamera: any, scene: Scene): Camera;
  24514. }
  24515. }
  24516. declare module BABYLON {
  24517. /**
  24518. * Class containing static functions to help procedurally build meshes
  24519. */
  24520. export class DiscBuilder {
  24521. /**
  24522. * Creates a plane polygonal mesh. By default, this is a disc
  24523. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  24524. * * 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
  24525. * * 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
  24526. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24527. * * 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
  24528. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24529. * @param name defines the name of the mesh
  24530. * @param options defines the options used to create the mesh
  24531. * @param scene defines the hosting scene
  24532. * @returns the plane polygonal mesh
  24533. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24534. */
  24535. static CreateDisc(name: string, options: {
  24536. radius?: number;
  24537. tessellation?: number;
  24538. arc?: number;
  24539. updatable?: boolean;
  24540. sideOrientation?: number;
  24541. frontUVs?: Vector4;
  24542. backUVs?: Vector4;
  24543. }, scene?: Nullable<Scene>): Mesh;
  24544. }
  24545. }
  24546. declare module BABYLON {
  24547. /**
  24548. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24549. *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.
  24550. * The SPS is also a particle system. It provides some methods to manage the particles.
  24551. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24552. *
  24553. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  24554. */
  24555. export class SolidParticleSystem implements IDisposable {
  24556. /**
  24557. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24558. * Example : var p = SPS.particles[i];
  24559. */
  24560. particles: SolidParticle[];
  24561. /**
  24562. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24563. */
  24564. nbParticles: number;
  24565. /**
  24566. * If the particles must ever face the camera (default false). Useful for planar particles.
  24567. */
  24568. billboard: boolean;
  24569. /**
  24570. * Recompute normals when adding a shape
  24571. */
  24572. recomputeNormals: boolean;
  24573. /**
  24574. * This a counter ofr your own usage. It's not set by any SPS functions.
  24575. */
  24576. counter: number;
  24577. /**
  24578. * The SPS name. This name is also given to the underlying mesh.
  24579. */
  24580. name: string;
  24581. /**
  24582. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24583. */
  24584. mesh: Mesh;
  24585. /**
  24586. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24587. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  24588. */
  24589. vars: any;
  24590. /**
  24591. * This array is populated when the SPS is set as 'pickable'.
  24592. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24593. * Each element of this array is an object `{idx: int, faceId: int}`.
  24594. * `idx` is the picked particle index in the `SPS.particles` array
  24595. * `faceId` is the picked face index counted within this particle.
  24596. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  24597. */
  24598. pickedParticles: {
  24599. idx: number;
  24600. faceId: number;
  24601. }[];
  24602. /**
  24603. * This array is populated when `enableDepthSort` is set to true.
  24604. * Each element of this array is an instance of the class DepthSortedParticle.
  24605. */
  24606. depthSortedParticles: DepthSortedParticle[];
  24607. /**
  24608. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24609. * @hidden
  24610. */ private _bSphereOnly: boolean;
  24611. /**
  24612. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24613. * @hidden
  24614. */ private _bSphereRadiusFactor: number;
  24615. private _scene;
  24616. private _positions;
  24617. private _indices;
  24618. private _normals;
  24619. private _colors;
  24620. private _uvs;
  24621. private _indices32;
  24622. private _positions32;
  24623. private _normals32;
  24624. private _fixedNormal32;
  24625. private _colors32;
  24626. private _uvs32;
  24627. private _index;
  24628. private _updatable;
  24629. private _pickable;
  24630. private _isVisibilityBoxLocked;
  24631. private _alwaysVisible;
  24632. private _depthSort;
  24633. private _shapeCounter;
  24634. private _copy;
  24635. private _color;
  24636. private _computeParticleColor;
  24637. private _computeParticleTexture;
  24638. private _computeParticleRotation;
  24639. private _computeParticleVertex;
  24640. private _computeBoundingBox;
  24641. private _depthSortParticles;
  24642. private _camera;
  24643. private _mustUnrotateFixedNormals;
  24644. private _particlesIntersect;
  24645. private _needs32Bits;
  24646. /**
  24647. * Creates a SPS (Solid Particle System) object.
  24648. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24649. * @param scene (Scene) is the scene in which the SPS is added.
  24650. * @param options defines the options of the sps e.g.
  24651. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24652. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24653. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24654. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24655. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24656. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24657. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24658. */
  24659. constructor(name: string, scene: Scene, options?: {
  24660. updatable?: boolean;
  24661. isPickable?: boolean;
  24662. enableDepthSort?: boolean;
  24663. particleIntersection?: boolean;
  24664. boundingSphereOnly?: boolean;
  24665. bSphereRadiusFactor?: number;
  24666. });
  24667. /**
  24668. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24669. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24670. * @returns the created mesh
  24671. */
  24672. buildMesh(): Mesh;
  24673. /**
  24674. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24675. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24676. * Thus the particles generated from `digest()` have their property `position` set yet.
  24677. * @param mesh ( Mesh ) is the mesh to be digested
  24678. * @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
  24679. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24680. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24681. * @returns the current SPS
  24682. */
  24683. digest(mesh: Mesh, options?: {
  24684. facetNb?: number;
  24685. number?: number;
  24686. delta?: number;
  24687. }): SolidParticleSystem;
  24688. private _unrotateFixedNormals;
  24689. private _resetCopy;
  24690. private _meshBuilder;
  24691. private _posToShape;
  24692. private _uvsToShapeUV;
  24693. private _addParticle;
  24694. /**
  24695. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24696. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  24697. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24698. * @param nb (positive integer) the number of particles to be created from this model
  24699. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24700. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24701. * @returns the number of shapes in the system
  24702. */
  24703. addShape(mesh: Mesh, nb: number, options?: {
  24704. positionFunction?: any;
  24705. vertexFunction?: any;
  24706. }): number;
  24707. private _rebuildParticle;
  24708. /**
  24709. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24710. * @returns the SPS.
  24711. */
  24712. rebuildMesh(): SolidParticleSystem;
  24713. /**
  24714. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24715. * This method calls `updateParticle()` for each particle of the SPS.
  24716. * For an animated SPS, it is usually called within the render loop.
  24717. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24718. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24719. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24720. * @returns the SPS.
  24721. */
  24722. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24723. /**
  24724. * Disposes the SPS.
  24725. */
  24726. dispose(): void;
  24727. /**
  24728. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24729. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24730. * @returns the SPS.
  24731. */
  24732. refreshVisibleSize(): SolidParticleSystem;
  24733. /**
  24734. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24735. * @param size the size (float) of the visibility box
  24736. * note : this doesn't lock the SPS mesh bounding box.
  24737. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24738. */
  24739. setVisibilityBox(size: number): void;
  24740. /**
  24741. * Gets whether the SPS as always visible or not
  24742. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24743. */
  24744. /**
  24745. * Sets the SPS as always visible or not
  24746. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24747. */
  24748. isAlwaysVisible: boolean;
  24749. /**
  24750. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24751. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24752. */
  24753. /**
  24754. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24755. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  24756. */
  24757. isVisibilityBoxLocked: boolean;
  24758. /**
  24759. * Tells to `setParticles()` to compute the particle rotations or not.
  24760. * Default value : true. The SPS is faster when it's set to false.
  24761. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24762. */
  24763. /**
  24764. * Gets if `setParticles()` computes the particle rotations or not.
  24765. * Default value : true. The SPS is faster when it's set to false.
  24766. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24767. */
  24768. computeParticleRotation: boolean;
  24769. /**
  24770. * Tells to `setParticles()` to compute the particle colors or not.
  24771. * Default value : true. The SPS is faster when it's set to false.
  24772. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24773. */
  24774. /**
  24775. * Gets if `setParticles()` computes the particle colors or not.
  24776. * Default value : true. The SPS is faster when it's set to false.
  24777. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24778. */
  24779. computeParticleColor: boolean;
  24780. /**
  24781. * Gets if `setParticles()` computes the particle textures or not.
  24782. * Default value : true. The SPS is faster when it's set to false.
  24783. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24784. */
  24785. computeParticleTexture: boolean;
  24786. /**
  24787. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24788. * Default value : false. The SPS is faster when it's set to false.
  24789. * Note : the particle custom vertex positions aren't stored values.
  24790. */
  24791. /**
  24792. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24793. * Default value : false. The SPS is faster when it's set to false.
  24794. * Note : the particle custom vertex positions aren't stored values.
  24795. */
  24796. computeParticleVertex: boolean;
  24797. /**
  24798. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24799. */
  24800. /**
  24801. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24802. */
  24803. computeBoundingBox: boolean;
  24804. /**
  24805. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24806. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24807. * Default : `true`
  24808. */
  24809. /**
  24810. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24811. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24812. * Default : `true`
  24813. */
  24814. depthSortParticles: boolean;
  24815. /**
  24816. * This function does nothing. It may be overwritten to set all the particle first values.
  24817. * The SPS doesn't call this function, you may have to call it by your own.
  24818. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24819. */
  24820. initParticles(): void;
  24821. /**
  24822. * This function does nothing. It may be overwritten to recycle a particle.
  24823. * The SPS doesn't call this function, you may have to call it by your own.
  24824. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24825. * @param particle The particle to recycle
  24826. * @returns the recycled particle
  24827. */
  24828. recycleParticle(particle: SolidParticle): SolidParticle;
  24829. /**
  24830. * Updates a particle : this function should be overwritten by the user.
  24831. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24832. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  24833. * @example : just set a particle position or velocity and recycle conditions
  24834. * @param particle The particle to update
  24835. * @returns the updated particle
  24836. */
  24837. updateParticle(particle: SolidParticle): SolidParticle;
  24838. /**
  24839. * Updates a vertex of a particle : it can be overwritten by the user.
  24840. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24841. * @param particle the current particle
  24842. * @param vertex the current index of the current particle
  24843. * @param pt the index of the current vertex in the particle shape
  24844. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  24845. * @example : just set a vertex particle position
  24846. * @returns the updated vertex
  24847. */
  24848. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24849. /**
  24850. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24851. * This does nothing and may be overwritten by the user.
  24852. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24853. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24854. * @param update the boolean update value actually passed to setParticles()
  24855. */
  24856. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24857. /**
  24858. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24859. * This will be passed three parameters.
  24860. * This does nothing and may be overwritten by the user.
  24861. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24862. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24863. * @param update the boolean update value actually passed to setParticles()
  24864. */
  24865. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24866. }
  24867. }
  24868. declare module BABYLON {
  24869. /**
  24870. * Represents one particle of a solid particle system.
  24871. */
  24872. export class SolidParticle {
  24873. /**
  24874. * particle global index
  24875. */
  24876. idx: number;
  24877. /**
  24878. * The color of the particle
  24879. */
  24880. color: Nullable<Color4>;
  24881. /**
  24882. * The world space position of the particle.
  24883. */
  24884. position: Vector3;
  24885. /**
  24886. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24887. */
  24888. rotation: Vector3;
  24889. /**
  24890. * The world space rotation quaternion of the particle.
  24891. */
  24892. rotationQuaternion: Nullable<Quaternion>;
  24893. /**
  24894. * The scaling of the particle.
  24895. */
  24896. scaling: Vector3;
  24897. /**
  24898. * The uvs of the particle.
  24899. */
  24900. uvs: Vector4;
  24901. /**
  24902. * The current speed of the particle.
  24903. */
  24904. velocity: Vector3;
  24905. /**
  24906. * The pivot point in the particle local space.
  24907. */
  24908. pivot: Vector3;
  24909. /**
  24910. * Must the particle be translated from its pivot point in its local space ?
  24911. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24912. * Default : false
  24913. */
  24914. translateFromPivot: boolean;
  24915. /**
  24916. * Is the particle active or not ?
  24917. */
  24918. alive: boolean;
  24919. /**
  24920. * Is the particle visible or not ?
  24921. */
  24922. isVisible: boolean;
  24923. /**
  24924. * Index of this particle in the global "positions" array (Internal use)
  24925. * @hidden
  24926. */ private _pos: number;
  24927. /**
  24928. * @hidden Index of this particle in the global "indices" array (Internal use)
  24929. */ private _ind: number;
  24930. /**
  24931. * @hidden ModelShape of this particle (Internal use)
  24932. */ private _model: ModelShape;
  24933. /**
  24934. * ModelShape id of this particle
  24935. */
  24936. shapeId: number;
  24937. /**
  24938. * Index of the particle in its shape id (Internal use)
  24939. */
  24940. idxInShape: number;
  24941. /**
  24942. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24943. */ private _modelBoundingInfo: BoundingInfo;
  24944. /**
  24945. * @hidden Particle BoundingInfo object (Internal use)
  24946. */ private _boundingInfo: BoundingInfo;
  24947. /**
  24948. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24949. */ private _sps: SolidParticleSystem;
  24950. /**
  24951. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24952. */ private _stillInvisible: boolean;
  24953. /**
  24954. * @hidden Last computed particle rotation matrix
  24955. */ private _rotationMatrix: number[];
  24956. /**
  24957. * Parent particle Id, if any.
  24958. * Default null.
  24959. */
  24960. parentId: Nullable<number>;
  24961. /**
  24962. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24963. * The possible values are :
  24964. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24965. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24966. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24967. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24968. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24969. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24970. * */
  24971. cullingStrategy: number;
  24972. /**
  24973. * @hidden Internal global position in the SPS.
  24974. */ private _globalPosition: Vector3;
  24975. /**
  24976. * Creates a Solid Particle object.
  24977. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24978. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24979. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24980. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24981. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24982. * @param shapeId (integer) is the model shape identifier in the SPS.
  24983. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24984. * @param sps defines the sps it is associated to
  24985. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24986. */
  24987. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24988. /**
  24989. * Legacy support, changed scale to scaling
  24990. */
  24991. /**
  24992. * Legacy support, changed scale to scaling
  24993. */
  24994. scale: Vector3;
  24995. /**
  24996. * Legacy support, changed quaternion to rotationQuaternion
  24997. */
  24998. /**
  24999. * Legacy support, changed quaternion to rotationQuaternion
  25000. */
  25001. quaternion: Nullable<Quaternion>;
  25002. /**
  25003. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  25004. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  25005. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  25006. * @returns true if it intersects
  25007. */
  25008. intersectsMesh(target: Mesh | SolidParticle): boolean;
  25009. /**
  25010. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  25011. * A particle is in the frustum if its bounding box intersects the frustum
  25012. * @param frustumPlanes defines the frustum to test
  25013. * @returns true if the particle is in the frustum planes
  25014. */
  25015. isInFrustum(frustumPlanes: Plane[]): boolean;
  25016. /**
  25017. * get the rotation matrix of the particle
  25018. * @hidden
  25019. */
  25020. getRotationMatrix(m: Matrix): void;
  25021. }
  25022. /**
  25023. * Represents the shape of the model used by one particle of a solid particle system.
  25024. * SPS internal tool, don't use it manually.
  25025. */
  25026. export class ModelShape {
  25027. /**
  25028. * The shape id
  25029. * @hidden
  25030. */
  25031. shapeID: number;
  25032. /**
  25033. * flat array of model positions (internal use)
  25034. * @hidden
  25035. */ private _shape: Vector3[];
  25036. /**
  25037. * flat array of model UVs (internal use)
  25038. * @hidden
  25039. */ private _shapeUV: number[];
  25040. /**
  25041. * length of the shape in the model indices array (internal use)
  25042. * @hidden
  25043. */ private _indicesLength: number;
  25044. /**
  25045. * Custom position function (internal use)
  25046. * @hidden
  25047. */ private _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  25048. /**
  25049. * Custom vertex function (internal use)
  25050. * @hidden
  25051. */ private _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  25052. /**
  25053. * 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.
  25054. * SPS internal tool, don't use it manually.
  25055. * @hidden
  25056. */
  25057. 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>);
  25058. }
  25059. /**
  25060. * Represents a Depth Sorted Particle in the solid particle system.
  25061. */
  25062. export class DepthSortedParticle {
  25063. /**
  25064. * Index of the particle in the "indices" array
  25065. */
  25066. ind: number;
  25067. /**
  25068. * Length of the particle shape in the "indices" array
  25069. */
  25070. indicesLength: number;
  25071. /**
  25072. * Squared distance from the particle to the camera
  25073. */
  25074. sqDistance: number;
  25075. }
  25076. }
  25077. declare module BABYLON {
  25078. /**
  25079. * @hidden
  25080. */
  25081. 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>>;
  25082. }
  25083. }
  25084. declare module BABYLON {
  25085. /** @hidden */ private class _FacetDataStorage {
  25086. facetPositions: Vector3[];
  25087. facetNormals: Vector3[];
  25088. facetPartitioning: number[][];
  25089. facetNb: number;
  25090. partitioningSubdivisions: number;
  25091. partitioningBBoxRatio: number;
  25092. facetDataEnabled: boolean;
  25093. facetParameters: any;
  25094. bbSize: Vector3;
  25095. subDiv: {
  25096. max: number;
  25097. X: number;
  25098. Y: number;
  25099. Z: number;
  25100. };
  25101. facetDepthSort: boolean;
  25102. facetDepthSortEnabled: boolean;
  25103. depthSortedIndices: IndicesArray;
  25104. depthSortedFacets: {
  25105. ind: number;
  25106. sqDistance: number;
  25107. }[];
  25108. facetDepthSortFunction: (f1: {
  25109. ind: number;
  25110. sqDistance: number;
  25111. }, f2: {
  25112. ind: number;
  25113. sqDistance: number;
  25114. }) => number;
  25115. facetDepthSortFrom: Vector3;
  25116. facetDepthSortOrigin: Vector3;
  25117. invertedMatrix: Matrix;
  25118. }
  25119. /**
  25120. * @hidden
  25121. **/ 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;
  25122. }
  25123. /**
  25124. * Class used to store all common mesh properties
  25125. */
  25126. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  25127. /** No occlusion */
  25128. static OCCLUSION_TYPE_NONE: number;
  25129. /** Occlusion set to optimisitic */
  25130. static OCCLUSION_TYPE_OPTIMISTIC: number;
  25131. /** Occlusion set to strict */
  25132. static OCCLUSION_TYPE_STRICT: number;
  25133. /** Use an accurante occlusion algorithm */
  25134. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  25135. /** Use a conservative occlusion algorithm */
  25136. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  25137. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  25138. * Test order :
  25139. * Is the bounding sphere outside the frustum ?
  25140. * If not, are the bounding box vertices outside the frustum ?
  25141. * It not, then the cullable object is in the frustum.
  25142. */
  25143. static readonly CULLINGSTRATEGY_STANDARD: number;
  25144. /** Culling strategy : Bounding Sphere Only.
  25145. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  25146. * It's also less accurate than the standard because some not visible objects can still be selected.
  25147. * Test : is the bounding sphere outside the frustum ?
  25148. * If not, then the cullable object is in the frustum.
  25149. */
  25150. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  25151. /** Culling strategy : Optimistic Inclusion.
  25152. * This in an inclusion test first, then the standard exclusion test.
  25153. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  25154. * 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.
  25155. * Anyway, it's as accurate as the standard strategy.
  25156. * Test :
  25157. * Is the cullable object bounding sphere center in the frustum ?
  25158. * If not, apply the default culling strategy.
  25159. */
  25160. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  25161. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  25162. * This in an inclusion test first, then the bounding sphere only exclusion test.
  25163. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  25164. * 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.
  25165. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  25166. * Test :
  25167. * Is the cullable object bounding sphere center in the frustum ?
  25168. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  25169. */
  25170. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  25171. /**
  25172. * No billboard
  25173. */
  25174. static readonly BILLBOARDMODE_NONE: number;
  25175. /** Billboard on X axis */
  25176. static readonly BILLBOARDMODE_X: number;
  25177. /** Billboard on Y axis */
  25178. static readonly BILLBOARDMODE_Y: number;
  25179. /** Billboard on Z axis */
  25180. static readonly BILLBOARDMODE_Z: number;
  25181. /** Billboard on all axes */
  25182. static readonly BILLBOARDMODE_ALL: number;
  25183. /** Billboard on using position instead of orientation */
  25184. static readonly BILLBOARDMODE_USE_POSITION: number;
  25185. /** @hidden */ private _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  25186. /**
  25187. * The culling strategy to use to check whether the mesh must be rendered or not.
  25188. * This value can be changed at any time and will be used on the next render mesh selection.
  25189. * The possible values are :
  25190. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  25191. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  25192. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  25193. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  25194. * Please read each static variable documentation to get details about the culling process.
  25195. * */
  25196. cullingStrategy: number;
  25197. /**
  25198. * Gets the number of facets in the mesh
  25199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25200. */
  25201. readonly facetNb: number;
  25202. /**
  25203. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  25204. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25205. */
  25206. partitioningSubdivisions: number;
  25207. /**
  25208. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  25209. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  25210. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  25211. */
  25212. partitioningBBoxRatio: number;
  25213. /**
  25214. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  25215. * Works only for updatable meshes.
  25216. * Doesn't work with multi-materials
  25217. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25218. */
  25219. mustDepthSortFacets: boolean;
  25220. /**
  25221. * The location (Vector3) where the facet depth sort must be computed from.
  25222. * By default, the active camera position.
  25223. * Used only when facet depth sort is enabled
  25224. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  25225. */
  25226. facetDepthSortFrom: Vector3;
  25227. /**
  25228. * gets a boolean indicating if facetData is enabled
  25229. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  25230. */
  25231. readonly isFacetDataEnabled: boolean;
  25232. /** @hidden */ private _updateNonUniformScalingState(value: boolean): boolean;
  25233. /**
  25234. * An event triggered when this mesh collides with another one
  25235. */
  25236. onCollideObservable: Observable<AbstractMesh>;
  25237. /** Set a function to call when this mesh collides with another one */
  25238. onCollide: () => void;
  25239. /**
  25240. * An event triggered when the collision's position changes
  25241. */
  25242. onCollisionPositionChangeObservable: Observable<Vector3>;
  25243. /** Set a function to call when the collision's position changes */
  25244. onCollisionPositionChange: () => void;
  25245. /**
  25246. * An event triggered when material is changed
  25247. */
  25248. onMaterialChangedObservable: Observable<AbstractMesh>;
  25249. /**
  25250. * Gets or sets the orientation for POV movement & rotation
  25251. */
  25252. definedFacingForward: boolean;
  25253. /** @hidden */ private _occlusionQuery: Nullable<WebGLQuery>;
  25254. /** @hidden */ private _renderingGroup: Nullable<RenderingGroup>;
  25255. /**
  25256. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25257. */
  25258. /**
  25259. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  25260. */
  25261. visibility: number;
  25262. /** Gets or sets the alpha index used to sort transparent meshes
  25263. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  25264. */
  25265. alphaIndex: number;
  25266. /**
  25267. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  25268. */
  25269. isVisible: boolean;
  25270. /**
  25271. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  25272. */
  25273. isPickable: boolean;
  25274. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  25275. showSubMeshesBoundingBox: boolean;
  25276. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  25277. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  25278. */
  25279. isBlocker: boolean;
  25280. /**
  25281. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  25282. */
  25283. enablePointerMoveEvents: boolean;
  25284. /**
  25285. * Specifies the rendering group id for this mesh (0 by default)
  25286. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  25287. */
  25288. renderingGroupId: number;
  25289. private _material;
  25290. /** Gets or sets current material */
  25291. material: Nullable<Material>;
  25292. /**
  25293. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  25294. * @see http://doc.babylonjs.com/babylon101/shadows
  25295. */
  25296. receiveShadows: boolean;
  25297. /** Defines color to use when rendering outline */
  25298. outlineColor: Color3;
  25299. /** Define width to use when rendering outline */
  25300. outlineWidth: number;
  25301. /** Defines color to use when rendering overlay */
  25302. overlayColor: Color3;
  25303. /** Defines alpha to use when rendering overlay */
  25304. overlayAlpha: number;
  25305. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  25306. hasVertexAlpha: boolean;
  25307. /** 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) */
  25308. useVertexColors: boolean;
  25309. /**
  25310. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  25311. */
  25312. computeBonesUsingShaders: boolean;
  25313. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  25314. numBoneInfluencers: number;
  25315. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  25316. applyFog: boolean;
  25317. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  25318. useOctreeForRenderingSelection: boolean;
  25319. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  25320. useOctreeForPicking: boolean;
  25321. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  25322. useOctreeForCollisions: boolean;
  25323. /**
  25324. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  25325. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  25326. */
  25327. layerMask: number;
  25328. /**
  25329. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  25330. */
  25331. alwaysSelectAsActiveMesh: boolean;
  25332. /**
  25333. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  25334. */
  25335. doNotSyncBoundingInfo: boolean;
  25336. /**
  25337. * Gets or sets the current action manager
  25338. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25339. */
  25340. actionManager: Nullable<AbstractActionManager>;
  25341. private _meshCollisionData;
  25342. /**
  25343. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  25344. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25345. */
  25346. ellipsoid: Vector3;
  25347. /**
  25348. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  25349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25350. */
  25351. ellipsoidOffset: Vector3;
  25352. /**
  25353. * Gets or sets a collision mask used to mask collisions (default is -1).
  25354. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25355. */
  25356. collisionMask: number;
  25357. /**
  25358. * Gets or sets the current collision group mask (-1 by default).
  25359. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  25360. */
  25361. collisionGroup: number;
  25362. /**
  25363. * Defines edge width used when edgesRenderer is enabled
  25364. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25365. */
  25366. edgesWidth: number;
  25367. /**
  25368. * Defines edge color used when edgesRenderer is enabled
  25369. * @see https://www.babylonjs-playground.com/#10OJSG#13
  25370. */
  25371. edgesColor: Color4;
  25372. /** @hidden */ private _edgesRenderer: Nullable<IEdgesRenderer>;
  25373. /** @hidden */ private _masterMesh: Nullable<AbstractMesh>;
  25374. /** @hidden */ private _boundingInfo: Nullable<BoundingInfo>;
  25375. /** @hidden */ private _renderId: number;
  25376. /**
  25377. * Gets or sets the list of subMeshes
  25378. * @see http://doc.babylonjs.com/how_to/multi_materials
  25379. */
  25380. subMeshes: SubMesh[];
  25381. /** @hidden */ private _intersectionsInProgress: AbstractMesh[];
  25382. /** @hidden */ private _unIndexed: boolean;
  25383. /** @hidden */ private _lightSources: Light[];
  25384. /** Gets the list of lights affecting that mesh */
  25385. readonly lightSources: Light[];
  25386. /** @hidden */ protected readonly _positions: Nullable<Vector3[]>;
  25387. /** @hidden */ private _waitingData: {
  25388. lods: Nullable<any>;
  25389. actions: Nullable<any>;
  25390. freezeWorldMatrix: Nullable<boolean>;
  25391. };
  25392. /** @hidden */ private _bonesTransformMatrices: Nullable<Float32Array>;
  25393. /** @hidden */ private _transformMatrixTexture: Nullable<RawTexture>;
  25394. /**
  25395. * Gets or sets a skeleton to apply skining transformations
  25396. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  25397. */
  25398. skeleton: Nullable<Skeleton>;
  25399. /**
  25400. * An event triggered when the mesh is rebuilt.
  25401. */
  25402. onRebuildObservable: Observable<AbstractMesh>;
  25403. /**
  25404. * Creates a new AbstractMesh
  25405. * @param name defines the name of the mesh
  25406. * @param scene defines the hosting scene
  25407. */
  25408. constructor(name: string, scene?: Nullable<Scene>);
  25409. /**
  25410. * Returns the string "AbstractMesh"
  25411. * @returns "AbstractMesh"
  25412. */
  25413. getClassName(): string;
  25414. /**
  25415. * Gets a string representation of the current mesh
  25416. * @param fullDetails defines a boolean indicating if full details must be included
  25417. * @returns a string representation of the current mesh
  25418. */
  25419. toString(fullDetails?: boolean): string;
  25420. /**
  25421. * @hidden
  25422. */
  25423. protected _getEffectiveParent(): Nullable<Node>;
  25424. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25425. /** @hidden */ private _rebuild(): void;
  25426. /** @hidden */ private _resyncLightSources(): void;
  25427. /** @hidden */ private _resyncLighSource(light: Light): void;
  25428. /** @hidden */ private _unBindEffect(): void;
  25429. /** @hidden */ private _removeLightSource(light: Light): void;
  25430. private _markSubMeshesAsDirty;
  25431. /** @hidden */ private _markSubMeshesAsLightDirty(): void;
  25432. /** @hidden */ private _markSubMeshesAsAttributesDirty(): void;
  25433. /** @hidden */ private _markSubMeshesAsMiscDirty(): void;
  25434. /**
  25435. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  25436. */
  25437. scaling: Vector3;
  25438. /**
  25439. * Returns true if the mesh is blocked. Implemented by child classes
  25440. */
  25441. readonly isBlocked: boolean;
  25442. /**
  25443. * Returns the mesh itself by default. Implemented by child classes
  25444. * @param camera defines the camera to use to pick the right LOD level
  25445. * @returns the currentAbstractMesh
  25446. */
  25447. getLOD(camera: Camera): Nullable<AbstractMesh>;
  25448. /**
  25449. * Returns 0 by default. Implemented by child classes
  25450. * @returns an integer
  25451. */
  25452. getTotalVertices(): number;
  25453. /**
  25454. * Returns a positive integer : the total number of indices in this mesh geometry.
  25455. * @returns the numner of indices or zero if the mesh has no geometry.
  25456. */
  25457. getTotalIndices(): number;
  25458. /**
  25459. * Returns null by default. Implemented by child classes
  25460. * @returns null
  25461. */
  25462. getIndices(): Nullable<IndicesArray>;
  25463. /**
  25464. * Returns the array of the requested vertex data kind. Implemented by child classes
  25465. * @param kind defines the vertex data kind to use
  25466. * @returns null
  25467. */
  25468. getVerticesData(kind: string): Nullable<FloatArray>;
  25469. /**
  25470. * Sets the vertex data of the mesh geometry for the requested `kind`.
  25471. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  25472. * Note that a new underlying VertexBuffer object is created each call.
  25473. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  25474. * @param kind defines vertex data kind:
  25475. * * VertexBuffer.PositionKind
  25476. * * VertexBuffer.UVKind
  25477. * * VertexBuffer.UV2Kind
  25478. * * VertexBuffer.UV3Kind
  25479. * * VertexBuffer.UV4Kind
  25480. * * VertexBuffer.UV5Kind
  25481. * * VertexBuffer.UV6Kind
  25482. * * VertexBuffer.ColorKind
  25483. * * VertexBuffer.MatricesIndicesKind
  25484. * * VertexBuffer.MatricesIndicesExtraKind
  25485. * * VertexBuffer.MatricesWeightsKind
  25486. * * VertexBuffer.MatricesWeightsExtraKind
  25487. * @param data defines the data source
  25488. * @param updatable defines if the data must be flagged as updatable (or static)
  25489. * @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
  25490. * @returns the current mesh
  25491. */
  25492. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25493. /**
  25494. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25495. * If the mesh has no geometry, it is simply returned as it is.
  25496. * @param kind defines vertex data kind:
  25497. * * VertexBuffer.PositionKind
  25498. * * VertexBuffer.UVKind
  25499. * * VertexBuffer.UV2Kind
  25500. * * VertexBuffer.UV3Kind
  25501. * * VertexBuffer.UV4Kind
  25502. * * VertexBuffer.UV5Kind
  25503. * * VertexBuffer.UV6Kind
  25504. * * VertexBuffer.ColorKind
  25505. * * VertexBuffer.MatricesIndicesKind
  25506. * * VertexBuffer.MatricesIndicesExtraKind
  25507. * * VertexBuffer.MatricesWeightsKind
  25508. * * VertexBuffer.MatricesWeightsExtraKind
  25509. * @param data defines the data source
  25510. * @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
  25511. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25512. * @returns the current mesh
  25513. */
  25514. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25515. /**
  25516. * Sets the mesh indices,
  25517. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25518. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25519. * @param totalVertices Defines the total number of vertices
  25520. * @returns the current mesh
  25521. */
  25522. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25523. /**
  25524. * Gets a boolean indicating if specific vertex data is present
  25525. * @param kind defines the vertex data kind to use
  25526. * @returns true is data kind is present
  25527. */
  25528. isVerticesDataPresent(kind: string): boolean;
  25529. /**
  25530. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  25531. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  25532. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  25533. * @returns a BoundingInfo
  25534. */
  25535. getBoundingInfo(): BoundingInfo;
  25536. /**
  25537. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25538. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25539. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25540. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  25541. * @returns the current mesh
  25542. */
  25543. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  25544. /**
  25545. * Overwrite the current bounding info
  25546. * @param boundingInfo defines the new bounding info
  25547. * @returns the current mesh
  25548. */
  25549. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25550. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25551. readonly useBones: boolean;
  25552. /** @hidden */ private _preActivate(): void;
  25553. /** @hidden */ private _preActivateForIntermediateRendering(renderId: number): void;
  25554. /** @hidden */ private _activate(renderId: number, intermediateRendering: boolean): boolean;
  25555. /** @hidden */ private _postActivate(): void;
  25556. /** @hidden */ private _freeze(): void;
  25557. /** @hidden */ private _unFreeze(): void;
  25558. /**
  25559. * Gets the current world matrix
  25560. * @returns a Matrix
  25561. */
  25562. getWorldMatrix(): Matrix;
  25563. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  25564. /**
  25565. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  25566. */
  25567. readonly isAnInstance: boolean;
  25568. /**
  25569. * Gets a boolean indicating if this mesh has instances
  25570. */
  25571. readonly hasInstances: boolean;
  25572. /**
  25573. * Perform relative position change from the point of view of behind the front of the mesh.
  25574. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25575. * Supports definition of mesh facing forward or backward
  25576. * @param amountRight defines the distance on the right axis
  25577. * @param amountUp defines the distance on the up axis
  25578. * @param amountForward defines the distance on the forward axis
  25579. * @returns the current mesh
  25580. */
  25581. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25582. /**
  25583. * Calculate relative position change from the point of view of behind the front of the mesh.
  25584. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25585. * Supports definition of mesh facing forward or backward
  25586. * @param amountRight defines the distance on the right axis
  25587. * @param amountUp defines the distance on the up axis
  25588. * @param amountForward defines the distance on the forward axis
  25589. * @returns the new displacement vector
  25590. */
  25591. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25592. /**
  25593. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25594. * Supports definition of mesh facing forward or backward
  25595. * @param flipBack defines the flip
  25596. * @param twirlClockwise defines the twirl
  25597. * @param tiltRight defines the tilt
  25598. * @returns the current mesh
  25599. */
  25600. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25601. /**
  25602. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25603. * Supports definition of mesh facing forward or backward.
  25604. * @param flipBack defines the flip
  25605. * @param twirlClockwise defines the twirl
  25606. * @param tiltRight defines the tilt
  25607. * @returns the new rotation vector
  25608. */
  25609. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25610. /**
  25611. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25612. * This means the mesh underlying bounding box and sphere are recomputed.
  25613. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25614. * @returns the current mesh
  25615. */
  25616. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25617. /** @hidden */ private _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25618. /** @hidden */ private _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25619. /** @hidden */ private _updateBoundingInfo(): AbstractMesh;
  25620. /** @hidden */ private _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25621. /** @hidden */
  25622. protected _afterComputeWorldMatrix(): void;
  25623. /** @hidden */ protected readonly _effectiveMesh: AbstractMesh;
  25624. /**
  25625. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25626. * A mesh is in the frustum if its bounding box intersects the frustum
  25627. * @param frustumPlanes defines the frustum to test
  25628. * @returns true if the mesh is in the frustum planes
  25629. */
  25630. isInFrustum(frustumPlanes: Plane[]): boolean;
  25631. /**
  25632. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25633. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25634. * @param frustumPlanes defines the frustum to test
  25635. * @returns true if the mesh is completely in the frustum planes
  25636. */
  25637. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25638. /**
  25639. * True if the mesh intersects another mesh or a SolidParticle object
  25640. * @param mesh defines a target mesh or SolidParticle to test
  25641. * @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)
  25642. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25643. * @returns true if there is an intersection
  25644. */
  25645. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25646. /**
  25647. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25648. * @param point defines the point to test
  25649. * @returns true if there is an intersection
  25650. */
  25651. intersectsPoint(point: Vector3): boolean;
  25652. /**
  25653. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25654. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25655. */
  25656. checkCollisions: boolean;
  25657. /**
  25658. * Gets Collider object used to compute collisions (not physics)
  25659. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25660. */
  25661. readonly collider: Nullable<Collider>;
  25662. /**
  25663. * Move the mesh using collision engine
  25664. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25665. * @param displacement defines the requested displacement vector
  25666. * @returns the current mesh
  25667. */
  25668. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25669. private _onCollisionPositionChange;
  25670. /** @hidden */ private _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25671. /** @hidden */ private _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25672. /** @hidden */ private _checkCollision(collider: Collider): AbstractMesh;
  25673. /** @hidden */ private _generatePointsArray(): boolean;
  25674. /**
  25675. * Checks if the passed Ray intersects with the mesh
  25676. * @param ray defines the ray to use
  25677. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25678. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25679. * @returns the picking info
  25680. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25681. */
  25682. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25683. /**
  25684. * Clones the current mesh
  25685. * @param name defines the mesh name
  25686. * @param newParent defines the new mesh parent
  25687. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25688. * @returns the new mesh
  25689. */
  25690. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25691. /**
  25692. * Disposes all the submeshes of the current meshnp
  25693. * @returns the current mesh
  25694. */
  25695. releaseSubMeshes(): AbstractMesh;
  25696. /**
  25697. * Releases resources associated with this abstract mesh.
  25698. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25699. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25700. */
  25701. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25702. /**
  25703. * Adds the passed mesh as a child to the current mesh
  25704. * @param mesh defines the child mesh
  25705. * @returns the current mesh
  25706. */
  25707. addChild(mesh: AbstractMesh): AbstractMesh;
  25708. /**
  25709. * Removes the passed mesh from the current mesh children list
  25710. * @param mesh defines the child mesh
  25711. * @returns the current mesh
  25712. */
  25713. removeChild(mesh: AbstractMesh): AbstractMesh;
  25714. /** @hidden */
  25715. private _initFacetData;
  25716. /**
  25717. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25718. * This method can be called within the render loop.
  25719. * 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
  25720. * @returns the current mesh
  25721. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25722. */
  25723. updateFacetData(): AbstractMesh;
  25724. /**
  25725. * Returns the facetLocalNormals array.
  25726. * The normals are expressed in the mesh local spac
  25727. * @returns an array of Vector3
  25728. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25729. */
  25730. getFacetLocalNormals(): Vector3[];
  25731. /**
  25732. * Returns the facetLocalPositions array.
  25733. * The facet positions are expressed in the mesh local space
  25734. * @returns an array of Vector3
  25735. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25736. */
  25737. getFacetLocalPositions(): Vector3[];
  25738. /**
  25739. * Returns the facetLocalPartioning array
  25740. * @returns an array of array of numbers
  25741. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25742. */
  25743. getFacetLocalPartitioning(): number[][];
  25744. /**
  25745. * Returns the i-th facet position in the world system.
  25746. * This method allocates a new Vector3 per call
  25747. * @param i defines the facet index
  25748. * @returns a new Vector3
  25749. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25750. */
  25751. getFacetPosition(i: number): Vector3;
  25752. /**
  25753. * Sets the reference Vector3 with the i-th facet position in the world system
  25754. * @param i defines the facet index
  25755. * @param ref defines the target vector
  25756. * @returns the current mesh
  25757. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25758. */
  25759. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25760. /**
  25761. * Returns the i-th facet normal in the world system.
  25762. * This method allocates a new Vector3 per call
  25763. * @param i defines the facet index
  25764. * @returns a new Vector3
  25765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25766. */
  25767. getFacetNormal(i: number): Vector3;
  25768. /**
  25769. * Sets the reference Vector3 with the i-th facet normal in the world system
  25770. * @param i defines the facet index
  25771. * @param ref defines the target vector
  25772. * @returns the current mesh
  25773. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25774. */
  25775. getFacetNormalToRef(i: number, ref: Vector3): this;
  25776. /**
  25777. * 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)
  25778. * @param x defines x coordinate
  25779. * @param y defines y coordinate
  25780. * @param z defines z coordinate
  25781. * @returns the array of facet indexes
  25782. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25783. */
  25784. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25785. /**
  25786. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25787. * @param projected sets as the (x,y,z) world projection on the facet
  25788. * @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
  25789. * @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
  25790. * @param x defines x coordinate
  25791. * @param y defines y coordinate
  25792. * @param z defines z coordinate
  25793. * @returns the face index if found (or null instead)
  25794. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25795. */
  25796. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25797. /**
  25798. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25799. * @param projected sets as the (x,y,z) local projection on the facet
  25800. * @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
  25801. * @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
  25802. * @param x defines x coordinate
  25803. * @param y defines y coordinate
  25804. * @param z defines z coordinate
  25805. * @returns the face index if found (or null instead)
  25806. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25807. */
  25808. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25809. /**
  25810. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25811. * @returns the parameters
  25812. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25813. */
  25814. getFacetDataParameters(): any;
  25815. /**
  25816. * Disables the feature FacetData and frees the related memory
  25817. * @returns the current mesh
  25818. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25819. */
  25820. disableFacetData(): AbstractMesh;
  25821. /**
  25822. * Updates the AbstractMesh indices array
  25823. * @param indices defines the data source
  25824. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25825. * @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)
  25826. * @returns the current mesh
  25827. */
  25828. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25829. /**
  25830. * Creates new normals data for the mesh
  25831. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25832. * @returns the current mesh
  25833. */
  25834. createNormals(updatable: boolean): AbstractMesh;
  25835. /**
  25836. * Align the mesh with a normal
  25837. * @param normal defines the normal to use
  25838. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25839. * @returns the current mesh
  25840. */
  25841. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25842. /** @hidden */ private _checkOcclusionQuery(): boolean;
  25843. /**
  25844. * Disables the mesh edge rendering mode
  25845. * @returns the currentAbstractMesh
  25846. */
  25847. disableEdgesRendering(): AbstractMesh;
  25848. /**
  25849. * Enables the edge rendering mode on the mesh.
  25850. * This mode makes the mesh edges visible
  25851. * @param epsilon defines the maximal distance between two angles to detect a face
  25852. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  25853. * @returns the currentAbstractMesh
  25854. * @see https://www.babylonjs-playground.com/#19O9TU#0
  25855. */
  25856. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  25857. }
  25858. }
  25859. declare module BABYLON {
  25860. /**
  25861. * Interface used to define ActionEvent
  25862. */
  25863. export interface IActionEvent {
  25864. /** The mesh or sprite that triggered the action */
  25865. source: any;
  25866. /** The X mouse cursor position at the time of the event */
  25867. pointerX: number;
  25868. /** The Y mouse cursor position at the time of the event */
  25869. pointerY: number;
  25870. /** The mesh that is currently pointed at (can be null) */
  25871. meshUnderPointer: Nullable<AbstractMesh>;
  25872. /** the original (browser) event that triggered the ActionEvent */
  25873. sourceEvent?: any;
  25874. /** additional data for the event */
  25875. additionalData?: any;
  25876. }
  25877. /**
  25878. * ActionEvent is the event being sent when an action is triggered.
  25879. */
  25880. export class ActionEvent implements IActionEvent {
  25881. /** The mesh or sprite that triggered the action */
  25882. source: any;
  25883. /** The X mouse cursor position at the time of the event */
  25884. pointerX: number;
  25885. /** The Y mouse cursor position at the time of the event */
  25886. pointerY: number;
  25887. /** The mesh that is currently pointed at (can be null) */
  25888. meshUnderPointer: Nullable<AbstractMesh>;
  25889. /** the original (browser) event that triggered the ActionEvent */
  25890. sourceEvent?: any;
  25891. /** additional data for the event */
  25892. additionalData?: any;
  25893. /**
  25894. * Creates a new ActionEvent
  25895. * @param source The mesh or sprite that triggered the action
  25896. * @param pointerX The X mouse cursor position at the time of the event
  25897. * @param pointerY The Y mouse cursor position at the time of the event
  25898. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25899. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25900. * @param additionalData additional data for the event
  25901. */
  25902. constructor(
  25903. /** The mesh or sprite that triggered the action */
  25904. source: any,
  25905. /** The X mouse cursor position at the time of the event */
  25906. pointerX: number,
  25907. /** The Y mouse cursor position at the time of the event */
  25908. pointerY: number,
  25909. /** The mesh that is currently pointed at (can be null) */
  25910. meshUnderPointer: Nullable<AbstractMesh>,
  25911. /** the original (browser) event that triggered the ActionEvent */
  25912. sourceEvent?: any,
  25913. /** additional data for the event */
  25914. additionalData?: any);
  25915. /**
  25916. * Helper function to auto-create an ActionEvent from a source mesh.
  25917. * @param source The source mesh that triggered the event
  25918. * @param evt The original (browser) event
  25919. * @param additionalData additional data for the event
  25920. * @returns the new ActionEvent
  25921. */
  25922. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25923. /**
  25924. * Helper function to auto-create an ActionEvent from a source sprite
  25925. * @param source The source sprite that triggered the event
  25926. * @param scene Scene associated with the sprite
  25927. * @param evt The original (browser) event
  25928. * @param additionalData additional data for the event
  25929. * @returns the new ActionEvent
  25930. */
  25931. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25932. /**
  25933. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25934. * @param scene the scene where the event occurred
  25935. * @param evt The original (browser) event
  25936. * @returns the new ActionEvent
  25937. */
  25938. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25939. /**
  25940. * Helper function to auto-create an ActionEvent from a primitive
  25941. * @param prim defines the target primitive
  25942. * @param pointerPos defines the pointer position
  25943. * @param evt The original (browser) event
  25944. * @param additionalData additional data for the event
  25945. * @returns the new ActionEvent
  25946. */
  25947. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25948. }
  25949. }
  25950. declare module BABYLON {
  25951. /**
  25952. * Abstract class used to decouple action Manager from scene and meshes.
  25953. * Do not instantiate.
  25954. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25955. */
  25956. export abstract class AbstractActionManager implements IDisposable {
  25957. /** Gets the list of active triggers */
  25958. static Triggers: {
  25959. [key: string]: number;
  25960. };
  25961. /** Gets the cursor to use when hovering items */
  25962. hoverCursor: string;
  25963. /** Gets the list of actions */
  25964. actions: IAction[];
  25965. /**
  25966. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25967. */
  25968. isRecursive: boolean;
  25969. /**
  25970. * Releases all associated resources
  25971. */
  25972. abstract dispose(): void;
  25973. /**
  25974. * Does this action manager has pointer triggers
  25975. */
  25976. abstract readonly hasPointerTriggers: boolean;
  25977. /**
  25978. * Does this action manager has pick triggers
  25979. */
  25980. abstract readonly hasPickTriggers: boolean;
  25981. /**
  25982. * Process a specific trigger
  25983. * @param trigger defines the trigger to process
  25984. * @param evt defines the event details to be processed
  25985. */
  25986. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25987. /**
  25988. * Does this action manager handles actions of any of the given triggers
  25989. * @param triggers defines the triggers to be tested
  25990. * @return a boolean indicating whether one (or more) of the triggers is handled
  25991. */
  25992. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25993. /**
  25994. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25995. * speed.
  25996. * @param triggerA defines the trigger to be tested
  25997. * @param triggerB defines the trigger to be tested
  25998. * @return a boolean indicating whether one (or more) of the triggers is handled
  25999. */
  26000. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  26001. /**
  26002. * Does this action manager handles actions of a given trigger
  26003. * @param trigger defines the trigger to be tested
  26004. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  26005. * @return whether the trigger is handled
  26006. */
  26007. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  26008. /**
  26009. * Serialize this manager to a JSON object
  26010. * @param name defines the property name to store this manager
  26011. * @returns a JSON representation of this manager
  26012. */
  26013. abstract serialize(name: string): any;
  26014. /**
  26015. * Registers an action to this action manager
  26016. * @param action defines the action to be registered
  26017. * @return the action amended (prepared) after registration
  26018. */
  26019. abstract registerAction(action: IAction): Nullable<IAction>;
  26020. /**
  26021. * Unregisters an action to this action manager
  26022. * @param action defines the action to be unregistered
  26023. * @return a boolean indicating whether the action has been unregistered
  26024. */
  26025. abstract unregisterAction(action: IAction): Boolean;
  26026. /**
  26027. * Does exist one action manager with at least one trigger
  26028. **/
  26029. static readonly HasTriggers: boolean;
  26030. /**
  26031. * Does exist one action manager with at least one pick trigger
  26032. **/
  26033. static readonly HasPickTriggers: boolean;
  26034. /**
  26035. * Does exist one action manager that handles actions of a given trigger
  26036. * @param trigger defines the trigger to be tested
  26037. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  26038. **/
  26039. static HasSpecificTrigger(trigger: number): boolean;
  26040. }
  26041. }
  26042. declare module BABYLON {
  26043. /**
  26044. * Defines how a node can be built from a string name.
  26045. */
  26046. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  26047. /**
  26048. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  26049. */
  26050. export class Node implements IBehaviorAware<Node> {
  26051. /** @hidden */ private static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  26052. private static _NodeConstructors;
  26053. /**
  26054. * Add a new node constructor
  26055. * @param type defines the type name of the node to construct
  26056. * @param constructorFunc defines the constructor function
  26057. */
  26058. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  26059. /**
  26060. * Returns a node constructor based on type name
  26061. * @param type defines the type name
  26062. * @param name defines the new node name
  26063. * @param scene defines the hosting scene
  26064. * @param options defines optional options to transmit to constructors
  26065. * @returns the new constructor or null
  26066. */
  26067. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  26068. /**
  26069. * Gets or sets the name of the node
  26070. */
  26071. name: string;
  26072. /**
  26073. * Gets or sets the id of the node
  26074. */
  26075. id: string;
  26076. /**
  26077. * Gets or sets the unique id of the node
  26078. */
  26079. uniqueId: number;
  26080. /**
  26081. * Gets or sets a string used to store user defined state for the node
  26082. */
  26083. state: string;
  26084. /**
  26085. * Gets or sets an object used to store user defined information for the node
  26086. */
  26087. metadata: any;
  26088. /**
  26089. * For internal use only. Please do not use.
  26090. */
  26091. reservedDataStore: any;
  26092. /**
  26093. * List of inspectable custom properties (used by the Inspector)
  26094. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  26095. */
  26096. inspectableCustomProperties: IInspectable[];
  26097. /**
  26098. * Gets or sets a boolean used to define if the node must be serialized
  26099. */
  26100. doNotSerialize: boolean;
  26101. /** @hidden */ private _isDisposed: boolean;
  26102. /**
  26103. * Gets a list of Animations associated with the node
  26104. */
  26105. animations: Animation[];
  26106. protected _ranges: {
  26107. [name: string]: Nullable<AnimationRange>;
  26108. };
  26109. /**
  26110. * Callback raised when the node is ready to be used
  26111. */
  26112. onReady: Nullable<(node: Node) => void>;
  26113. private _isEnabled;
  26114. private _isParentEnabled;
  26115. private _isReady;
  26116. /** @hidden */ private _currentRenderId: number;
  26117. private _parentUpdateId;
  26118. /** @hidden */ private _childUpdateId: number;
  26119. /** @hidden */ private _waitingParentId: Nullable<string>;
  26120. /** @hidden */ private _scene: Scene;
  26121. /** @hidden */ private _cache: any;
  26122. private _parentNode;
  26123. private _children;
  26124. /** @hidden */ private _worldMatrix: Matrix;
  26125. /** @hidden */ private _worldMatrixDeterminant: number;
  26126. /** @hidden */ private _worldMatrixDeterminantIsDirty: boolean;
  26127. /** @hidden */
  26128. private _sceneRootNodesIndex;
  26129. /**
  26130. * Gets a boolean indicating if the node has been disposed
  26131. * @returns true if the node was disposed
  26132. */
  26133. isDisposed(): boolean;
  26134. /**
  26135. * Gets or sets the parent of the node (without keeping the current position in the scene)
  26136. * @see https://doc.babylonjs.com/how_to/parenting
  26137. */
  26138. parent: Nullable<Node>;
  26139. private addToSceneRootNodes;
  26140. private removeFromSceneRootNodes;
  26141. private _animationPropertiesOverride;
  26142. /**
  26143. * Gets or sets the animation properties override
  26144. */
  26145. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  26146. /**
  26147. * Gets a string idenfifying the name of the class
  26148. * @returns "Node" string
  26149. */
  26150. getClassName(): string;
  26151. /** @hidden */ protected readonly _isNode: boolean;
  26152. /**
  26153. * An event triggered when the mesh is disposed
  26154. */
  26155. onDisposeObservable: Observable<Node>;
  26156. private _onDisposeObserver;
  26157. /**
  26158. * Sets a callback that will be raised when the node will be disposed
  26159. */
  26160. onDispose: () => void;
  26161. /**
  26162. * Creates a new Node
  26163. * @param name the name and id to be given to this node
  26164. * @param scene the scene this node will be added to
  26165. * @param addToRootNodes the node will be added to scene.rootNodes
  26166. */
  26167. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  26168. /**
  26169. * Gets the scene of the node
  26170. * @returns a scene
  26171. */
  26172. getScene(): Scene;
  26173. /**
  26174. * Gets the engine of the node
  26175. * @returns a Engine
  26176. */
  26177. getEngine(): Engine;
  26178. private _behaviors;
  26179. /**
  26180. * Attach a behavior to the node
  26181. * @see http://doc.babylonjs.com/features/behaviour
  26182. * @param behavior defines the behavior to attach
  26183. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  26184. * @returns the current Node
  26185. */
  26186. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  26187. /**
  26188. * Remove an attached behavior
  26189. * @see http://doc.babylonjs.com/features/behaviour
  26190. * @param behavior defines the behavior to attach
  26191. * @returns the current Node
  26192. */
  26193. removeBehavior(behavior: Behavior<Node>): Node;
  26194. /**
  26195. * Gets the list of attached behaviors
  26196. * @see http://doc.babylonjs.com/features/behaviour
  26197. */
  26198. readonly behaviors: Behavior<Node>[];
  26199. /**
  26200. * Gets an attached behavior by name
  26201. * @param name defines the name of the behavior to look for
  26202. * @see http://doc.babylonjs.com/features/behaviour
  26203. * @returns null if behavior was not found else the requested behavior
  26204. */
  26205. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  26206. /**
  26207. * Returns the latest update of the World matrix
  26208. * @returns a Matrix
  26209. */
  26210. getWorldMatrix(): Matrix;
  26211. /** @hidden */ private _getWorldMatrixDeterminant(): number;
  26212. /**
  26213. * Returns directly the latest state of the mesh World matrix.
  26214. * A Matrix is returned.
  26215. */
  26216. readonly worldMatrixFromCache: Matrix;
  26217. /** @hidden */ private _initCache(): void;
  26218. /** @hidden */
  26219. updateCache(force?: boolean): void;
  26220. /** @hidden */ private _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26221. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  26222. /** @hidden */ private _isSynchronized(): boolean;
  26223. /** @hidden */ private _markSyncedWithParent(): void;
  26224. /** @hidden */
  26225. isSynchronizedWithParent(): boolean;
  26226. /** @hidden */
  26227. isSynchronized(): boolean;
  26228. /**
  26229. * Is this node ready to be used/rendered
  26230. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  26231. * @return true if the node is ready
  26232. */
  26233. isReady(completeCheck?: boolean): boolean;
  26234. /**
  26235. * Is this node enabled?
  26236. * 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
  26237. * @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
  26238. * @return whether this node (and its parent) is enabled
  26239. */
  26240. isEnabled(checkAncestors?: boolean): boolean;
  26241. /** @hidden */
  26242. protected _syncParentEnabledState(): void;
  26243. /**
  26244. * Set the enabled state of this node
  26245. * @param value defines the new enabled state
  26246. */
  26247. setEnabled(value: boolean): void;
  26248. /**
  26249. * Is this node a descendant of the given node?
  26250. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  26251. * @param ancestor defines the parent node to inspect
  26252. * @returns a boolean indicating if this node is a descendant of the given node
  26253. */
  26254. isDescendantOf(ancestor: Node): boolean;
  26255. /** @hidden */ private _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  26256. /**
  26257. * Will return all nodes that have this node as ascendant
  26258. * @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
  26259. * @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
  26260. * @return all children nodes of all types
  26261. */
  26262. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  26263. /**
  26264. * Get all child-meshes of this node
  26265. * @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)
  26266. * @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
  26267. * @returns an array of AbstractMesh
  26268. */
  26269. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  26270. /**
  26271. * Get all direct children of this node
  26272. * @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
  26273. * @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)
  26274. * @returns an array of Node
  26275. */
  26276. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  26277. /** @hidden */ private _setReady(state: boolean): void;
  26278. /**
  26279. * Get an animation by name
  26280. * @param name defines the name of the animation to look for
  26281. * @returns null if not found else the requested animation
  26282. */
  26283. getAnimationByName(name: string): Nullable<Animation>;
  26284. /**
  26285. * Creates an animation range for this node
  26286. * @param name defines the name of the range
  26287. * @param from defines the starting key
  26288. * @param to defines the end key
  26289. */
  26290. createAnimationRange(name: string, from: number, to: number): void;
  26291. /**
  26292. * Delete a specific animation range
  26293. * @param name defines the name of the range to delete
  26294. * @param deleteFrames defines if animation frames from the range must be deleted as well
  26295. */
  26296. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  26297. /**
  26298. * Get an animation range by name
  26299. * @param name defines the name of the animation range to look for
  26300. * @returns null if not found else the requested animation range
  26301. */
  26302. getAnimationRange(name: string): Nullable<AnimationRange>;
  26303. /**
  26304. * Gets the list of all animation ranges defined on this node
  26305. * @returns an array
  26306. */
  26307. getAnimationRanges(): Nullable<AnimationRange>[];
  26308. /**
  26309. * Will start the animation sequence
  26310. * @param name defines the range frames for animation sequence
  26311. * @param loop defines if the animation should loop (false by default)
  26312. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  26313. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  26314. * @returns the object created for this animation. If range does not exist, it will return null
  26315. */
  26316. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  26317. /**
  26318. * Serialize animation ranges into a JSON compatible object
  26319. * @returns serialization object
  26320. */
  26321. serializeAnimationRanges(): any;
  26322. /**
  26323. * Computes the world matrix of the node
  26324. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  26325. * @returns the world matrix
  26326. */
  26327. computeWorldMatrix(force?: boolean): Matrix;
  26328. /**
  26329. * Releases resources associated with this node.
  26330. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  26331. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  26332. */
  26333. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  26334. /**
  26335. * Parse animation range data from a serialization object and store them into a given node
  26336. * @param node defines where to store the animation ranges
  26337. * @param parsedNode defines the serialization object to read data from
  26338. * @param scene defines the hosting scene
  26339. */
  26340. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  26341. /**
  26342. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  26343. * @param includeDescendants Include bounding info from descendants as well (true by default)
  26344. * @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
  26345. * @returns the new bounding vectors
  26346. */
  26347. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  26348. min: Vector3;
  26349. max: Vector3;
  26350. };
  26351. }
  26352. }
  26353. declare module BABYLON {
  26354. /**
  26355. * @hidden
  26356. */
  26357. export class _IAnimationState {
  26358. key: number;
  26359. repeatCount: number;
  26360. workValue?: any;
  26361. loopMode?: number;
  26362. offsetValue?: any;
  26363. highLimitValue?: any;
  26364. }
  26365. /**
  26366. * Class used to store any kind of animation
  26367. */
  26368. export class Animation {
  26369. /**Name of the animation */
  26370. name: string;
  26371. /**Property to animate */
  26372. targetProperty: string;
  26373. /**The frames per second of the animation */
  26374. framePerSecond: number;
  26375. /**The data type of the animation */
  26376. dataType: number;
  26377. /**The loop mode of the animation */
  26378. loopMode?: number | undefined;
  26379. /**Specifies if blending should be enabled */
  26380. enableBlending?: boolean | undefined;
  26381. /**
  26382. * Use matrix interpolation instead of using direct key value when animating matrices
  26383. */
  26384. static AllowMatricesInterpolation: boolean;
  26385. /**
  26386. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  26387. */
  26388. static AllowMatrixDecomposeForInterpolation: boolean;
  26389. /**
  26390. * Stores the key frames of the animation
  26391. */
  26392. private _keys;
  26393. /**
  26394. * Stores the easing function of the animation
  26395. */
  26396. private _easingFunction;
  26397. /**
  26398. * @hidden Internal use only
  26399. */ private _runtimeAnimations: RuntimeAnimation[];
  26400. /**
  26401. * The set of event that will be linked to this animation
  26402. */
  26403. private _events;
  26404. /**
  26405. * Stores an array of target property paths
  26406. */
  26407. targetPropertyPath: string[];
  26408. /**
  26409. * Stores the blending speed of the animation
  26410. */
  26411. blendingSpeed: number;
  26412. /**
  26413. * Stores the animation ranges for the animation
  26414. */
  26415. private _ranges;
  26416. /**
  26417. * @hidden Internal use
  26418. */ private static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  26419. /**
  26420. * Sets up an animation
  26421. * @param property The property to animate
  26422. * @param animationType The animation type to apply
  26423. * @param framePerSecond The frames per second of the animation
  26424. * @param easingFunction The easing function used in the animation
  26425. * @returns The created animation
  26426. */
  26427. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  26428. /**
  26429. * Create and start an animation on a node
  26430. * @param name defines the name of the global animation that will be run on all nodes
  26431. * @param node defines the root node where the animation will take place
  26432. * @param targetProperty defines property to animate
  26433. * @param framePerSecond defines the number of frame per second yo use
  26434. * @param totalFrame defines the number of frames in total
  26435. * @param from defines the initial value
  26436. * @param to defines the final value
  26437. * @param loopMode defines which loop mode you want to use (off by default)
  26438. * @param easingFunction defines the easing function to use (linear by default)
  26439. * @param onAnimationEnd defines the callback to call when animation end
  26440. * @returns the animatable created for this animation
  26441. */
  26442. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26443. /**
  26444. * Create and start an animation on a node and its descendants
  26445. * @param name defines the name of the global animation that will be run on all nodes
  26446. * @param node defines the root node where the animation will take place
  26447. * @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
  26448. * @param targetProperty defines property to animate
  26449. * @param framePerSecond defines the number of frame per second to use
  26450. * @param totalFrame defines the number of frames in total
  26451. * @param from defines the initial value
  26452. * @param to defines the final value
  26453. * @param loopMode defines which loop mode you want to use (off by default)
  26454. * @param easingFunction defines the easing function to use (linear by default)
  26455. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26456. * @returns the list of animatables created for all nodes
  26457. * @example https://www.babylonjs-playground.com/#MH0VLI
  26458. */
  26459. 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[]>;
  26460. /**
  26461. * Creates a new animation, merges it with the existing animations and starts it
  26462. * @param name Name of the animation
  26463. * @param node Node which contains the scene that begins the animations
  26464. * @param targetProperty Specifies which property to animate
  26465. * @param framePerSecond The frames per second of the animation
  26466. * @param totalFrame The total number of frames
  26467. * @param from The frame at the beginning of the animation
  26468. * @param to The frame at the end of the animation
  26469. * @param loopMode Specifies the loop mode of the animation
  26470. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26471. * @param onAnimationEnd Callback to run once the animation is complete
  26472. * @returns Nullable animation
  26473. */
  26474. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26475. /**
  26476. * Transition property of an host to the target Value
  26477. * @param property The property to transition
  26478. * @param targetValue The target Value of the property
  26479. * @param host The object where the property to animate belongs
  26480. * @param scene Scene used to run the animation
  26481. * @param frameRate Framerate (in frame/s) to use
  26482. * @param transition The transition type we want to use
  26483. * @param duration The duration of the animation, in milliseconds
  26484. * @param onAnimationEnd Callback trigger at the end of the animation
  26485. * @returns Nullable animation
  26486. */
  26487. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26488. /**
  26489. * Return the array of runtime animations currently using this animation
  26490. */
  26491. readonly runtimeAnimations: RuntimeAnimation[];
  26492. /**
  26493. * Specifies if any of the runtime animations are currently running
  26494. */
  26495. readonly hasRunningRuntimeAnimations: boolean;
  26496. /**
  26497. * Initializes the animation
  26498. * @param name Name of the animation
  26499. * @param targetProperty Property to animate
  26500. * @param framePerSecond The frames per second of the animation
  26501. * @param dataType The data type of the animation
  26502. * @param loopMode The loop mode of the animation
  26503. * @param enableBlending Specifies if blending should be enabled
  26504. */
  26505. constructor(
  26506. /**Name of the animation */
  26507. name: string,
  26508. /**Property to animate */
  26509. targetProperty: string,
  26510. /**The frames per second of the animation */
  26511. framePerSecond: number,
  26512. /**The data type of the animation */
  26513. dataType: number,
  26514. /**The loop mode of the animation */
  26515. loopMode?: number | undefined,
  26516. /**Specifies if blending should be enabled */
  26517. enableBlending?: boolean | undefined);
  26518. /**
  26519. * Converts the animation to a string
  26520. * @param fullDetails support for multiple levels of logging within scene loading
  26521. * @returns String form of the animation
  26522. */
  26523. toString(fullDetails?: boolean): string;
  26524. /**
  26525. * Add an event to this animation
  26526. * @param event Event to add
  26527. */
  26528. addEvent(event: AnimationEvent): void;
  26529. /**
  26530. * Remove all events found at the given frame
  26531. * @param frame The frame to remove events from
  26532. */
  26533. removeEvents(frame: number): void;
  26534. /**
  26535. * Retrieves all the events from the animation
  26536. * @returns Events from the animation
  26537. */
  26538. getEvents(): AnimationEvent[];
  26539. /**
  26540. * Creates an animation range
  26541. * @param name Name of the animation range
  26542. * @param from Starting frame of the animation range
  26543. * @param to Ending frame of the animation
  26544. */
  26545. createRange(name: string, from: number, to: number): void;
  26546. /**
  26547. * Deletes an animation range by name
  26548. * @param name Name of the animation range to delete
  26549. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26550. */
  26551. deleteRange(name: string, deleteFrames?: boolean): void;
  26552. /**
  26553. * Gets the animation range by name, or null if not defined
  26554. * @param name Name of the animation range
  26555. * @returns Nullable animation range
  26556. */
  26557. getRange(name: string): Nullable<AnimationRange>;
  26558. /**
  26559. * Gets the key frames from the animation
  26560. * @returns The key frames of the animation
  26561. */
  26562. getKeys(): Array<IAnimationKey>;
  26563. /**
  26564. * Gets the highest frame rate of the animation
  26565. * @returns Highest frame rate of the animation
  26566. */
  26567. getHighestFrame(): number;
  26568. /**
  26569. * Gets the easing function of the animation
  26570. * @returns Easing function of the animation
  26571. */
  26572. getEasingFunction(): IEasingFunction;
  26573. /**
  26574. * Sets the easing function of the animation
  26575. * @param easingFunction A custom mathematical formula for animation
  26576. */
  26577. setEasingFunction(easingFunction: EasingFunction): void;
  26578. /**
  26579. * Interpolates a scalar linearly
  26580. * @param startValue Start value of the animation curve
  26581. * @param endValue End value of the animation curve
  26582. * @param gradient Scalar amount to interpolate
  26583. * @returns Interpolated scalar value
  26584. */
  26585. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26586. /**
  26587. * Interpolates a scalar cubically
  26588. * @param startValue Start value of the animation curve
  26589. * @param outTangent End tangent of the animation
  26590. * @param endValue End value of the animation curve
  26591. * @param inTangent Start tangent of the animation curve
  26592. * @param gradient Scalar amount to interpolate
  26593. * @returns Interpolated scalar value
  26594. */
  26595. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26596. /**
  26597. * Interpolates a quaternion using a spherical linear interpolation
  26598. * @param startValue Start value of the animation curve
  26599. * @param endValue End value of the animation curve
  26600. * @param gradient Scalar amount to interpolate
  26601. * @returns Interpolated quaternion value
  26602. */
  26603. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26604. /**
  26605. * Interpolates a quaternion cubically
  26606. * @param startValue Start value of the animation curve
  26607. * @param outTangent End tangent of the animation curve
  26608. * @param endValue End value of the animation curve
  26609. * @param inTangent Start tangent of the animation curve
  26610. * @param gradient Scalar amount to interpolate
  26611. * @returns Interpolated quaternion value
  26612. */
  26613. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26614. /**
  26615. * Interpolates a Vector3 linearl
  26616. * @param startValue Start value of the animation curve
  26617. * @param endValue End value of the animation curve
  26618. * @param gradient Scalar amount to interpolate
  26619. * @returns Interpolated scalar value
  26620. */
  26621. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26622. /**
  26623. * Interpolates a Vector3 cubically
  26624. * @param startValue Start value of the animation curve
  26625. * @param outTangent End tangent of the animation
  26626. * @param endValue End value of the animation curve
  26627. * @param inTangent Start tangent of the animation curve
  26628. * @param gradient Scalar amount to interpolate
  26629. * @returns InterpolatedVector3 value
  26630. */
  26631. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26632. /**
  26633. * Interpolates a Vector2 linearly
  26634. * @param startValue Start value of the animation curve
  26635. * @param endValue End value of the animation curve
  26636. * @param gradient Scalar amount to interpolate
  26637. * @returns Interpolated Vector2 value
  26638. */
  26639. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26640. /**
  26641. * Interpolates a Vector2 cubically
  26642. * @param startValue Start value of the animation curve
  26643. * @param outTangent End tangent of the animation
  26644. * @param endValue End value of the animation curve
  26645. * @param inTangent Start tangent of the animation curve
  26646. * @param gradient Scalar amount to interpolate
  26647. * @returns Interpolated Vector2 value
  26648. */
  26649. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26650. /**
  26651. * Interpolates a size linearly
  26652. * @param startValue Start value of the animation curve
  26653. * @param endValue End value of the animation curve
  26654. * @param gradient Scalar amount to interpolate
  26655. * @returns Interpolated Size value
  26656. */
  26657. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26658. /**
  26659. * Interpolates a Color3 linearly
  26660. * @param startValue Start value of the animation curve
  26661. * @param endValue End value of the animation curve
  26662. * @param gradient Scalar amount to interpolate
  26663. * @returns Interpolated Color3 value
  26664. */
  26665. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26666. /**
  26667. * @hidden Internal use only
  26668. */ private _getKeyValue(value: any): any;
  26669. /**
  26670. * @hidden Internal use only
  26671. */ private _interpolate(currentFrame: number, state: _IAnimationState): any;
  26672. /**
  26673. * Defines the function to use to interpolate matrices
  26674. * @param startValue defines the start matrix
  26675. * @param endValue defines the end matrix
  26676. * @param gradient defines the gradient between both matrices
  26677. * @param result defines an optional target matrix where to store the interpolation
  26678. * @returns the interpolated matrix
  26679. */
  26680. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26681. /**
  26682. * Makes a copy of the animation
  26683. * @returns Cloned animation
  26684. */
  26685. clone(): Animation;
  26686. /**
  26687. * Sets the key frames of the animation
  26688. * @param values The animation key frames to set
  26689. */
  26690. setKeys(values: Array<IAnimationKey>): void;
  26691. /**
  26692. * Serializes the animation to an object
  26693. * @returns Serialized object
  26694. */
  26695. serialize(): any;
  26696. /**
  26697. * Float animation type
  26698. */
  26699. private static _ANIMATIONTYPE_FLOAT;
  26700. /**
  26701. * Vector3 animation type
  26702. */
  26703. private static _ANIMATIONTYPE_VECTOR3;
  26704. /**
  26705. * Quaternion animation type
  26706. */
  26707. private static _ANIMATIONTYPE_QUATERNION;
  26708. /**
  26709. * Matrix animation type
  26710. */
  26711. private static _ANIMATIONTYPE_MATRIX;
  26712. /**
  26713. * Color3 animation type
  26714. */
  26715. private static _ANIMATIONTYPE_COLOR3;
  26716. /**
  26717. * Vector2 animation type
  26718. */
  26719. private static _ANIMATIONTYPE_VECTOR2;
  26720. /**
  26721. * Size animation type
  26722. */
  26723. private static _ANIMATIONTYPE_SIZE;
  26724. /**
  26725. * Relative Loop Mode
  26726. */
  26727. private static _ANIMATIONLOOPMODE_RELATIVE;
  26728. /**
  26729. * Cycle Loop Mode
  26730. */
  26731. private static _ANIMATIONLOOPMODE_CYCLE;
  26732. /**
  26733. * Constant Loop Mode
  26734. */
  26735. private static _ANIMATIONLOOPMODE_CONSTANT;
  26736. /**
  26737. * Get the float animation type
  26738. */
  26739. static readonly ANIMATIONTYPE_FLOAT: number;
  26740. /**
  26741. * Get the Vector3 animation type
  26742. */
  26743. static readonly ANIMATIONTYPE_VECTOR3: number;
  26744. /**
  26745. * Get the Vector2 animation type
  26746. */
  26747. static readonly ANIMATIONTYPE_VECTOR2: number;
  26748. /**
  26749. * Get the Size animation type
  26750. */
  26751. static readonly ANIMATIONTYPE_SIZE: number;
  26752. /**
  26753. * Get the Quaternion animation type
  26754. */
  26755. static readonly ANIMATIONTYPE_QUATERNION: number;
  26756. /**
  26757. * Get the Matrix animation type
  26758. */
  26759. static readonly ANIMATIONTYPE_MATRIX: number;
  26760. /**
  26761. * Get the Color3 animation type
  26762. */
  26763. static readonly ANIMATIONTYPE_COLOR3: number;
  26764. /**
  26765. * Get the Relative Loop Mode
  26766. */
  26767. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26768. /**
  26769. * Get the Cycle Loop Mode
  26770. */
  26771. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26772. /**
  26773. * Get the Constant Loop Mode
  26774. */
  26775. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26776. /** @hidden */ private static _UniversalLerp(left: any, right: any, amount: number): any;
  26777. /**
  26778. * Parses an animation object and creates an animation
  26779. * @param parsedAnimation Parsed animation object
  26780. * @returns Animation object
  26781. */
  26782. static Parse(parsedAnimation: any): Animation;
  26783. /**
  26784. * Appends the serialized animations from the source animations
  26785. * @param source Source containing the animations
  26786. * @param destination Target to store the animations
  26787. */
  26788. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26789. }
  26790. }
  26791. declare module BABYLON {
  26792. /**
  26793. * Interface containing an array of animations
  26794. */
  26795. export interface IAnimatable {
  26796. /**
  26797. * Array of animations
  26798. */
  26799. animations: Nullable<Array<Animation>>;
  26800. }
  26801. }
  26802. declare module BABYLON {
  26803. /**
  26804. * This represents all the required information to add a fresnel effect on a material:
  26805. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  26806. */
  26807. export class FresnelParameters {
  26808. private _isEnabled;
  26809. /**
  26810. * Define if the fresnel effect is enable or not.
  26811. */
  26812. isEnabled: boolean;
  26813. /**
  26814. * Define the color used on edges (grazing angle)
  26815. */
  26816. leftColor: Color3;
  26817. /**
  26818. * Define the color used on center
  26819. */
  26820. rightColor: Color3;
  26821. /**
  26822. * Define bias applied to computed fresnel term
  26823. */
  26824. bias: number;
  26825. /**
  26826. * Defined the power exponent applied to fresnel term
  26827. */
  26828. power: number;
  26829. /**
  26830. * Clones the current fresnel and its valuues
  26831. * @returns a clone fresnel configuration
  26832. */
  26833. clone(): FresnelParameters;
  26834. /**
  26835. * Serializes the current fresnel parameters to a JSON representation.
  26836. * @return the JSON serialization
  26837. */
  26838. serialize(): any;
  26839. /**
  26840. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  26841. * @param parsedFresnelParameters Define the JSON representation
  26842. * @returns the parsed parameters
  26843. */
  26844. static Parse(parsedFresnelParameters: any): FresnelParameters;
  26845. }
  26846. }
  26847. declare module BABYLON {
  26848. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  26849. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26850. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26851. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26852. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26853. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26854. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26855. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26856. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26857. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26858. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26859. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26860. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26861. /**
  26862. * Decorator used to define property that can be serialized as reference to a camera
  26863. * @param sourceName defines the name of the property to decorate
  26864. */
  26865. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  26866. /**
  26867. * Class used to help serialization objects
  26868. */
  26869. export class SerializationHelper {
  26870. /** @hidden */ private static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  26871. /** @hidden */ private static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  26872. /** @hidden */ private static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  26873. /** @hidden */ private static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  26874. /**
  26875. * Appends the serialized animations from the source animations
  26876. * @param source Source containing the animations
  26877. * @param destination Target to store the animations
  26878. */
  26879. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26880. /**
  26881. * Static function used to serialized a specific entity
  26882. * @param entity defines the entity to serialize
  26883. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  26884. * @returns a JSON compatible object representing the serialization of the entity
  26885. */
  26886. static Serialize<T>(entity: T, serializationObject?: any): any;
  26887. /**
  26888. * Creates a new entity from a serialization data object
  26889. * @param creationFunction defines a function used to instanciated the new entity
  26890. * @param source defines the source serialization data
  26891. * @param scene defines the hosting scene
  26892. * @param rootUrl defines the root url for resources
  26893. * @returns a new entity
  26894. */
  26895. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  26896. /**
  26897. * Clones an object
  26898. * @param creationFunction defines the function used to instanciate the new object
  26899. * @param source defines the source object
  26900. * @returns the cloned object
  26901. */
  26902. static Clone<T>(creationFunction: () => T, source: T): T;
  26903. /**
  26904. * Instanciates a new object based on a source one (some data will be shared between both object)
  26905. * @param creationFunction defines the function used to instanciate the new object
  26906. * @param source defines the source object
  26907. * @returns the new object
  26908. */
  26909. static Instanciate<T>(creationFunction: () => T, source: T): T;
  26910. }
  26911. }
  26912. declare module BABYLON {
  26913. /**
  26914. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  26915. */
  26916. export interface CubeMapInfo {
  26917. /**
  26918. * The pixel array for the front face.
  26919. * This is stored in format, left to right, up to down format.
  26920. */
  26921. front: Nullable<ArrayBufferView>;
  26922. /**
  26923. * The pixel array for the back face.
  26924. * This is stored in format, left to right, up to down format.
  26925. */
  26926. back: Nullable<ArrayBufferView>;
  26927. /**
  26928. * The pixel array for the left face.
  26929. * This is stored in format, left to right, up to down format.
  26930. */
  26931. left: Nullable<ArrayBufferView>;
  26932. /**
  26933. * The pixel array for the right face.
  26934. * This is stored in format, left to right, up to down format.
  26935. */
  26936. right: Nullable<ArrayBufferView>;
  26937. /**
  26938. * The pixel array for the up face.
  26939. * This is stored in format, left to right, up to down format.
  26940. */
  26941. up: Nullable<ArrayBufferView>;
  26942. /**
  26943. * The pixel array for the down face.
  26944. * This is stored in format, left to right, up to down format.
  26945. */
  26946. down: Nullable<ArrayBufferView>;
  26947. /**
  26948. * The size of the cubemap stored.
  26949. *
  26950. * Each faces will be size * size pixels.
  26951. */
  26952. size: number;
  26953. /**
  26954. * The format of the texture.
  26955. *
  26956. * RGBA, RGB.
  26957. */
  26958. format: number;
  26959. /**
  26960. * The type of the texture data.
  26961. *
  26962. * UNSIGNED_INT, FLOAT.
  26963. */
  26964. type: number;
  26965. /**
  26966. * Specifies whether the texture is in gamma space.
  26967. */
  26968. gammaSpace: boolean;
  26969. }
  26970. /**
  26971. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  26972. */
  26973. export class PanoramaToCubeMapTools {
  26974. private static FACE_FRONT;
  26975. private static FACE_BACK;
  26976. private static FACE_RIGHT;
  26977. private static FACE_LEFT;
  26978. private static FACE_DOWN;
  26979. private static FACE_UP;
  26980. /**
  26981. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  26982. *
  26983. * @param float32Array The source data.
  26984. * @param inputWidth The width of the input panorama.
  26985. * @param inputHeight The height of the input panorama.
  26986. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  26987. * @return The cubemap data
  26988. */
  26989. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  26990. private static CreateCubemapTexture;
  26991. private static CalcProjectionSpherical;
  26992. }
  26993. }
  26994. declare module BABYLON {
  26995. /**
  26996. * Helper class dealing with the extraction of spherical polynomial dataArray
  26997. * from a cube map.
  26998. */
  26999. export class CubeMapToSphericalPolynomialTools {
  27000. private static FileFaces;
  27001. /**
  27002. * Converts a texture to the according Spherical Polynomial data.
  27003. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27004. *
  27005. * @param texture The texture to extract the information from.
  27006. * @return The Spherical Polynomial data.
  27007. */
  27008. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  27009. /**
  27010. * Converts a cubemap to the according Spherical Polynomial data.
  27011. * This extracts the first 3 orders only as they are the only one used in the lighting.
  27012. *
  27013. * @param cubeInfo The Cube map to extract the information from.
  27014. * @return The Spherical Polynomial data.
  27015. */
  27016. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  27017. }
  27018. }
  27019. declare module BABYLON {
  27020. /**
  27021. * Class used to manipulate GUIDs
  27022. */
  27023. export class GUID {
  27024. /**
  27025. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  27026. * Be aware Math.random() could cause collisions, but:
  27027. * "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"
  27028. * @returns a pseudo random id
  27029. */
  27030. static RandomId(): string;
  27031. }
  27032. }
  27033. declare module BABYLON {
  27034. /**
  27035. * Base class of all the textures in babylon.
  27036. * It groups all the common properties the materials, post process, lights... might need
  27037. * in order to make a correct use of the texture.
  27038. */
  27039. export class BaseTexture implements IAnimatable {
  27040. /**
  27041. * Default anisotropic filtering level for the application.
  27042. * It is set to 4 as a good tradeoff between perf and quality.
  27043. */
  27044. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  27045. /**
  27046. * Gets or sets the unique id of the texture
  27047. */
  27048. uniqueId: number;
  27049. /**
  27050. * Define the name of the texture.
  27051. */
  27052. name: string;
  27053. /**
  27054. * Gets or sets an object used to store user defined information.
  27055. */
  27056. metadata: any;
  27057. /**
  27058. * For internal use only. Please do not use.
  27059. */
  27060. reservedDataStore: any;
  27061. private _hasAlpha;
  27062. /**
  27063. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  27064. */
  27065. hasAlpha: boolean;
  27066. /**
  27067. * Defines if the alpha value should be determined via the rgb values.
  27068. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  27069. */
  27070. getAlphaFromRGB: boolean;
  27071. /**
  27072. * Intensity or strength of the texture.
  27073. * It is commonly used by materials to fine tune the intensity of the texture
  27074. */
  27075. level: number;
  27076. /**
  27077. * Define the UV chanel to use starting from 0 and defaulting to 0.
  27078. * This is part of the texture as textures usually maps to one uv set.
  27079. */
  27080. coordinatesIndex: number;
  27081. private _coordinatesMode;
  27082. /**
  27083. * How a texture is mapped.
  27084. *
  27085. * | Value | Type | Description |
  27086. * | ----- | ----------------------------------- | ----------- |
  27087. * | 0 | EXPLICIT_MODE | |
  27088. * | 1 | SPHERICAL_MODE | |
  27089. * | 2 | PLANAR_MODE | |
  27090. * | 3 | CUBIC_MODE | |
  27091. * | 4 | PROJECTION_MODE | |
  27092. * | 5 | SKYBOX_MODE | |
  27093. * | 6 | INVCUBIC_MODE | |
  27094. * | 7 | EQUIRECTANGULAR_MODE | |
  27095. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  27096. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  27097. */
  27098. coordinatesMode: number;
  27099. /**
  27100. * | Value | Type | Description |
  27101. * | ----- | ------------------ | ----------- |
  27102. * | 0 | CLAMP_ADDRESSMODE | |
  27103. * | 1 | WRAP_ADDRESSMODE | |
  27104. * | 2 | MIRROR_ADDRESSMODE | |
  27105. */
  27106. wrapU: number;
  27107. /**
  27108. * | Value | Type | Description |
  27109. * | ----- | ------------------ | ----------- |
  27110. * | 0 | CLAMP_ADDRESSMODE | |
  27111. * | 1 | WRAP_ADDRESSMODE | |
  27112. * | 2 | MIRROR_ADDRESSMODE | |
  27113. */
  27114. wrapV: number;
  27115. /**
  27116. * | Value | Type | Description |
  27117. * | ----- | ------------------ | ----------- |
  27118. * | 0 | CLAMP_ADDRESSMODE | |
  27119. * | 1 | WRAP_ADDRESSMODE | |
  27120. * | 2 | MIRROR_ADDRESSMODE | |
  27121. */
  27122. wrapR: number;
  27123. /**
  27124. * With compliant hardware and browser (supporting anisotropic filtering)
  27125. * this defines the level of anisotropic filtering in the texture.
  27126. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  27127. */
  27128. anisotropicFilteringLevel: number;
  27129. /**
  27130. * Define if the texture is a cube texture or if false a 2d texture.
  27131. */
  27132. isCube: boolean;
  27133. /**
  27134. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  27135. */
  27136. is3D: boolean;
  27137. /**
  27138. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  27139. * HDR texture are usually stored in linear space.
  27140. * This only impacts the PBR and Background materials
  27141. */
  27142. gammaSpace: boolean;
  27143. /**
  27144. * Gets whether or not the texture contains RGBD data.
  27145. */
  27146. readonly isRGBD: boolean;
  27147. /**
  27148. * Is Z inverted in the texture (useful in a cube texture).
  27149. */
  27150. invertZ: boolean;
  27151. /**
  27152. * Are mip maps generated for this texture or not.
  27153. */
  27154. readonly noMipmap: boolean;
  27155. /**
  27156. * @hidden
  27157. */
  27158. lodLevelInAlpha: boolean;
  27159. /**
  27160. * With prefiltered texture, defined the offset used during the prefiltering steps.
  27161. */
  27162. lodGenerationOffset: number;
  27163. /**
  27164. * With prefiltered texture, defined the scale used during the prefiltering steps.
  27165. */
  27166. lodGenerationScale: number;
  27167. /**
  27168. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  27169. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  27170. * average roughness values.
  27171. */
  27172. linearSpecularLOD: boolean;
  27173. /**
  27174. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  27175. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  27176. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  27177. */
  27178. irradianceTexture: Nullable<BaseTexture>;
  27179. /**
  27180. * Define if the texture is a render target.
  27181. */
  27182. isRenderTarget: boolean;
  27183. /**
  27184. * Define the unique id of the texture in the scene.
  27185. */
  27186. readonly uid: string;
  27187. /**
  27188. * Return a string representation of the texture.
  27189. * @returns the texture as a string
  27190. */
  27191. toString(): string;
  27192. /**
  27193. * Get the class name of the texture.
  27194. * @returns "BaseTexture"
  27195. */
  27196. getClassName(): string;
  27197. /**
  27198. * Define the list of animation attached to the texture.
  27199. */
  27200. animations: Animation[];
  27201. /**
  27202. * An event triggered when the texture is disposed.
  27203. */
  27204. onDisposeObservable: Observable<BaseTexture>;
  27205. private _onDisposeObserver;
  27206. /**
  27207. * Callback triggered when the texture has been disposed.
  27208. * Kept for back compatibility, you can use the onDisposeObservable instead.
  27209. */
  27210. onDispose: () => void;
  27211. /**
  27212. * Define the current state of the loading sequence when in delayed load mode.
  27213. */
  27214. delayLoadState: number;
  27215. private _scene;
  27216. /** @hidden */ private _texture: Nullable<InternalTexture>;
  27217. private _uid;
  27218. /**
  27219. * Define if the texture is preventinga material to render or not.
  27220. * If not and the texture is not ready, the engine will use a default black texture instead.
  27221. */
  27222. readonly isBlocking: boolean;
  27223. /**
  27224. * Instantiates a new BaseTexture.
  27225. * Base class of all the textures in babylon.
  27226. * It groups all the common properties the materials, post process, lights... might need
  27227. * in order to make a correct use of the texture.
  27228. * @param scene Define the scene the texture blongs to
  27229. */
  27230. constructor(scene: Nullable<Scene>);
  27231. /**
  27232. * Get the scene the texture belongs to.
  27233. * @returns the scene or null if undefined
  27234. */
  27235. getScene(): Nullable<Scene>;
  27236. /**
  27237. * Get the texture transform matrix used to offset tile the texture for istance.
  27238. * @returns the transformation matrix
  27239. */
  27240. getTextureMatrix(): Matrix;
  27241. /**
  27242. * Get the texture reflection matrix used to rotate/transform the reflection.
  27243. * @returns the reflection matrix
  27244. */
  27245. getReflectionTextureMatrix(): Matrix;
  27246. /**
  27247. * Get the underlying lower level texture from Babylon.
  27248. * @returns the insternal texture
  27249. */
  27250. getInternalTexture(): Nullable<InternalTexture>;
  27251. /**
  27252. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  27253. * @returns true if ready or not blocking
  27254. */
  27255. isReadyOrNotBlocking(): boolean;
  27256. /**
  27257. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  27258. * @returns true if fully ready
  27259. */
  27260. isReady(): boolean;
  27261. private _cachedSize;
  27262. /**
  27263. * Get the size of the texture.
  27264. * @returns the texture size.
  27265. */
  27266. getSize(): ISize;
  27267. /**
  27268. * Get the base size of the texture.
  27269. * It can be different from the size if the texture has been resized for POT for instance
  27270. * @returns the base size
  27271. */
  27272. getBaseSize(): ISize;
  27273. /**
  27274. * Update the sampling mode of the texture.
  27275. * Default is Trilinear mode.
  27276. *
  27277. * | Value | Type | Description |
  27278. * | ----- | ------------------ | ----------- |
  27279. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  27280. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  27281. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  27282. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  27283. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  27284. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  27285. * | 7 | NEAREST_LINEAR | |
  27286. * | 8 | NEAREST_NEAREST | |
  27287. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  27288. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  27289. * | 11 | LINEAR_LINEAR | |
  27290. * | 12 | LINEAR_NEAREST | |
  27291. *
  27292. * > _mag_: magnification filter (close to the viewer)
  27293. * > _min_: minification filter (far from the viewer)
  27294. * > _mip_: filter used between mip map levels
  27295. *@param samplingMode Define the new sampling mode of the texture
  27296. */
  27297. updateSamplingMode(samplingMode: number): void;
  27298. /**
  27299. * Scales the texture if is `canRescale()`
  27300. * @param ratio the resize factor we want to use to rescale
  27301. */
  27302. scale(ratio: number): void;
  27303. /**
  27304. * Get if the texture can rescale.
  27305. */
  27306. readonly canRescale: boolean;
  27307. /** @hidden */ private _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  27308. /** @hidden */ private _rebuild(): void;
  27309. /**
  27310. * Triggers the load sequence in delayed load mode.
  27311. */
  27312. delayLoad(): void;
  27313. /**
  27314. * Clones the texture.
  27315. * @returns the cloned texture
  27316. */
  27317. clone(): Nullable<BaseTexture>;
  27318. /**
  27319. * Get the texture underlying type (INT, FLOAT...)
  27320. */
  27321. readonly textureType: number;
  27322. /**
  27323. * Get the texture underlying format (RGB, RGBA...)
  27324. */
  27325. readonly textureFormat: number;
  27326. /**
  27327. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  27328. * This will returns an RGBA array buffer containing either in values (0-255) or
  27329. * float values (0-1) depending of the underlying buffer type.
  27330. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  27331. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  27332. * @param buffer defines a user defined buffer to fill with data (can be null)
  27333. * @returns The Array buffer containing the pixels data.
  27334. */
  27335. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  27336. /**
  27337. * Release and destroy the underlying lower level texture aka internalTexture.
  27338. */
  27339. releaseInternalTexture(): void;
  27340. /**
  27341. * Get the polynomial representation of the texture data.
  27342. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  27343. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  27344. */
  27345. sphericalPolynomial: Nullable<SphericalPolynomial>;
  27346. /** @hidden */ protected readonly _lodTextureHigh: Nullable<BaseTexture>;
  27347. /** @hidden */ protected readonly _lodTextureMid: Nullable<BaseTexture>;
  27348. /** @hidden */ protected readonly _lodTextureLow: Nullable<BaseTexture>;
  27349. /**
  27350. * Dispose the texture and release its associated resources.
  27351. */
  27352. dispose(): void;
  27353. /**
  27354. * Serialize the texture into a JSON representation that can be parsed later on.
  27355. * @returns the JSON representation of the texture
  27356. */
  27357. serialize(): any;
  27358. /**
  27359. * Helper function to be called back once a list of texture contains only ready textures.
  27360. * @param textures Define the list of textures to wait for
  27361. * @param callback Define the callback triggered once the entire list will be ready
  27362. */
  27363. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  27364. }
  27365. }
  27366. declare module BABYLON {
  27367. /**
  27368. * Class used to store data associated with WebGL texture data for the engine
  27369. * This class should not be used directly
  27370. */
  27371. export class InternalTexture {
  27372. /** @hidden */ private static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  27373. /**
  27374. * The source of the texture data is unknown
  27375. */
  27376. static DATASOURCE_UNKNOWN: number;
  27377. /**
  27378. * Texture data comes from an URL
  27379. */
  27380. static DATASOURCE_URL: number;
  27381. /**
  27382. * Texture data is only used for temporary storage
  27383. */
  27384. static DATASOURCE_TEMP: number;
  27385. /**
  27386. * Texture data comes from raw data (ArrayBuffer)
  27387. */
  27388. static DATASOURCE_RAW: number;
  27389. /**
  27390. * Texture content is dynamic (video or dynamic texture)
  27391. */
  27392. static DATASOURCE_DYNAMIC: number;
  27393. /**
  27394. * Texture content is generated by rendering to it
  27395. */
  27396. static DATASOURCE_RENDERTARGET: number;
  27397. /**
  27398. * Texture content is part of a multi render target process
  27399. */
  27400. static DATASOURCE_MULTIRENDERTARGET: number;
  27401. /**
  27402. * Texture data comes from a cube data file
  27403. */
  27404. static DATASOURCE_CUBE: number;
  27405. /**
  27406. * Texture data comes from a raw cube data
  27407. */
  27408. static DATASOURCE_CUBERAW: number;
  27409. /**
  27410. * Texture data come from a prefiltered cube data file
  27411. */
  27412. static DATASOURCE_CUBEPREFILTERED: number;
  27413. /**
  27414. * Texture content is raw 3D data
  27415. */
  27416. static DATASOURCE_RAW3D: number;
  27417. /**
  27418. * Texture content is a depth texture
  27419. */
  27420. static DATASOURCE_DEPTHTEXTURE: number;
  27421. /**
  27422. * Texture data comes from a raw cube data encoded with RGBD
  27423. */
  27424. static DATASOURCE_CUBERAW_RGBD: number;
  27425. /**
  27426. * Defines if the texture is ready
  27427. */
  27428. isReady: boolean;
  27429. /**
  27430. * Defines if the texture is a cube texture
  27431. */
  27432. isCube: boolean;
  27433. /**
  27434. * Defines if the texture contains 3D data
  27435. */
  27436. is3D: boolean;
  27437. /**
  27438. * Defines if the texture contains multiview data
  27439. */
  27440. isMultiview: boolean;
  27441. /**
  27442. * Gets the URL used to load this texture
  27443. */
  27444. url: string;
  27445. /**
  27446. * Gets the sampling mode of the texture
  27447. */
  27448. samplingMode: number;
  27449. /**
  27450. * Gets a boolean indicating if the texture needs mipmaps generation
  27451. */
  27452. generateMipMaps: boolean;
  27453. /**
  27454. * Gets the number of samples used by the texture (WebGL2+ only)
  27455. */
  27456. samples: number;
  27457. /**
  27458. * Gets the type of the texture (int, float...)
  27459. */
  27460. type: number;
  27461. /**
  27462. * Gets the format of the texture (RGB, RGBA...)
  27463. */
  27464. format: number;
  27465. /**
  27466. * Observable called when the texture is loaded
  27467. */
  27468. onLoadedObservable: Observable<InternalTexture>;
  27469. /**
  27470. * Gets the width of the texture
  27471. */
  27472. width: number;
  27473. /**
  27474. * Gets the height of the texture
  27475. */
  27476. height: number;
  27477. /**
  27478. * Gets the depth of the texture
  27479. */
  27480. depth: number;
  27481. /**
  27482. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  27483. */
  27484. baseWidth: number;
  27485. /**
  27486. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  27487. */
  27488. baseHeight: number;
  27489. /**
  27490. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  27491. */
  27492. baseDepth: number;
  27493. /**
  27494. * Gets a boolean indicating if the texture is inverted on Y axis
  27495. */
  27496. invertY: boolean;
  27497. /** @hidden */ private _invertVScale: boolean;
  27498. /** @hidden */ private _associatedChannel: number;
  27499. /** @hidden */ private _dataSource: number;
  27500. /** @hidden */ private _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  27501. /** @hidden */ private _bufferView: Nullable<ArrayBufferView>;
  27502. /** @hidden */ private _bufferViewArray: Nullable<ArrayBufferView[]>;
  27503. /** @hidden */ private _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  27504. /** @hidden */ private _size: number;
  27505. /** @hidden */ private _extension: string;
  27506. /** @hidden */ private _files: Nullable<string[]>;
  27507. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  27508. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  27509. /** @hidden */ private _framebuffer: Nullable<WebGLFramebuffer>;
  27510. /** @hidden */ private _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  27511. /** @hidden */ private _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  27512. /** @hidden */ private _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  27513. /** @hidden */ private _attachments: Nullable<number[]>;
  27514. /** @hidden */ private _cachedCoordinatesMode: Nullable<number>;
  27515. /** @hidden */ private _cachedWrapU: Nullable<number>;
  27516. /** @hidden */ private _cachedWrapV: Nullable<number>;
  27517. /** @hidden */ private _cachedWrapR: Nullable<number>;
  27518. /** @hidden */ private _cachedAnisotropicFilteringLevel: Nullable<number>;
  27519. /** @hidden */ private _isDisabled: boolean;
  27520. /** @hidden */ private _compression: Nullable<string>;
  27521. /** @hidden */ private _generateStencilBuffer: boolean;
  27522. /** @hidden */ private _generateDepthBuffer: boolean;
  27523. /** @hidden */ private _comparisonFunction: number;
  27524. /** @hidden */ private _sphericalPolynomial: Nullable<SphericalPolynomial>;
  27525. /** @hidden */ private _lodGenerationScale: number;
  27526. /** @hidden */ private _lodGenerationOffset: number;
  27527. /** @hidden */ private _colorTextureArray: Nullable<WebGLTexture>;
  27528. /** @hidden */ private _depthStencilTextureArray: Nullable<WebGLTexture>;
  27529. /** @hidden */ private _lodTextureHigh: Nullable<BaseTexture>;
  27530. /** @hidden */ private _lodTextureMid: Nullable<BaseTexture>;
  27531. /** @hidden */ private _lodTextureLow: Nullable<BaseTexture>;
  27532. /** @hidden */ private _isRGBD: boolean;
  27533. /** @hidden */ private _linearSpecularLOD: boolean;
  27534. /** @hidden */ private _irradianceTexture: Nullable<BaseTexture>;
  27535. /** @hidden */ private _webGLTexture: Nullable<WebGLTexture>;
  27536. /** @hidden */ private _references: number;
  27537. private _engine;
  27538. /**
  27539. * Gets the Engine the texture belongs to.
  27540. * @returns The babylon engine
  27541. */
  27542. getEngine(): Engine;
  27543. /**
  27544. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  27545. */
  27546. readonly dataSource: number;
  27547. /**
  27548. * Creates a new InternalTexture
  27549. * @param engine defines the engine to use
  27550. * @param dataSource defines the type of data that will be used
  27551. * @param delayAllocation if the texture allocation should be delayed (default: false)
  27552. */
  27553. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  27554. /**
  27555. * Increments the number of references (ie. the number of Texture that point to it)
  27556. */
  27557. incrementReferences(): void;
  27558. /**
  27559. * Change the size of the texture (not the size of the content)
  27560. * @param width defines the new width
  27561. * @param height defines the new height
  27562. * @param depth defines the new depth (1 by default)
  27563. */
  27564. updateSize(width: int, height: int, depth?: int): void;
  27565. /** @hidden */ private _rebuild(): void;
  27566. /** @hidden */ private _swapAndDie(target: InternalTexture): void;
  27567. /**
  27568. * Dispose the current allocated resources
  27569. */
  27570. dispose(): void;
  27571. }
  27572. }
  27573. declare module BABYLON {
  27574. /**
  27575. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  27576. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  27577. */
  27578. export class EffectFallbacks {
  27579. private _defines;
  27580. private _currentRank;
  27581. private _maxRank;
  27582. private _mesh;
  27583. /**
  27584. * Removes the fallback from the bound mesh.
  27585. */
  27586. unBindMesh(): void;
  27587. /**
  27588. * Adds a fallback on the specified property.
  27589. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27590. * @param define The name of the define in the shader
  27591. */
  27592. addFallback(rank: number, define: string): void;
  27593. /**
  27594. * Sets the mesh to use CPU skinning when needing to fallback.
  27595. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  27596. * @param mesh The mesh to use the fallbacks.
  27597. */
  27598. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  27599. /**
  27600. * Checks to see if more fallbacks are still availible.
  27601. */
  27602. readonly isMoreFallbacks: boolean;
  27603. /**
  27604. * Removes the defines that should be removed when falling back.
  27605. * @param currentDefines defines the current define statements for the shader.
  27606. * @param effect defines the current effect we try to compile
  27607. * @returns The resulting defines with defines of the current rank removed.
  27608. */
  27609. reduce(currentDefines: string, effect: Effect): string;
  27610. }
  27611. /**
  27612. * Options to be used when creating an effect.
  27613. */
  27614. export class EffectCreationOptions {
  27615. /**
  27616. * Atrributes that will be used in the shader.
  27617. */
  27618. attributes: string[];
  27619. /**
  27620. * Uniform varible names that will be set in the shader.
  27621. */
  27622. uniformsNames: string[];
  27623. /**
  27624. * Uniform buffer varible names that will be set in the shader.
  27625. */
  27626. uniformBuffersNames: string[];
  27627. /**
  27628. * Sampler texture variable names that will be set in the shader.
  27629. */
  27630. samplers: string[];
  27631. /**
  27632. * Define statements that will be set in the shader.
  27633. */
  27634. defines: any;
  27635. /**
  27636. * Possible fallbacks for this effect to improve performance when needed.
  27637. */
  27638. fallbacks: Nullable<EffectFallbacks>;
  27639. /**
  27640. * Callback that will be called when the shader is compiled.
  27641. */
  27642. onCompiled: Nullable<(effect: Effect) => void>;
  27643. /**
  27644. * Callback that will be called if an error occurs during shader compilation.
  27645. */
  27646. onError: Nullable<(effect: Effect, errors: string) => void>;
  27647. /**
  27648. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27649. */
  27650. indexParameters: any;
  27651. /**
  27652. * Max number of lights that can be used in the shader.
  27653. */
  27654. maxSimultaneousLights: number;
  27655. /**
  27656. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  27657. */
  27658. transformFeedbackVaryings: Nullable<string[]>;
  27659. }
  27660. /**
  27661. * Effect containing vertex and fragment shader that can be executed on an object.
  27662. */
  27663. export class Effect implements IDisposable {
  27664. /**
  27665. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  27666. */
  27667. static ShadersRepository: string;
  27668. /**
  27669. * Name of the effect.
  27670. */
  27671. name: any;
  27672. /**
  27673. * String container all the define statements that should be set on the shader.
  27674. */
  27675. defines: string;
  27676. /**
  27677. * Callback that will be called when the shader is compiled.
  27678. */
  27679. onCompiled: Nullable<(effect: Effect) => void>;
  27680. /**
  27681. * Callback that will be called if an error occurs during shader compilation.
  27682. */
  27683. onError: Nullable<(effect: Effect, errors: string) => void>;
  27684. /**
  27685. * Callback that will be called when effect is bound.
  27686. */
  27687. onBind: Nullable<(effect: Effect) => void>;
  27688. /**
  27689. * Unique ID of the effect.
  27690. */
  27691. uniqueId: number;
  27692. /**
  27693. * Observable that will be called when the shader is compiled.
  27694. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  27695. */
  27696. onCompileObservable: Observable<Effect>;
  27697. /**
  27698. * Observable that will be called if an error occurs during shader compilation.
  27699. */
  27700. onErrorObservable: Observable<Effect>;
  27701. /** @hidden */ private _onBindObservable: Nullable<Observable<Effect>>;
  27702. /**
  27703. * Observable that will be called when effect is bound.
  27704. */
  27705. readonly onBindObservable: Observable<Effect>;
  27706. /** @hidden */ private _bonesComputationForcedToCPU: boolean;
  27707. private static _uniqueIdSeed;
  27708. private _engine;
  27709. private _uniformBuffersNames;
  27710. private _uniformsNames;
  27711. private _samplerList;
  27712. private _samplers;
  27713. private _isReady;
  27714. private _compilationError;
  27715. private _attributesNames;
  27716. private _attributes;
  27717. private _uniforms;
  27718. /**
  27719. * Key for the effect.
  27720. * @hidden
  27721. */ private _key: string;
  27722. private _indexParameters;
  27723. private _fallbacks;
  27724. private _vertexSourceCode;
  27725. private _fragmentSourceCode;
  27726. private _vertexSourceCodeOverride;
  27727. private _fragmentSourceCodeOverride;
  27728. private _transformFeedbackVaryings;
  27729. /**
  27730. * Compiled shader to webGL program.
  27731. * @hidden
  27732. */ private _pipelineContext: Nullable<IPipelineContext>;
  27733. private _valueCache;
  27734. private static _baseCache;
  27735. /**
  27736. * Instantiates an effect.
  27737. * An effect can be used to create/manage/execute vertex and fragment shaders.
  27738. * @param baseName Name of the effect.
  27739. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  27740. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  27741. * @param samplers List of sampler variables that will be passed to the shader.
  27742. * @param engine Engine to be used to render the effect
  27743. * @param defines Define statements to be added to the shader.
  27744. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  27745. * @param onCompiled Callback that will be called when the shader is compiled.
  27746. * @param onError Callback that will be called if an error occurs during shader compilation.
  27747. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  27748. */
  27749. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: Nullable<string[]>, engine?: Engine, defines?: Nullable<string>, fallbacks?: Nullable<EffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  27750. private _useFinalCode;
  27751. /**
  27752. * Unique key for this effect
  27753. */
  27754. readonly key: string;
  27755. /**
  27756. * If the effect has been compiled and prepared.
  27757. * @returns if the effect is compiled and prepared.
  27758. */
  27759. isReady(): boolean;
  27760. /**
  27761. * The engine the effect was initialized with.
  27762. * @returns the engine.
  27763. */
  27764. getEngine(): Engine;
  27765. /**
  27766. * The pipeline context for this effect
  27767. * @returns the associated pipeline context
  27768. */
  27769. getPipelineContext(): Nullable<IPipelineContext>;
  27770. /**
  27771. * The set of names of attribute variables for the shader.
  27772. * @returns An array of attribute names.
  27773. */
  27774. getAttributesNames(): string[];
  27775. /**
  27776. * Returns the attribute at the given index.
  27777. * @param index The index of the attribute.
  27778. * @returns The location of the attribute.
  27779. */
  27780. getAttributeLocation(index: number): number;
  27781. /**
  27782. * Returns the attribute based on the name of the variable.
  27783. * @param name of the attribute to look up.
  27784. * @returns the attribute location.
  27785. */
  27786. getAttributeLocationByName(name: string): number;
  27787. /**
  27788. * The number of attributes.
  27789. * @returns the numnber of attributes.
  27790. */
  27791. getAttributesCount(): number;
  27792. /**
  27793. * Gets the index of a uniform variable.
  27794. * @param uniformName of the uniform to look up.
  27795. * @returns the index.
  27796. */
  27797. getUniformIndex(uniformName: string): number;
  27798. /**
  27799. * Returns the attribute based on the name of the variable.
  27800. * @param uniformName of the uniform to look up.
  27801. * @returns the location of the uniform.
  27802. */
  27803. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  27804. /**
  27805. * Returns an array of sampler variable names
  27806. * @returns The array of sampler variable neames.
  27807. */
  27808. getSamplers(): string[];
  27809. /**
  27810. * The error from the last compilation.
  27811. * @returns the error string.
  27812. */
  27813. getCompilationError(): string;
  27814. /**
  27815. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  27816. * @param func The callback to be used.
  27817. */
  27818. executeWhenCompiled(func: (effect: Effect) => void): void;
  27819. private _checkIsReady;
  27820. /** @hidden */ private _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  27821. /** @hidden */ private _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  27822. /** @hidden */ private _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  27823. /**
  27824. * Recompiles the webGL program
  27825. * @param vertexSourceCode The source code for the vertex shader.
  27826. * @param fragmentSourceCode The source code for the fragment shader.
  27827. * @param onCompiled Callback called when completed.
  27828. * @param onError Callback called on error.
  27829. * @hidden
  27830. */ private _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  27831. /**
  27832. * Prepares the effect
  27833. * @hidden
  27834. */ private _prepareEffect(): void;
  27835. /**
  27836. * Checks if the effect is supported. (Must be called after compilation)
  27837. */
  27838. readonly isSupported: boolean;
  27839. /**
  27840. * Binds a texture to the engine to be used as output of the shader.
  27841. * @param channel Name of the output variable.
  27842. * @param texture Texture to bind.
  27843. * @hidden
  27844. */ private _bindTexture(channel: string, texture: InternalTexture): void;
  27845. /**
  27846. * Sets a texture on the engine to be used in the shader.
  27847. * @param channel Name of the sampler variable.
  27848. * @param texture Texture to set.
  27849. */
  27850. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  27851. /**
  27852. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  27853. * @param channel Name of the sampler variable.
  27854. * @param texture Texture to set.
  27855. */
  27856. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  27857. /**
  27858. * Sets an array of textures on the engine to be used in the shader.
  27859. * @param channel Name of the variable.
  27860. * @param textures Textures to set.
  27861. */
  27862. setTextureArray(channel: string, textures: BaseTexture[]): void;
  27863. /**
  27864. * 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)
  27865. * @param channel Name of the sampler variable.
  27866. * @param postProcess Post process to get the input texture from.
  27867. */
  27868. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  27869. /**
  27870. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  27871. * 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)
  27872. * @param channel Name of the sampler variable.
  27873. * @param postProcess Post process to get the output texture from.
  27874. */
  27875. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  27876. /** @hidden */ private _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  27877. /** @hidden */ private _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  27878. /** @hidden */ private _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  27879. /** @hidden */ private _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  27880. /**
  27881. * Binds a buffer to a uniform.
  27882. * @param buffer Buffer to bind.
  27883. * @param name Name of the uniform variable to bind to.
  27884. */
  27885. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  27886. /**
  27887. * Binds block to a uniform.
  27888. * @param blockName Name of the block to bind.
  27889. * @param index Index to bind.
  27890. */
  27891. bindUniformBlock(blockName: string, index: number): void;
  27892. /**
  27893. * Sets an interger value on a uniform variable.
  27894. * @param uniformName Name of the variable.
  27895. * @param value Value to be set.
  27896. * @returns this effect.
  27897. */
  27898. setInt(uniformName: string, value: number): Effect;
  27899. /**
  27900. * Sets an int array on a uniform variable.
  27901. * @param uniformName Name of the variable.
  27902. * @param array array to be set.
  27903. * @returns this effect.
  27904. */
  27905. setIntArray(uniformName: string, array: Int32Array): Effect;
  27906. /**
  27907. * 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)
  27908. * @param uniformName Name of the variable.
  27909. * @param array array to be set.
  27910. * @returns this effect.
  27911. */
  27912. setIntArray2(uniformName: string, array: Int32Array): Effect;
  27913. /**
  27914. * 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)
  27915. * @param uniformName Name of the variable.
  27916. * @param array array to be set.
  27917. * @returns this effect.
  27918. */
  27919. setIntArray3(uniformName: string, array: Int32Array): Effect;
  27920. /**
  27921. * 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)
  27922. * @param uniformName Name of the variable.
  27923. * @param array array to be set.
  27924. * @returns this effect.
  27925. */
  27926. setIntArray4(uniformName: string, array: Int32Array): Effect;
  27927. /**
  27928. * Sets an float array on a uniform variable.
  27929. * @param uniformName Name of the variable.
  27930. * @param array array to be set.
  27931. * @returns this effect.
  27932. */
  27933. setFloatArray(uniformName: string, array: Float32Array): Effect;
  27934. /**
  27935. * 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)
  27936. * @param uniformName Name of the variable.
  27937. * @param array array to be set.
  27938. * @returns this effect.
  27939. */
  27940. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  27941. /**
  27942. * 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)
  27943. * @param uniformName Name of the variable.
  27944. * @param array array to be set.
  27945. * @returns this effect.
  27946. */
  27947. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  27948. /**
  27949. * 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)
  27950. * @param uniformName Name of the variable.
  27951. * @param array array to be set.
  27952. * @returns this effect.
  27953. */
  27954. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  27955. /**
  27956. * Sets an array on a uniform variable.
  27957. * @param uniformName Name of the variable.
  27958. * @param array array to be set.
  27959. * @returns this effect.
  27960. */
  27961. setArray(uniformName: string, array: number[]): Effect;
  27962. /**
  27963. * 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)
  27964. * @param uniformName Name of the variable.
  27965. * @param array array to be set.
  27966. * @returns this effect.
  27967. */
  27968. setArray2(uniformName: string, array: number[]): Effect;
  27969. /**
  27970. * 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)
  27971. * @param uniformName Name of the variable.
  27972. * @param array array to be set.
  27973. * @returns this effect.
  27974. */
  27975. setArray3(uniformName: string, array: number[]): Effect;
  27976. /**
  27977. * 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)
  27978. * @param uniformName Name of the variable.
  27979. * @param array array to be set.
  27980. * @returns this effect.
  27981. */
  27982. setArray4(uniformName: string, array: number[]): Effect;
  27983. /**
  27984. * Sets matrices on a uniform variable.
  27985. * @param uniformName Name of the variable.
  27986. * @param matrices matrices to be set.
  27987. * @returns this effect.
  27988. */
  27989. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  27990. /**
  27991. * Sets matrix on a uniform variable.
  27992. * @param uniformName Name of the variable.
  27993. * @param matrix matrix to be set.
  27994. * @returns this effect.
  27995. */
  27996. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  27997. /**
  27998. * 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)
  27999. * @param uniformName Name of the variable.
  28000. * @param matrix matrix to be set.
  28001. * @returns this effect.
  28002. */
  28003. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  28004. /**
  28005. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  28006. * @param uniformName Name of the variable.
  28007. * @param matrix matrix to be set.
  28008. * @returns this effect.
  28009. */
  28010. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  28011. /**
  28012. * Sets a float on a uniform variable.
  28013. * @param uniformName Name of the variable.
  28014. * @param value value to be set.
  28015. * @returns this effect.
  28016. */
  28017. setFloat(uniformName: string, value: number): Effect;
  28018. /**
  28019. * Sets a boolean on a uniform variable.
  28020. * @param uniformName Name of the variable.
  28021. * @param bool value to be set.
  28022. * @returns this effect.
  28023. */
  28024. setBool(uniformName: string, bool: boolean): Effect;
  28025. /**
  28026. * Sets a Vector2 on a uniform variable.
  28027. * @param uniformName Name of the variable.
  28028. * @param vector2 vector2 to be set.
  28029. * @returns this effect.
  28030. */
  28031. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  28032. /**
  28033. * Sets a float2 on a uniform variable.
  28034. * @param uniformName Name of the variable.
  28035. * @param x First float in float2.
  28036. * @param y Second float in float2.
  28037. * @returns this effect.
  28038. */
  28039. setFloat2(uniformName: string, x: number, y: number): Effect;
  28040. /**
  28041. * Sets a Vector3 on a uniform variable.
  28042. * @param uniformName Name of the variable.
  28043. * @param vector3 Value to be set.
  28044. * @returns this effect.
  28045. */
  28046. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  28047. /**
  28048. * Sets a float3 on a uniform variable.
  28049. * @param uniformName Name of the variable.
  28050. * @param x First float in float3.
  28051. * @param y Second float in float3.
  28052. * @param z Third float in float3.
  28053. * @returns this effect.
  28054. */
  28055. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  28056. /**
  28057. * Sets a Vector4 on a uniform variable.
  28058. * @param uniformName Name of the variable.
  28059. * @param vector4 Value to be set.
  28060. * @returns this effect.
  28061. */
  28062. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  28063. /**
  28064. * Sets a float4 on a uniform variable.
  28065. * @param uniformName Name of the variable.
  28066. * @param x First float in float4.
  28067. * @param y Second float in float4.
  28068. * @param z Third float in float4.
  28069. * @param w Fourth float in float4.
  28070. * @returns this effect.
  28071. */
  28072. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  28073. /**
  28074. * Sets a Color3 on a uniform variable.
  28075. * @param uniformName Name of the variable.
  28076. * @param color3 Value to be set.
  28077. * @returns this effect.
  28078. */
  28079. setColor3(uniformName: string, color3: IColor3Like): Effect;
  28080. /**
  28081. * Sets a Color4 on a uniform variable.
  28082. * @param uniformName Name of the variable.
  28083. * @param color3 Value to be set.
  28084. * @param alpha Alpha value to be set.
  28085. * @returns this effect.
  28086. */
  28087. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  28088. /**
  28089. * Sets a Color4 on a uniform variable
  28090. * @param uniformName defines the name of the variable
  28091. * @param color4 defines the value to be set
  28092. * @returns this effect.
  28093. */
  28094. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  28095. /** Release all associated resources */
  28096. dispose(): void;
  28097. /**
  28098. * This function will add a new shader to the shader store
  28099. * @param name the name of the shader
  28100. * @param pixelShader optional pixel shader content
  28101. * @param vertexShader optional vertex shader content
  28102. */
  28103. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  28104. /**
  28105. * Store of each shader (The can be looked up using effect.key)
  28106. */
  28107. static ShadersStore: {
  28108. [key: string]: string;
  28109. };
  28110. /**
  28111. * Store of each included file for a shader (The can be looked up using effect.key)
  28112. */
  28113. static IncludesShadersStore: {
  28114. [key: string]: string;
  28115. };
  28116. /**
  28117. * Resets the cache of effects.
  28118. */
  28119. static ResetCache(): void;
  28120. }
  28121. }
  28122. declare module BABYLON {
  28123. /**
  28124. * Uniform buffer objects.
  28125. *
  28126. * Handles blocks of uniform on the GPU.
  28127. *
  28128. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28129. *
  28130. * For more information, please refer to :
  28131. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28132. */
  28133. export class UniformBuffer {
  28134. private _engine;
  28135. private _buffer;
  28136. private _data;
  28137. private _bufferData;
  28138. private _dynamic?;
  28139. private _uniformLocations;
  28140. private _uniformSizes;
  28141. private _uniformLocationPointer;
  28142. private _needSync;
  28143. private _noUBO;
  28144. private _currentEffect;
  28145. private static _MAX_UNIFORM_SIZE;
  28146. private static _tempBuffer;
  28147. /**
  28148. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  28149. * This is dynamic to allow compat with webgl 1 and 2.
  28150. * You will need to pass the name of the uniform as well as the value.
  28151. */
  28152. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  28153. /**
  28154. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  28155. * This is dynamic to allow compat with webgl 1 and 2.
  28156. * You will need to pass the name of the uniform as well as the value.
  28157. */
  28158. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  28159. /**
  28160. * Lambda to Update a single float in a uniform buffer.
  28161. * This is dynamic to allow compat with webgl 1 and 2.
  28162. * You will need to pass the name of the uniform as well as the value.
  28163. */
  28164. updateFloat: (name: string, x: number) => void;
  28165. /**
  28166. * Lambda to Update a vec2 of float in a uniform buffer.
  28167. * This is dynamic to allow compat with webgl 1 and 2.
  28168. * You will need to pass the name of the uniform as well as the value.
  28169. */
  28170. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  28171. /**
  28172. * Lambda to Update a vec3 of float in a uniform buffer.
  28173. * This is dynamic to allow compat with webgl 1 and 2.
  28174. * You will need to pass the name of the uniform as well as the value.
  28175. */
  28176. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  28177. /**
  28178. * Lambda to Update a vec4 of float in a uniform buffer.
  28179. * This is dynamic to allow compat with webgl 1 and 2.
  28180. * You will need to pass the name of the uniform as well as the value.
  28181. */
  28182. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  28183. /**
  28184. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  28185. * This is dynamic to allow compat with webgl 1 and 2.
  28186. * You will need to pass the name of the uniform as well as the value.
  28187. */
  28188. updateMatrix: (name: string, mat: Matrix) => void;
  28189. /**
  28190. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  28191. * This is dynamic to allow compat with webgl 1 and 2.
  28192. * You will need to pass the name of the uniform as well as the value.
  28193. */
  28194. updateVector3: (name: string, vector: Vector3) => void;
  28195. /**
  28196. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  28197. * This is dynamic to allow compat with webgl 1 and 2.
  28198. * You will need to pass the name of the uniform as well as the value.
  28199. */
  28200. updateVector4: (name: string, vector: Vector4) => void;
  28201. /**
  28202. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  28203. * This is dynamic to allow compat with webgl 1 and 2.
  28204. * You will need to pass the name of the uniform as well as the value.
  28205. */
  28206. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  28207. /**
  28208. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  28209. * This is dynamic to allow compat with webgl 1 and 2.
  28210. * You will need to pass the name of the uniform as well as the value.
  28211. */
  28212. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  28213. /**
  28214. * Instantiates a new Uniform buffer objects.
  28215. *
  28216. * Handles blocks of uniform on the GPU.
  28217. *
  28218. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  28219. *
  28220. * For more information, please refer to :
  28221. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  28222. * @param engine Define the engine the buffer is associated with
  28223. * @param data Define the data contained in the buffer
  28224. * @param dynamic Define if the buffer is updatable
  28225. */
  28226. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  28227. /**
  28228. * Indicates if the buffer is using the WebGL2 UBO implementation,
  28229. * or just falling back on setUniformXXX calls.
  28230. */
  28231. readonly useUbo: boolean;
  28232. /**
  28233. * Indicates if the WebGL underlying uniform buffer is in sync
  28234. * with the javascript cache data.
  28235. */
  28236. readonly isSync: boolean;
  28237. /**
  28238. * Indicates if the WebGL underlying uniform buffer is dynamic.
  28239. * Also, a dynamic UniformBuffer will disable cache verification and always
  28240. * update the underlying WebGL uniform buffer to the GPU.
  28241. * @returns if Dynamic, otherwise false
  28242. */
  28243. isDynamic(): boolean;
  28244. /**
  28245. * The data cache on JS side.
  28246. * @returns the underlying data as a float array
  28247. */
  28248. getData(): Float32Array;
  28249. /**
  28250. * The underlying WebGL Uniform buffer.
  28251. * @returns the webgl buffer
  28252. */
  28253. getBuffer(): Nullable<DataBuffer>;
  28254. /**
  28255. * std140 layout specifies how to align data within an UBO structure.
  28256. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  28257. * for specs.
  28258. */
  28259. private _fillAlignment;
  28260. /**
  28261. * Adds an uniform in the buffer.
  28262. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  28263. * for the layout to be correct !
  28264. * @param name Name of the uniform, as used in the uniform block in the shader.
  28265. * @param size Data size, or data directly.
  28266. */
  28267. addUniform(name: string, size: number | number[]): void;
  28268. /**
  28269. * Adds a Matrix 4x4 to the uniform buffer.
  28270. * @param name Name of the uniform, as used in the uniform block in the shader.
  28271. * @param mat A 4x4 matrix.
  28272. */
  28273. addMatrix(name: string, mat: Matrix): void;
  28274. /**
  28275. * Adds a vec2 to the uniform buffer.
  28276. * @param name Name of the uniform, as used in the uniform block in the shader.
  28277. * @param x Define the x component value of the vec2
  28278. * @param y Define the y component value of the vec2
  28279. */
  28280. addFloat2(name: string, x: number, y: number): void;
  28281. /**
  28282. * Adds a vec3 to the uniform buffer.
  28283. * @param name Name of the uniform, as used in the uniform block in the shader.
  28284. * @param x Define the x component value of the vec3
  28285. * @param y Define the y component value of the vec3
  28286. * @param z Define the z component value of the vec3
  28287. */
  28288. addFloat3(name: string, x: number, y: number, z: number): void;
  28289. /**
  28290. * Adds a vec3 to the uniform buffer.
  28291. * @param name Name of the uniform, as used in the uniform block in the shader.
  28292. * @param color Define the vec3 from a Color
  28293. */
  28294. addColor3(name: string, color: Color3): void;
  28295. /**
  28296. * Adds a vec4 to the uniform buffer.
  28297. * @param name Name of the uniform, as used in the uniform block in the shader.
  28298. * @param color Define the rgb components from a Color
  28299. * @param alpha Define the a component of the vec4
  28300. */
  28301. addColor4(name: string, color: Color3, alpha: number): void;
  28302. /**
  28303. * Adds a vec3 to the uniform buffer.
  28304. * @param name Name of the uniform, as used in the uniform block in the shader.
  28305. * @param vector Define the vec3 components from a Vector
  28306. */
  28307. addVector3(name: string, vector: Vector3): void;
  28308. /**
  28309. * Adds a Matrix 3x3 to the uniform buffer.
  28310. * @param name Name of the uniform, as used in the uniform block in the shader.
  28311. */
  28312. addMatrix3x3(name: string): void;
  28313. /**
  28314. * Adds a Matrix 2x2 to the uniform buffer.
  28315. * @param name Name of the uniform, as used in the uniform block in the shader.
  28316. */
  28317. addMatrix2x2(name: string): void;
  28318. /**
  28319. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  28320. */
  28321. create(): void;
  28322. /** @hidden */ private _rebuild(): void;
  28323. /**
  28324. * Updates the WebGL Uniform Buffer on the GPU.
  28325. * If the `dynamic` flag is set to true, no cache comparison is done.
  28326. * Otherwise, the buffer will be updated only if the cache differs.
  28327. */
  28328. update(): void;
  28329. /**
  28330. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  28331. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28332. * @param data Define the flattened data
  28333. * @param size Define the size of the data.
  28334. */
  28335. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  28336. private _valueCache;
  28337. private _cacheMatrix;
  28338. private _updateMatrix3x3ForUniform;
  28339. private _updateMatrix3x3ForEffect;
  28340. private _updateMatrix2x2ForEffect;
  28341. private _updateMatrix2x2ForUniform;
  28342. private _updateFloatForEffect;
  28343. private _updateFloatForUniform;
  28344. private _updateFloat2ForEffect;
  28345. private _updateFloat2ForUniform;
  28346. private _updateFloat3ForEffect;
  28347. private _updateFloat3ForUniform;
  28348. private _updateFloat4ForEffect;
  28349. private _updateFloat4ForUniform;
  28350. private _updateMatrixForEffect;
  28351. private _updateMatrixForUniform;
  28352. private _updateVector3ForEffect;
  28353. private _updateVector3ForUniform;
  28354. private _updateVector4ForEffect;
  28355. private _updateVector4ForUniform;
  28356. private _updateColor3ForEffect;
  28357. private _updateColor3ForUniform;
  28358. private _updateColor4ForEffect;
  28359. private _updateColor4ForUniform;
  28360. /**
  28361. * Sets a sampler uniform on the effect.
  28362. * @param name Define the name of the sampler.
  28363. * @param texture Define the texture to set in the sampler
  28364. */
  28365. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  28366. /**
  28367. * Directly updates the value of the uniform in the cache AND on the GPU.
  28368. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  28369. * @param data Define the flattened data
  28370. */
  28371. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  28372. /**
  28373. * Binds this uniform buffer to an effect.
  28374. * @param effect Define the effect to bind the buffer to
  28375. * @param name Name of the uniform block in the shader.
  28376. */
  28377. bindToEffect(effect: Effect, name: string): void;
  28378. /**
  28379. * Disposes the uniform buffer.
  28380. */
  28381. dispose(): void;
  28382. }
  28383. }
  28384. declare module BABYLON {
  28385. /**
  28386. * Class used to work with sound analyzer using fast fourier transform (FFT)
  28387. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28388. */
  28389. export class Analyser {
  28390. /**
  28391. * Gets or sets the smoothing
  28392. * @ignorenaming
  28393. */
  28394. SMOOTHING: number;
  28395. /**
  28396. * Gets or sets the FFT table size
  28397. * @ignorenaming
  28398. */
  28399. FFT_SIZE: number;
  28400. /**
  28401. * Gets or sets the bar graph amplitude
  28402. * @ignorenaming
  28403. */
  28404. BARGRAPHAMPLITUDE: number;
  28405. /**
  28406. * Gets or sets the position of the debug canvas
  28407. * @ignorenaming
  28408. */
  28409. DEBUGCANVASPOS: {
  28410. x: number;
  28411. y: number;
  28412. };
  28413. /**
  28414. * Gets or sets the debug canvas size
  28415. * @ignorenaming
  28416. */
  28417. DEBUGCANVASSIZE: {
  28418. width: number;
  28419. height: number;
  28420. };
  28421. private _byteFreqs;
  28422. private _byteTime;
  28423. private _floatFreqs;
  28424. private _webAudioAnalyser;
  28425. private _debugCanvas;
  28426. private _debugCanvasContext;
  28427. private _scene;
  28428. private _registerFunc;
  28429. private _audioEngine;
  28430. /**
  28431. * Creates a new analyser
  28432. * @param scene defines hosting scene
  28433. */
  28434. constructor(scene: Scene);
  28435. /**
  28436. * Get the number of data values you will have to play with for the visualization
  28437. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  28438. * @returns a number
  28439. */
  28440. getFrequencyBinCount(): number;
  28441. /**
  28442. * Gets the current frequency data as a byte array
  28443. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28444. * @returns a Uint8Array
  28445. */
  28446. getByteFrequencyData(): Uint8Array;
  28447. /**
  28448. * Gets the current waveform as a byte array
  28449. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  28450. * @returns a Uint8Array
  28451. */
  28452. getByteTimeDomainData(): Uint8Array;
  28453. /**
  28454. * Gets the current frequency data as a float array
  28455. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  28456. * @returns a Float32Array
  28457. */
  28458. getFloatFrequencyData(): Float32Array;
  28459. /**
  28460. * Renders the debug canvas
  28461. */
  28462. drawDebugCanvas(): void;
  28463. /**
  28464. * Stops rendering the debug canvas and removes it
  28465. */
  28466. stopDebugCanvas(): void;
  28467. /**
  28468. * Connects two audio nodes
  28469. * @param inputAudioNode defines first node to connect
  28470. * @param outputAudioNode defines second node to connect
  28471. */
  28472. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  28473. /**
  28474. * Releases all associated resources
  28475. */
  28476. dispose(): void;
  28477. }
  28478. }
  28479. declare module BABYLON {
  28480. /**
  28481. * This represents an audio engine and it is responsible
  28482. * to play, synchronize and analyse sounds throughout the application.
  28483. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28484. */
  28485. export interface IAudioEngine extends IDisposable {
  28486. /**
  28487. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28488. */
  28489. readonly canUseWebAudio: boolean;
  28490. /**
  28491. * Gets the current AudioContext if available.
  28492. */
  28493. readonly audioContext: Nullable<AudioContext>;
  28494. /**
  28495. * The master gain node defines the global audio volume of your audio engine.
  28496. */
  28497. readonly masterGain: GainNode;
  28498. /**
  28499. * Gets whether or not mp3 are supported by your browser.
  28500. */
  28501. readonly isMP3supported: boolean;
  28502. /**
  28503. * Gets whether or not ogg are supported by your browser.
  28504. */
  28505. readonly isOGGsupported: boolean;
  28506. /**
  28507. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28508. * @ignoreNaming
  28509. */
  28510. WarnedWebAudioUnsupported: boolean;
  28511. /**
  28512. * Defines if the audio engine relies on a custom unlocked button.
  28513. * In this case, the embedded button will not be displayed.
  28514. */
  28515. useCustomUnlockedButton: boolean;
  28516. /**
  28517. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  28518. */
  28519. readonly unlocked: boolean;
  28520. /**
  28521. * Event raised when audio has been unlocked on the browser.
  28522. */
  28523. onAudioUnlockedObservable: Observable<AudioEngine>;
  28524. /**
  28525. * Event raised when audio has been locked on the browser.
  28526. */
  28527. onAudioLockedObservable: Observable<AudioEngine>;
  28528. /**
  28529. * Flags the audio engine in Locked state.
  28530. * This happens due to new browser policies preventing audio to autoplay.
  28531. */
  28532. lock(): void;
  28533. /**
  28534. * Unlocks the audio engine once a user action has been done on the dom.
  28535. * This is helpful to resume play once browser policies have been satisfied.
  28536. */
  28537. unlock(): void;
  28538. }
  28539. /**
  28540. * This represents the default audio engine used in babylon.
  28541. * It is responsible to play, synchronize and analyse sounds throughout the application.
  28542. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28543. */
  28544. export class AudioEngine implements IAudioEngine {
  28545. private _audioContext;
  28546. private _audioContextInitialized;
  28547. private _muteButton;
  28548. private _hostElement;
  28549. /**
  28550. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  28551. */
  28552. canUseWebAudio: boolean;
  28553. /**
  28554. * The master gain node defines the global audio volume of your audio engine.
  28555. */
  28556. masterGain: GainNode;
  28557. /**
  28558. * Defines if Babylon should emit a warning if WebAudio is not supported.
  28559. * @ignoreNaming
  28560. */
  28561. WarnedWebAudioUnsupported: boolean;
  28562. /**
  28563. * Gets whether or not mp3 are supported by your browser.
  28564. */
  28565. isMP3supported: boolean;
  28566. /**
  28567. * Gets whether or not ogg are supported by your browser.
  28568. */
  28569. isOGGsupported: boolean;
  28570. /**
  28571. * Gets whether audio has been unlocked on the device.
  28572. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  28573. * a user interaction has happened.
  28574. */
  28575. unlocked: boolean;
  28576. /**
  28577. * Defines if the audio engine relies on a custom unlocked button.
  28578. * In this case, the embedded button will not be displayed.
  28579. */
  28580. useCustomUnlockedButton: boolean;
  28581. /**
  28582. * Event raised when audio has been unlocked on the browser.
  28583. */
  28584. onAudioUnlockedObservable: Observable<AudioEngine>;
  28585. /**
  28586. * Event raised when audio has been locked on the browser.
  28587. */
  28588. onAudioLockedObservable: Observable<AudioEngine>;
  28589. /**
  28590. * Gets the current AudioContext if available.
  28591. */
  28592. readonly audioContext: Nullable<AudioContext>;
  28593. private _connectedAnalyser;
  28594. /**
  28595. * Instantiates a new audio engine.
  28596. *
  28597. * There should be only one per page as some browsers restrict the number
  28598. * of audio contexts you can create.
  28599. * @param hostElement defines the host element where to display the mute icon if necessary
  28600. */
  28601. constructor(hostElement?: Nullable<HTMLElement>);
  28602. /**
  28603. * Flags the audio engine in Locked state.
  28604. * This happens due to new browser policies preventing audio to autoplay.
  28605. */
  28606. lock(): void;
  28607. /**
  28608. * Unlocks the audio engine once a user action has been done on the dom.
  28609. * This is helpful to resume play once browser policies have been satisfied.
  28610. */
  28611. unlock(): void;
  28612. private _resumeAudioContext;
  28613. private _initializeAudioContext;
  28614. private _tryToRun;
  28615. private _triggerRunningState;
  28616. private _triggerSuspendedState;
  28617. private _displayMuteButton;
  28618. private _moveButtonToTopLeft;
  28619. private _onResize;
  28620. private _hideMuteButton;
  28621. /**
  28622. * Destroy and release the resources associated with the audio ccontext.
  28623. */
  28624. dispose(): void;
  28625. /**
  28626. * Gets the global volume sets on the master gain.
  28627. * @returns the global volume if set or -1 otherwise
  28628. */
  28629. getGlobalVolume(): number;
  28630. /**
  28631. * Sets the global volume of your experience (sets on the master gain).
  28632. * @param newVolume Defines the new global volume of the application
  28633. */
  28634. setGlobalVolume(newVolume: number): void;
  28635. /**
  28636. * Connect the audio engine to an audio analyser allowing some amazing
  28637. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  28638. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  28639. * @param analyser The analyser to connect to the engine
  28640. */
  28641. connectToAnalyser(analyser: Analyser): void;
  28642. }
  28643. }
  28644. declare module BABYLON {
  28645. /**
  28646. * Interface used to present a loading screen while loading a scene
  28647. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28648. */
  28649. export interface ILoadingScreen {
  28650. /**
  28651. * Function called to display the loading screen
  28652. */
  28653. displayLoadingUI: () => void;
  28654. /**
  28655. * Function called to hide the loading screen
  28656. */
  28657. hideLoadingUI: () => void;
  28658. /**
  28659. * Gets or sets the color to use for the background
  28660. */
  28661. loadingUIBackgroundColor: string;
  28662. /**
  28663. * Gets or sets the text to display while loading
  28664. */
  28665. loadingUIText: string;
  28666. }
  28667. /**
  28668. * Class used for the default loading screen
  28669. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  28670. */
  28671. export class DefaultLoadingScreen implements ILoadingScreen {
  28672. private _renderingCanvas;
  28673. private _loadingText;
  28674. private _loadingDivBackgroundColor;
  28675. private _loadingDiv;
  28676. private _loadingTextDiv;
  28677. /** Gets or sets the logo url to use for the default loading screen */
  28678. static DefaultLogoUrl: string;
  28679. /** Gets or sets the spinner url to use for the default loading screen */
  28680. static DefaultSpinnerUrl: string;
  28681. /**
  28682. * Creates a new default loading screen
  28683. * @param _renderingCanvas defines the canvas used to render the scene
  28684. * @param _loadingText defines the default text to display
  28685. * @param _loadingDivBackgroundColor defines the default background color
  28686. */
  28687. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  28688. /**
  28689. * Function called to display the loading screen
  28690. */
  28691. displayLoadingUI(): void;
  28692. /**
  28693. * Function called to hide the loading screen
  28694. */
  28695. hideLoadingUI(): void;
  28696. /**
  28697. * Gets or sets the text to display while loading
  28698. */
  28699. loadingUIText: string;
  28700. /**
  28701. * Gets or sets the color to use for the background
  28702. */
  28703. loadingUIBackgroundColor: string;
  28704. private _resizeLoadingUI;
  28705. }
  28706. }
  28707. declare module BABYLON {
  28708. /** @hidden */
  28709. export class WebGLPipelineContext implements IPipelineContext {
  28710. engine: Engine;
  28711. program: Nullable<WebGLProgram>;
  28712. context?: WebGLRenderingContext;
  28713. vertexShader?: WebGLShader;
  28714. fragmentShader?: WebGLShader;
  28715. isParallelCompiled: boolean;
  28716. onCompiled?: () => void;
  28717. transformFeedback?: WebGLTransformFeedback | null;
  28718. readonly isAsync: boolean;
  28719. readonly isReady: boolean; private _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  28720. }
  28721. }
  28722. declare module BABYLON {
  28723. /** @hidden */
  28724. export class WebGLDataBuffer extends DataBuffer {
  28725. private _buffer;
  28726. constructor(resource: WebGLBuffer);
  28727. readonly underlyingResource: any;
  28728. }
  28729. }
  28730. declare module BABYLON {
  28731. /** @hidden */
  28732. export class WebGL2ShaderProcessor implements IShaderProcessor {
  28733. attributeProcessor(attribute: string): string;
  28734. varyingProcessor(varying: string, isFragment: boolean): string;
  28735. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  28736. }
  28737. }
  28738. declare module BABYLON {
  28739. /**
  28740. * This class is used to track a performance counter which is number based.
  28741. * The user has access to many properties which give statistics of different nature.
  28742. *
  28743. * The implementer can track two kinds of Performance Counter: time and count.
  28744. * 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.
  28745. * 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.
  28746. */
  28747. export class PerfCounter {
  28748. /**
  28749. * Gets or sets a global boolean to turn on and off all the counters
  28750. */
  28751. static Enabled: boolean;
  28752. /**
  28753. * Returns the smallest value ever
  28754. */
  28755. readonly min: number;
  28756. /**
  28757. * Returns the biggest value ever
  28758. */
  28759. readonly max: number;
  28760. /**
  28761. * Returns the average value since the performance counter is running
  28762. */
  28763. readonly average: number;
  28764. /**
  28765. * Returns the average value of the last second the counter was monitored
  28766. */
  28767. readonly lastSecAverage: number;
  28768. /**
  28769. * Returns the current value
  28770. */
  28771. readonly current: number;
  28772. /**
  28773. * Gets the accumulated total
  28774. */
  28775. readonly total: number;
  28776. /**
  28777. * Gets the total value count
  28778. */
  28779. readonly count: number;
  28780. /**
  28781. * Creates a new counter
  28782. */
  28783. constructor();
  28784. /**
  28785. * Call this method to start monitoring a new frame.
  28786. * 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.
  28787. */
  28788. fetchNewFrame(): void;
  28789. /**
  28790. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  28791. * @param newCount the count value to add to the monitored count
  28792. * @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.
  28793. */
  28794. addCount(newCount: number, fetchResult: boolean): void;
  28795. /**
  28796. * Start monitoring this performance counter
  28797. */
  28798. beginMonitoring(): void;
  28799. /**
  28800. * Compute the time lapsed since the previous beginMonitoring() call.
  28801. * @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
  28802. */
  28803. endMonitoring(newFrame?: boolean): void;
  28804. private _fetchResult;
  28805. private _startMonitoringTime;
  28806. private _min;
  28807. private _max;
  28808. private _average;
  28809. private _current;
  28810. private _totalValueCount;
  28811. private _totalAccumulated;
  28812. private _lastSecAverage;
  28813. private _lastSecAccumulated;
  28814. private _lastSecTime;
  28815. private _lastSecValueCount;
  28816. }
  28817. }
  28818. declare module BABYLON {
  28819. /**
  28820. * Interface for any object that can request an animation frame
  28821. */
  28822. export interface ICustomAnimationFrameRequester {
  28823. /**
  28824. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  28825. */
  28826. renderFunction?: Function;
  28827. /**
  28828. * Called to request the next frame to render to
  28829. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  28830. */
  28831. requestAnimationFrame: Function;
  28832. /**
  28833. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  28834. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  28835. */
  28836. requestID?: number;
  28837. }
  28838. }
  28839. declare module BABYLON {
  28840. /**
  28841. * Settings for finer control over video usage
  28842. */
  28843. export interface VideoTextureSettings {
  28844. /**
  28845. * Applies `autoplay` to video, if specified
  28846. */
  28847. autoPlay?: boolean;
  28848. /**
  28849. * Applies `loop` to video, if specified
  28850. */
  28851. loop?: boolean;
  28852. /**
  28853. * Automatically updates internal texture from video at every frame in the render loop
  28854. */
  28855. autoUpdateTexture: boolean;
  28856. /**
  28857. * Image src displayed during the video loading or until the user interacts with the video.
  28858. */
  28859. poster?: string;
  28860. }
  28861. /**
  28862. * If you want to display a video in your scene, this is the special texture for that.
  28863. * This special texture works similar to other textures, with the exception of a few parameters.
  28864. * @see https://doc.babylonjs.com/how_to/video_texture
  28865. */
  28866. export class VideoTexture extends Texture {
  28867. /**
  28868. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  28869. */
  28870. readonly autoUpdateTexture: boolean;
  28871. /**
  28872. * The video instance used by the texture internally
  28873. */
  28874. readonly video: HTMLVideoElement;
  28875. private _onUserActionRequestedObservable;
  28876. /**
  28877. * Event triggerd when a dom action is required by the user to play the video.
  28878. * This happens due to recent changes in browser policies preventing video to auto start.
  28879. */
  28880. readonly onUserActionRequestedObservable: Observable<Texture>;
  28881. private _generateMipMaps;
  28882. private _engine;
  28883. private _stillImageCaptured;
  28884. private _displayingPosterTexture;
  28885. private _settings;
  28886. private _createInternalTextureOnEvent;
  28887. /**
  28888. * Creates a video texture.
  28889. * If you want to display a video in your scene, this is the special texture for that.
  28890. * This special texture works similar to other textures, with the exception of a few parameters.
  28891. * @see https://doc.babylonjs.com/how_to/video_texture
  28892. * @param name optional name, will detect from video source, if not defined
  28893. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  28894. * @param scene is obviously the current scene.
  28895. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  28896. * @param invertY is false by default but can be used to invert video on Y axis
  28897. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  28898. * @param settings allows finer control over video usage
  28899. */
  28900. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  28901. private _getName;
  28902. private _getVideo;
  28903. private _createInternalTexture;
  28904. private reset;
  28905. /**
  28906. * @hidden Internal method to initiate `update`.
  28907. */ private _rebuild(): void;
  28908. /**
  28909. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  28910. */
  28911. update(): void;
  28912. /**
  28913. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  28914. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  28915. */
  28916. updateTexture(isVisible: boolean): void;
  28917. protected _updateInternalTexture: () => void;
  28918. /**
  28919. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  28920. * @param url New url.
  28921. */
  28922. updateURL(url: string): void;
  28923. /**
  28924. * Dispose the texture and release its associated resources.
  28925. */
  28926. dispose(): void;
  28927. /**
  28928. * Creates a video texture straight from a stream.
  28929. * @param scene Define the scene the texture should be created in
  28930. * @param stream Define the stream the texture should be created from
  28931. * @returns The created video texture as a promise
  28932. */
  28933. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  28934. /**
  28935. * Creates a video texture straight from your WebCam video feed.
  28936. * @param scene Define the scene the texture should be created in
  28937. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28938. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28939. * @returns The created video texture as a promise
  28940. */
  28941. static CreateFromWebCamAsync(scene: Scene, constraints: {
  28942. minWidth: number;
  28943. maxWidth: number;
  28944. minHeight: number;
  28945. maxHeight: number;
  28946. deviceId: string;
  28947. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  28948. /**
  28949. * Creates a video texture straight from your WebCam video feed.
  28950. * @param scene Define the scene the texture should be created in
  28951. * @param onReady Define a callback to triggered once the texture will be ready
  28952. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  28953. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  28954. */
  28955. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  28956. minWidth: number;
  28957. maxWidth: number;
  28958. minHeight: number;
  28959. maxHeight: number;
  28960. deviceId: string;
  28961. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  28962. }
  28963. }
  28964. declare module BABYLON {
  28965. /**
  28966. * Defines the interface used by objects containing a viewport (like a camera)
  28967. */
  28968. interface IViewportOwnerLike {
  28969. /**
  28970. * Gets or sets the viewport
  28971. */
  28972. viewport: IViewportLike;
  28973. }
  28974. /**
  28975. * Interface for attribute information associated with buffer instanciation
  28976. */
  28977. export class InstancingAttributeInfo {
  28978. /**
  28979. * Index/offset of the attribute in the vertex shader
  28980. */
  28981. index: number;
  28982. /**
  28983. * size of the attribute, 1, 2, 3 or 4
  28984. */
  28985. attributeSize: number;
  28986. /**
  28987. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  28988. * default is FLOAT
  28989. */
  28990. attribyteType: number;
  28991. /**
  28992. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  28993. */
  28994. normalized: boolean;
  28995. /**
  28996. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  28997. */
  28998. offset: number;
  28999. /**
  29000. * Name of the GLSL attribute, for debugging purpose only
  29001. */
  29002. attributeName: string;
  29003. }
  29004. /**
  29005. * Define options used to create a depth texture
  29006. */
  29007. export class DepthTextureCreationOptions {
  29008. /** Specifies whether or not a stencil should be allocated in the texture */
  29009. generateStencil?: boolean;
  29010. /** Specifies whether or not bilinear filtering is enable on the texture */
  29011. bilinearFiltering?: boolean;
  29012. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  29013. comparisonFunction?: number;
  29014. /** Specifies if the created texture is a cube texture */
  29015. isCube?: boolean;
  29016. }
  29017. /**
  29018. * Class used to describe the capabilities of the engine relatively to the current browser
  29019. */
  29020. export class EngineCapabilities {
  29021. /** Maximum textures units per fragment shader */
  29022. maxTexturesImageUnits: number;
  29023. /** Maximum texture units per vertex shader */
  29024. maxVertexTextureImageUnits: number;
  29025. /** Maximum textures units in the entire pipeline */
  29026. maxCombinedTexturesImageUnits: number;
  29027. /** Maximum texture size */
  29028. maxTextureSize: number;
  29029. /** Maximum cube texture size */
  29030. maxCubemapTextureSize: number;
  29031. /** Maximum render texture size */
  29032. maxRenderTextureSize: number;
  29033. /** Maximum number of vertex attributes */
  29034. maxVertexAttribs: number;
  29035. /** Maximum number of varyings */
  29036. maxVaryingVectors: number;
  29037. /** Maximum number of uniforms per vertex shader */
  29038. maxVertexUniformVectors: number;
  29039. /** Maximum number of uniforms per fragment shader */
  29040. maxFragmentUniformVectors: number;
  29041. /** Defines if standard derivates (dx/dy) are supported */
  29042. standardDerivatives: boolean;
  29043. /** Defines if s3tc texture compression is supported */
  29044. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29045. /** Defines if pvrtc texture compression is supported */
  29046. pvrtc: any;
  29047. /** Defines if etc1 texture compression is supported */
  29048. etc1: any;
  29049. /** Defines if etc2 texture compression is supported */
  29050. etc2: any;
  29051. /** Defines if astc texture compression is supported */
  29052. astc: any;
  29053. /** Defines if float textures are supported */
  29054. textureFloat: boolean;
  29055. /** Defines if vertex array objects are supported */
  29056. vertexArrayObject: boolean;
  29057. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29058. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29059. /** Gets the maximum level of anisotropy supported */
  29060. maxAnisotropy: number;
  29061. /** Defines if instancing is supported */
  29062. instancedArrays: boolean;
  29063. /** Defines if 32 bits indices are supported */
  29064. uintIndices: boolean;
  29065. /** Defines if high precision shaders are supported */
  29066. highPrecisionShaderSupported: boolean;
  29067. /** Defines if depth reading in the fragment shader is supported */
  29068. fragmentDepthSupported: boolean;
  29069. /** Defines if float texture linear filtering is supported*/
  29070. textureFloatLinearFiltering: boolean;
  29071. /** Defines if rendering to float textures is supported */
  29072. textureFloatRender: boolean;
  29073. /** Defines if half float textures are supported*/
  29074. textureHalfFloat: boolean;
  29075. /** Defines if half float texture linear filtering is supported*/
  29076. textureHalfFloatLinearFiltering: boolean;
  29077. /** Defines if rendering to half float textures is supported */
  29078. textureHalfFloatRender: boolean;
  29079. /** Defines if textureLOD shader command is supported */
  29080. textureLOD: boolean;
  29081. /** Defines if draw buffers extension is supported */
  29082. drawBuffersExtension: boolean;
  29083. /** Defines if depth textures are supported */
  29084. depthTextureExtension: boolean;
  29085. /** Defines if float color buffer are supported */
  29086. colorBufferFloat: boolean;
  29087. /** Gets disjoint timer query extension (null if not supported) */
  29088. timerQuery: EXT_disjoint_timer_query;
  29089. /** Defines if timestamp can be used with timer query */
  29090. canUseTimestampForTimerQuery: boolean;
  29091. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29092. multiview: any;
  29093. /** Function used to let the system compiles shaders in background */
  29094. parallelShaderCompile: {
  29095. COMPLETION_STATUS_KHR: number;
  29096. };
  29097. /** Max number of texture samples for MSAA */
  29098. maxMSAASamples: number;
  29099. }
  29100. /** Interface defining initialization parameters for Engine class */
  29101. export interface EngineOptions extends WebGLContextAttributes {
  29102. /**
  29103. * Defines if the engine should no exceed a specified device ratio
  29104. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29105. */
  29106. limitDeviceRatio?: number;
  29107. /**
  29108. * Defines if webvr should be enabled automatically
  29109. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29110. */
  29111. autoEnableWebVR?: boolean;
  29112. /**
  29113. * Defines if webgl2 should be turned off even if supported
  29114. * @see http://doc.babylonjs.com/features/webgl2
  29115. */
  29116. disableWebGL2Support?: boolean;
  29117. /**
  29118. * Defines if webaudio should be initialized as well
  29119. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29120. */
  29121. audioEngine?: boolean;
  29122. /**
  29123. * Defines if animations should run using a deterministic lock step
  29124. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29125. */
  29126. deterministicLockstep?: boolean;
  29127. /** Defines the maximum steps to use with deterministic lock step mode */
  29128. lockstepMaxSteps?: number;
  29129. /**
  29130. * Defines that engine should ignore context lost events
  29131. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  29132. */
  29133. doNotHandleContextLost?: boolean;
  29134. /**
  29135. * Defines that engine should ignore modifying touch action attribute and style
  29136. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  29137. */
  29138. doNotHandleTouchAction?: boolean;
  29139. /**
  29140. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  29141. */
  29142. useHighPrecisionFloats?: boolean;
  29143. }
  29144. /**
  29145. * Defines the interface used by display changed events
  29146. */
  29147. export interface IDisplayChangedEventArgs {
  29148. /** Gets the vrDisplay object (if any) */
  29149. vrDisplay: Nullable<any>;
  29150. /** Gets a boolean indicating if webVR is supported */
  29151. vrSupported: boolean;
  29152. }
  29153. /**
  29154. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  29155. */
  29156. export class Engine {
  29157. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  29158. static ExceptionList: ({
  29159. key: string;
  29160. capture: string;
  29161. captureConstraint: number;
  29162. targets: string[];
  29163. } | {
  29164. key: string;
  29165. capture: null;
  29166. captureConstraint: null;
  29167. targets: string[];
  29168. })[];
  29169. /** Gets the list of created engines */
  29170. static readonly Instances: Engine[];
  29171. /**
  29172. * Gets the latest created engine
  29173. */
  29174. static readonly LastCreatedEngine: Nullable<Engine>;
  29175. /**
  29176. * Gets the latest created scene
  29177. */
  29178. static readonly LastCreatedScene: Nullable<Scene>;
  29179. /**
  29180. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  29181. * @param flag defines which part of the materials must be marked as dirty
  29182. * @param predicate defines a predicate used to filter which materials should be affected
  29183. */
  29184. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  29185. /** @hidden */ private static _TextureLoaders: IInternalTextureLoader[];
  29186. /** Defines that alpha blending is disabled */
  29187. static readonly ALPHA_DISABLE: number;
  29188. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  29189. static readonly ALPHA_ADD: number;
  29190. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  29191. static readonly ALPHA_COMBINE: number;
  29192. /** Defines that alpha blending to DEST - SRC * DEST */
  29193. static readonly ALPHA_SUBTRACT: number;
  29194. /** Defines that alpha blending to SRC * DEST */
  29195. static readonly ALPHA_MULTIPLY: number;
  29196. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  29197. static readonly ALPHA_MAXIMIZED: number;
  29198. /** Defines that alpha blending to SRC + DEST */
  29199. static readonly ALPHA_ONEONE: number;
  29200. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  29201. static readonly ALPHA_PREMULTIPLIED: number;
  29202. /**
  29203. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  29204. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  29205. */
  29206. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  29207. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  29208. static readonly ALPHA_INTERPOLATE: number;
  29209. /**
  29210. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  29211. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  29212. */
  29213. static readonly ALPHA_SCREENMODE: number;
  29214. /** Defines that the ressource is not delayed*/
  29215. static readonly DELAYLOADSTATE_NONE: number;
  29216. /** Defines that the ressource was successfully delay loaded */
  29217. static readonly DELAYLOADSTATE_LOADED: number;
  29218. /** Defines that the ressource is currently delay loading */
  29219. static readonly DELAYLOADSTATE_LOADING: number;
  29220. /** Defines that the ressource is delayed and has not started loading */
  29221. static readonly DELAYLOADSTATE_NOTLOADED: number;
  29222. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  29223. static readonly NEVER: number;
  29224. /** 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 */
  29225. static readonly ALWAYS: number;
  29226. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  29227. static readonly LESS: number;
  29228. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  29229. static readonly EQUAL: number;
  29230. /** 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 */
  29231. static readonly LEQUAL: number;
  29232. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  29233. static readonly GREATER: number;
  29234. /** 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 */
  29235. static readonly GEQUAL: number;
  29236. /** 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 */
  29237. static readonly NOTEQUAL: number;
  29238. /** Passed to stencilOperation to specify that stencil value must be kept */
  29239. static readonly KEEP: number;
  29240. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29241. static readonly REPLACE: number;
  29242. /** Passed to stencilOperation to specify that stencil value must be incremented */
  29243. static readonly INCR: number;
  29244. /** Passed to stencilOperation to specify that stencil value must be decremented */
  29245. static readonly DECR: number;
  29246. /** Passed to stencilOperation to specify that stencil value must be inverted */
  29247. static readonly INVERT: number;
  29248. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  29249. static readonly INCR_WRAP: number;
  29250. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  29251. static readonly DECR_WRAP: number;
  29252. /** Texture is not repeating outside of 0..1 UVs */
  29253. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  29254. /** Texture is repeating outside of 0..1 UVs */
  29255. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  29256. /** Texture is repeating and mirrored */
  29257. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  29258. /** ALPHA */
  29259. static readonly TEXTUREFORMAT_ALPHA: number;
  29260. /** LUMINANCE */
  29261. static readonly TEXTUREFORMAT_LUMINANCE: number;
  29262. /** LUMINANCE_ALPHA */
  29263. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  29264. /** RGB */
  29265. static readonly TEXTUREFORMAT_RGB: number;
  29266. /** RGBA */
  29267. static readonly TEXTUREFORMAT_RGBA: number;
  29268. /** RED */
  29269. static readonly TEXTUREFORMAT_RED: number;
  29270. /** RED (2nd reference) */
  29271. static readonly TEXTUREFORMAT_R: number;
  29272. /** RG */
  29273. static readonly TEXTUREFORMAT_RG: number;
  29274. /** RED_INTEGER */
  29275. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  29276. /** RED_INTEGER (2nd reference) */
  29277. static readonly TEXTUREFORMAT_R_INTEGER: number;
  29278. /** RG_INTEGER */
  29279. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  29280. /** RGB_INTEGER */
  29281. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  29282. /** RGBA_INTEGER */
  29283. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  29284. /** UNSIGNED_BYTE */
  29285. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  29286. /** UNSIGNED_BYTE (2nd reference) */
  29287. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  29288. /** FLOAT */
  29289. static readonly TEXTURETYPE_FLOAT: number;
  29290. /** HALF_FLOAT */
  29291. static readonly TEXTURETYPE_HALF_FLOAT: number;
  29292. /** BYTE */
  29293. static readonly TEXTURETYPE_BYTE: number;
  29294. /** SHORT */
  29295. static readonly TEXTURETYPE_SHORT: number;
  29296. /** UNSIGNED_SHORT */
  29297. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  29298. /** INT */
  29299. static readonly TEXTURETYPE_INT: number;
  29300. /** UNSIGNED_INT */
  29301. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  29302. /** UNSIGNED_SHORT_4_4_4_4 */
  29303. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  29304. /** UNSIGNED_SHORT_5_5_5_1 */
  29305. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  29306. /** UNSIGNED_SHORT_5_6_5 */
  29307. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  29308. /** UNSIGNED_INT_2_10_10_10_REV */
  29309. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  29310. /** UNSIGNED_INT_24_8 */
  29311. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  29312. /** UNSIGNED_INT_10F_11F_11F_REV */
  29313. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  29314. /** UNSIGNED_INT_5_9_9_9_REV */
  29315. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  29316. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  29317. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  29318. /** nearest is mag = nearest and min = nearest and mip = linear */
  29319. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  29320. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29321. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  29322. /** Trilinear is mag = linear and min = linear and mip = linear */
  29323. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  29324. /** nearest is mag = nearest and min = nearest and mip = linear */
  29325. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  29326. /** Bilinear is mag = linear and min = linear and mip = nearest */
  29327. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  29328. /** Trilinear is mag = linear and min = linear and mip = linear */
  29329. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  29330. /** mag = nearest and min = nearest and mip = nearest */
  29331. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  29332. /** mag = nearest and min = linear and mip = nearest */
  29333. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  29334. /** mag = nearest and min = linear and mip = linear */
  29335. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  29336. /** mag = nearest and min = linear and mip = none */
  29337. static readonly TEXTURE_NEAREST_LINEAR: number;
  29338. /** mag = nearest and min = nearest and mip = none */
  29339. static readonly TEXTURE_NEAREST_NEAREST: number;
  29340. /** mag = linear and min = nearest and mip = nearest */
  29341. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  29342. /** mag = linear and min = nearest and mip = linear */
  29343. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  29344. /** mag = linear and min = linear and mip = none */
  29345. static readonly TEXTURE_LINEAR_LINEAR: number;
  29346. /** mag = linear and min = nearest and mip = none */
  29347. static readonly TEXTURE_LINEAR_NEAREST: number;
  29348. /** Explicit coordinates mode */
  29349. static readonly TEXTURE_EXPLICIT_MODE: number;
  29350. /** Spherical coordinates mode */
  29351. static readonly TEXTURE_SPHERICAL_MODE: number;
  29352. /** Planar coordinates mode */
  29353. static readonly TEXTURE_PLANAR_MODE: number;
  29354. /** Cubic coordinates mode */
  29355. static readonly TEXTURE_CUBIC_MODE: number;
  29356. /** Projection coordinates mode */
  29357. static readonly TEXTURE_PROJECTION_MODE: number;
  29358. /** Skybox coordinates mode */
  29359. static readonly TEXTURE_SKYBOX_MODE: number;
  29360. /** Inverse Cubic coordinates mode */
  29361. static readonly TEXTURE_INVCUBIC_MODE: number;
  29362. /** Equirectangular coordinates mode */
  29363. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  29364. /** Equirectangular Fixed coordinates mode */
  29365. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  29366. /** Equirectangular Fixed Mirrored coordinates mode */
  29367. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  29368. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  29369. static readonly SCALEMODE_FLOOR: number;
  29370. /** Defines that texture rescaling will look for the nearest power of 2 size */
  29371. static readonly SCALEMODE_NEAREST: number;
  29372. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  29373. static readonly SCALEMODE_CEILING: number;
  29374. /**
  29375. * Returns the current npm package of the sdk
  29376. */
  29377. static readonly NpmPackage: string;
  29378. /**
  29379. * Returns the current version of the framework
  29380. */
  29381. static readonly Version: string;
  29382. /**
  29383. * Returns a string describing the current engine
  29384. */
  29385. readonly description: string;
  29386. /**
  29387. * Gets or sets the epsilon value used by collision engine
  29388. */
  29389. static CollisionsEpsilon: number;
  29390. /**
  29391. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29392. */
  29393. static ShadersRepository: string;
  29394. /**
  29395. * Method called to create the default loading screen.
  29396. * This can be overriden in your own app.
  29397. * @param canvas The rendering canvas element
  29398. * @returns The loading screen
  29399. */
  29400. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  29401. /**
  29402. * Method called to create the default rescale post process on each engine.
  29403. */ private static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  29404. /** @hidden */ private _shaderProcessor: IShaderProcessor;
  29405. /**
  29406. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  29407. */
  29408. forcePOTTextures: boolean;
  29409. /**
  29410. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  29411. */
  29412. isFullscreen: boolean;
  29413. /**
  29414. * Gets a boolean indicating if the pointer is currently locked
  29415. */
  29416. isPointerLock: boolean;
  29417. /**
  29418. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  29419. */
  29420. cullBackFaces: boolean;
  29421. /**
  29422. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  29423. */
  29424. renderEvenInBackground: boolean;
  29425. /**
  29426. * Gets or sets a boolean indicating that cache can be kept between frames
  29427. */
  29428. preventCacheWipeBetweenFrames: boolean;
  29429. /**
  29430. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  29431. **/
  29432. enableOfflineSupport: boolean;
  29433. /**
  29434. * 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)
  29435. **/
  29436. disableManifestCheck: boolean;
  29437. /**
  29438. * Gets the list of created scenes
  29439. */
  29440. scenes: Scene[];
  29441. /**
  29442. * Event raised when a new scene is created
  29443. */
  29444. onNewSceneAddedObservable: Observable<Scene>;
  29445. /**
  29446. * Gets the list of created postprocesses
  29447. */
  29448. postProcesses: PostProcess[];
  29449. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  29450. validateShaderPrograms: boolean;
  29451. /**
  29452. * Observable event triggered each time the rendering canvas is resized
  29453. */
  29454. onResizeObservable: Observable<Engine>;
  29455. /**
  29456. * Observable event triggered each time the canvas loses focus
  29457. */
  29458. onCanvasBlurObservable: Observable<Engine>;
  29459. /**
  29460. * Observable event triggered each time the canvas gains focus
  29461. */
  29462. onCanvasFocusObservable: Observable<Engine>;
  29463. /**
  29464. * Observable event triggered each time the canvas receives pointerout event
  29465. */
  29466. onCanvasPointerOutObservable: Observable<PointerEvent>;
  29467. /**
  29468. * Observable event triggered before each texture is initialized
  29469. */
  29470. onBeforeTextureInitObservable: Observable<Texture>;
  29471. /**
  29472. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  29473. */
  29474. disableUniformBuffers: boolean;
  29475. /** @hidden */ private _uniformBuffers: UniformBuffer[];
  29476. /**
  29477. * Gets a boolean indicating that the engine supports uniform buffers
  29478. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29479. */
  29480. readonly supportsUniformBuffers: boolean;
  29481. /**
  29482. * Observable raised when the engine begins a new frame
  29483. */
  29484. onBeginFrameObservable: Observable<Engine>;
  29485. /**
  29486. * If set, will be used to request the next animation frame for the render loop
  29487. */
  29488. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  29489. /**
  29490. * Observable raised when the engine ends the current frame
  29491. */
  29492. onEndFrameObservable: Observable<Engine>;
  29493. /**
  29494. * Observable raised when the engine is about to compile a shader
  29495. */
  29496. onBeforeShaderCompilationObservable: Observable<Engine>;
  29497. /**
  29498. * Observable raised when the engine has jsut compiled a shader
  29499. */
  29500. onAfterShaderCompilationObservable: Observable<Engine>;
  29501. /** @hidden */ private _gl: WebGLRenderingContext;
  29502. private _renderingCanvas;
  29503. private _windowIsBackground;
  29504. private _webGLVersion;
  29505. protected _highPrecisionShadersAllowed: boolean;
  29506. /** @hidden */ protected readonly _shouldUseHighPrecisionShader: boolean;
  29507. /**
  29508. * Gets a boolean indicating that only power of 2 textures are supported
  29509. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  29510. */
  29511. readonly needPOTTextures: boolean;
  29512. /** @hidden */ private _badOS: boolean;
  29513. /** @hidden */ private _badDesktopOS: boolean;
  29514. /**
  29515. * Gets the audio engine
  29516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  29517. * @ignorenaming
  29518. */
  29519. static audioEngine: IAudioEngine;
  29520. /**
  29521. * Default AudioEngine factory responsible of creating the Audio Engine.
  29522. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  29523. */
  29524. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  29525. /**
  29526. * Default offline support factory responsible of creating a tool used to store data locally.
  29527. * By default, this will create a Database object if the workload has been embedded.
  29528. */
  29529. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  29530. private _onFocus;
  29531. private _onBlur;
  29532. private _onCanvasPointerOut;
  29533. private _onCanvasBlur;
  29534. private _onCanvasFocus;
  29535. private _onFullscreenChange;
  29536. private _onPointerLockChange;
  29537. private _hardwareScalingLevel;
  29538. /** @hidden */ private _caps: EngineCapabilities;
  29539. private _pointerLockRequested;
  29540. private _isStencilEnable;
  29541. private _colorWrite;
  29542. private _loadingScreen;
  29543. /** @hidden */ private _drawCalls: PerfCounter;
  29544. private _glVersion;
  29545. private _glRenderer;
  29546. private _glVendor;
  29547. private _videoTextureSupported;
  29548. private _renderingQueueLaunched;
  29549. private _activeRenderLoops;
  29550. private _deterministicLockstep;
  29551. private _lockstepMaxSteps;
  29552. /**
  29553. * Observable signaled when a context lost event is raised
  29554. */
  29555. onContextLostObservable: Observable<Engine>;
  29556. /**
  29557. * Observable signaled when a context restored event is raised
  29558. */
  29559. onContextRestoredObservable: Observable<Engine>;
  29560. private _onContextLost;
  29561. private _onContextRestored;
  29562. private _contextWasLost;
  29563. /** @hidden */ private _doNotHandleContextLost: boolean;
  29564. /**
  29565. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  29566. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  29567. */
  29568. doNotHandleContextLost: boolean;
  29569. private _performanceMonitor;
  29570. private _fps;
  29571. private _deltaTime;
  29572. /**
  29573. * Turn this value on if you want to pause FPS computation when in background
  29574. */
  29575. disablePerformanceMonitorInBackground: boolean;
  29576. /**
  29577. * Gets the performance monitor attached to this engine
  29578. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  29579. */
  29580. readonly performanceMonitor: PerformanceMonitor;
  29581. /**
  29582. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  29583. */
  29584. disableVertexArrayObjects: boolean;
  29585. /** @hidden */
  29586. protected _depthCullingState: _DepthCullingState;
  29587. /** @hidden */
  29588. protected _stencilState: _StencilState;
  29589. /** @hidden */
  29590. protected _alphaState: _AlphaState;
  29591. /** @hidden */
  29592. protected _alphaMode: number;
  29593. /** @hidden */ private _internalTexturesCache: InternalTexture[];
  29594. /** @hidden */
  29595. protected _activeChannel: number;
  29596. private _currentTextureChannel;
  29597. /** @hidden */
  29598. protected _boundTexturesCache: {
  29599. [key: string]: Nullable<InternalTexture>;
  29600. };
  29601. /** @hidden */
  29602. protected _currentEffect: Nullable<Effect>;
  29603. /** @hidden */
  29604. protected _currentProgram: Nullable<WebGLProgram>;
  29605. private _compiledEffects;
  29606. private _vertexAttribArraysEnabled;
  29607. /** @hidden */
  29608. protected _cachedViewport: Nullable<IViewportLike>;
  29609. private _cachedVertexArrayObject;
  29610. /** @hidden */
  29611. protected _cachedVertexBuffers: any;
  29612. /** @hidden */
  29613. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  29614. /** @hidden */
  29615. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  29616. /** @hidden */ private _currentRenderTarget: Nullable<InternalTexture>;
  29617. private _uintIndicesCurrentlySet;
  29618. private _currentBoundBuffer;
  29619. /** @hidden */
  29620. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  29621. private _currentBufferPointers;
  29622. private _currentInstanceLocations;
  29623. private _currentInstanceBuffers;
  29624. private _textureUnits;
  29625. /** @hidden */ private _workingCanvas: Nullable<HTMLCanvasElement>;
  29626. /** @hidden */ private _workingContext: Nullable<CanvasRenderingContext2D>;
  29627. private _rescalePostProcess;
  29628. private _dummyFramebuffer;
  29629. private _externalData;
  29630. /** @hidden */ private _bindedRenderFunction: any;
  29631. private _vaoRecordInProgress;
  29632. private _mustWipeVertexAttributes;
  29633. private _emptyTexture;
  29634. private _emptyCubeTexture;
  29635. private _emptyTexture3D;
  29636. /** @hidden */ private _frameHandler: number;
  29637. private _nextFreeTextureSlots;
  29638. private _maxSimultaneousTextures;
  29639. private _activeRequests;
  29640. private _texturesSupported;
  29641. /** @hidden */ private _textureFormatInUse: Nullable<string>;
  29642. /**
  29643. * Gets the list of texture formats supported
  29644. */
  29645. readonly texturesSupported: Array<string>;
  29646. /**
  29647. * Gets the list of texture formats in use
  29648. */
  29649. readonly textureFormatInUse: Nullable<string>;
  29650. /**
  29651. * Gets the current viewport
  29652. */
  29653. readonly currentViewport: Nullable<IViewportLike>;
  29654. /**
  29655. * Gets the default empty texture
  29656. */
  29657. readonly emptyTexture: InternalTexture;
  29658. /**
  29659. * Gets the default empty 3D texture
  29660. */
  29661. readonly emptyTexture3D: InternalTexture;
  29662. /**
  29663. * Gets the default empty cube texture
  29664. */
  29665. readonly emptyCubeTexture: InternalTexture;
  29666. /**
  29667. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  29668. */
  29669. readonly premultipliedAlpha: boolean;
  29670. /**
  29671. * Creates a new engine
  29672. * @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
  29673. * @param antialias defines enable antialiasing (default: false)
  29674. * @param options defines further options to be sent to the getContext() function
  29675. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  29676. */
  29677. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  29678. /**
  29679. * Initializes a webVR display and starts listening to display change events
  29680. * The onVRDisplayChangedObservable will be notified upon these changes
  29681. * @returns The onVRDisplayChangedObservable
  29682. */
  29683. initWebVR(): Observable<IDisplayChangedEventArgs>;
  29684. /** @hidden */ private _prepareVRComponent(): void;
  29685. /** @hidden */ private _connectVREvents(canvas: HTMLCanvasElement, document: any): void;
  29686. /** @hidden */ private _submitVRFrame(): void;
  29687. /**
  29688. * Call this function to leave webVR mode
  29689. * Will do nothing if webVR is not supported or if there is no webVR device
  29690. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29691. */
  29692. disableVR(): void;
  29693. /**
  29694. * Gets a boolean indicating that the system is in VR mode and is presenting
  29695. * @returns true if VR mode is engaged
  29696. */
  29697. isVRPresenting(): boolean;
  29698. /** @hidden */ private _requestVRFrame(): void;
  29699. private _disableTouchAction;
  29700. private _rebuildInternalTextures;
  29701. private _rebuildEffects;
  29702. /**
  29703. * Gets a boolean indicating if all created effects are ready
  29704. * @returns true if all effects are ready
  29705. */
  29706. areAllEffectsReady(): boolean;
  29707. private _rebuildBuffers;
  29708. private _initGLContext;
  29709. /**
  29710. * Gets version of the current webGL context
  29711. */
  29712. readonly webGLVersion: number;
  29713. /**
  29714. * Gets a string idenfifying the name of the class
  29715. * @returns "Engine" string
  29716. */
  29717. getClassName(): string;
  29718. /**
  29719. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  29720. */
  29721. readonly isStencilEnable: boolean;
  29722. /** @hidden */ private _prepareWorkingCanvas(): void;
  29723. /**
  29724. * Reset the texture cache to empty state
  29725. */
  29726. resetTextureCache(): void;
  29727. /**
  29728. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  29729. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29730. * @returns true if engine is in deterministic lock step mode
  29731. */
  29732. isDeterministicLockStep(): boolean;
  29733. /**
  29734. * Gets the max steps when engine is running in deterministic lock step
  29735. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  29736. * @returns the max steps
  29737. */
  29738. getLockstepMaxSteps(): number;
  29739. /**
  29740. * Gets an object containing information about the current webGL context
  29741. * @returns an object containing the vender, the renderer and the version of the current webGL context
  29742. */
  29743. getGlInfo(): {
  29744. vendor: string;
  29745. renderer: string;
  29746. version: string;
  29747. };
  29748. /**
  29749. * Gets current aspect ratio
  29750. * @param viewportOwner defines the camera to use to get the aspect ratio
  29751. * @param useScreen defines if screen size must be used (or the current render target if any)
  29752. * @returns a number defining the aspect ratio
  29753. */
  29754. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  29755. /**
  29756. * Gets current screen aspect ratio
  29757. * @returns a number defining the aspect ratio
  29758. */
  29759. getScreenAspectRatio(): number;
  29760. /**
  29761. * Gets the current render width
  29762. * @param useScreen defines if screen size must be used (or the current render target if any)
  29763. * @returns a number defining the current render width
  29764. */
  29765. getRenderWidth(useScreen?: boolean): number;
  29766. /**
  29767. * Gets the current render height
  29768. * @param useScreen defines if screen size must be used (or the current render target if any)
  29769. * @returns a number defining the current render height
  29770. */
  29771. getRenderHeight(useScreen?: boolean): number;
  29772. /**
  29773. * Gets the HTML canvas attached with the current webGL context
  29774. * @returns a HTML canvas
  29775. */
  29776. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  29777. /**
  29778. * Gets host window
  29779. * @returns the host window object
  29780. */
  29781. getHostWindow(): Window;
  29782. /**
  29783. * Gets host document
  29784. * @returns the host document object
  29785. */
  29786. getHostDocument(): Document;
  29787. /**
  29788. * Gets the client rect of the HTML canvas attached with the current webGL context
  29789. * @returns a client rectanglee
  29790. */
  29791. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  29792. /**
  29793. * Defines the hardware scaling level.
  29794. * By default the hardware scaling level is computed from the window device ratio.
  29795. * 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.
  29796. * @param level defines the level to use
  29797. */
  29798. setHardwareScalingLevel(level: number): void;
  29799. /**
  29800. * Gets the current hardware scaling level.
  29801. * By default the hardware scaling level is computed from the window device ratio.
  29802. * 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.
  29803. * @returns a number indicating the current hardware scaling level
  29804. */
  29805. getHardwareScalingLevel(): number;
  29806. /**
  29807. * Gets the list of loaded textures
  29808. * @returns an array containing all loaded textures
  29809. */
  29810. getLoadedTexturesCache(): InternalTexture[];
  29811. /**
  29812. * Gets the object containing all engine capabilities
  29813. * @returns the EngineCapabilities object
  29814. */
  29815. getCaps(): EngineCapabilities;
  29816. /**
  29817. * Gets the current depth function
  29818. * @returns a number defining the depth function
  29819. */
  29820. getDepthFunction(): Nullable<number>;
  29821. /**
  29822. * Sets the current depth function
  29823. * @param depthFunc defines the function to use
  29824. */
  29825. setDepthFunction(depthFunc: number): void;
  29826. /**
  29827. * Sets the current depth function to GREATER
  29828. */
  29829. setDepthFunctionToGreater(): void;
  29830. /**
  29831. * Sets the current depth function to GEQUAL
  29832. */
  29833. setDepthFunctionToGreaterOrEqual(): void;
  29834. /**
  29835. * Sets the current depth function to LESS
  29836. */
  29837. setDepthFunctionToLess(): void;
  29838. private _cachedStencilBuffer;
  29839. private _cachedStencilFunction;
  29840. private _cachedStencilMask;
  29841. private _cachedStencilOperationPass;
  29842. private _cachedStencilOperationFail;
  29843. private _cachedStencilOperationDepthFail;
  29844. private _cachedStencilReference;
  29845. /**
  29846. * Caches the the state of the stencil buffer
  29847. */
  29848. cacheStencilState(): void;
  29849. /**
  29850. * Restores the state of the stencil buffer
  29851. */
  29852. restoreStencilState(): void;
  29853. /**
  29854. * Sets the current depth function to LEQUAL
  29855. */
  29856. setDepthFunctionToLessOrEqual(): void;
  29857. /**
  29858. * Gets a boolean indicating if stencil buffer is enabled
  29859. * @returns the current stencil buffer state
  29860. */
  29861. getStencilBuffer(): boolean;
  29862. /**
  29863. * Enable or disable the stencil buffer
  29864. * @param enable defines if the stencil buffer must be enabled or disabled
  29865. */
  29866. setStencilBuffer(enable: boolean): void;
  29867. /**
  29868. * Gets the current stencil mask
  29869. * @returns a number defining the new stencil mask to use
  29870. */
  29871. getStencilMask(): number;
  29872. /**
  29873. * Sets the current stencil mask
  29874. * @param mask defines the new stencil mask to use
  29875. */
  29876. setStencilMask(mask: number): void;
  29877. /**
  29878. * Gets the current stencil function
  29879. * @returns a number defining the stencil function to use
  29880. */
  29881. getStencilFunction(): number;
  29882. /**
  29883. * Gets the current stencil reference value
  29884. * @returns a number defining the stencil reference value to use
  29885. */
  29886. getStencilFunctionReference(): number;
  29887. /**
  29888. * Gets the current stencil mask
  29889. * @returns a number defining the stencil mask to use
  29890. */
  29891. getStencilFunctionMask(): number;
  29892. /**
  29893. * Sets the current stencil function
  29894. * @param stencilFunc defines the new stencil function to use
  29895. */
  29896. setStencilFunction(stencilFunc: number): void;
  29897. /**
  29898. * Sets the current stencil reference
  29899. * @param reference defines the new stencil reference to use
  29900. */
  29901. setStencilFunctionReference(reference: number): void;
  29902. /**
  29903. * Sets the current stencil mask
  29904. * @param mask defines the new stencil mask to use
  29905. */
  29906. setStencilFunctionMask(mask: number): void;
  29907. /**
  29908. * Gets the current stencil operation when stencil fails
  29909. * @returns a number defining stencil operation to use when stencil fails
  29910. */
  29911. getStencilOperationFail(): number;
  29912. /**
  29913. * Gets the current stencil operation when depth fails
  29914. * @returns a number defining stencil operation to use when depth fails
  29915. */
  29916. getStencilOperationDepthFail(): number;
  29917. /**
  29918. * Gets the current stencil operation when stencil passes
  29919. * @returns a number defining stencil operation to use when stencil passes
  29920. */
  29921. getStencilOperationPass(): number;
  29922. /**
  29923. * Sets the stencil operation to use when stencil fails
  29924. * @param operation defines the stencil operation to use when stencil fails
  29925. */
  29926. setStencilOperationFail(operation: number): void;
  29927. /**
  29928. * Sets the stencil operation to use when depth fails
  29929. * @param operation defines the stencil operation to use when depth fails
  29930. */
  29931. setStencilOperationDepthFail(operation: number): void;
  29932. /**
  29933. * Sets the stencil operation to use when stencil passes
  29934. * @param operation defines the stencil operation to use when stencil passes
  29935. */
  29936. setStencilOperationPass(operation: number): void;
  29937. /**
  29938. * Sets a boolean indicating if the dithering state is enabled or disabled
  29939. * @param value defines the dithering state
  29940. */
  29941. setDitheringState(value: boolean): void;
  29942. /**
  29943. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  29944. * @param value defines the rasterizer state
  29945. */
  29946. setRasterizerState(value: boolean): void;
  29947. /**
  29948. * stop executing a render loop function and remove it from the execution array
  29949. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  29950. */
  29951. stopRenderLoop(renderFunction?: () => void): void;
  29952. /** @hidden */ private _renderLoop(): void;
  29953. /**
  29954. * Register and execute a render loop. The engine can have more than one render function
  29955. * @param renderFunction defines the function to continuously execute
  29956. */
  29957. runRenderLoop(renderFunction: () => void): void;
  29958. /**
  29959. * Toggle full screen mode
  29960. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29961. */
  29962. switchFullscreen(requestPointerLock: boolean): void;
  29963. /**
  29964. * Enters full screen mode
  29965. * @param requestPointerLock defines if a pointer lock should be requested from the user
  29966. */
  29967. enterFullscreen(requestPointerLock: boolean): void;
  29968. /**
  29969. * Exits full screen mode
  29970. */
  29971. exitFullscreen(): void;
  29972. /**
  29973. * Enters Pointerlock mode
  29974. */
  29975. enterPointerlock(): void;
  29976. /**
  29977. * Exits Pointerlock mode
  29978. */
  29979. exitPointerlock(): void;
  29980. /**
  29981. * Clear the current render buffer or the current render target (if any is set up)
  29982. * @param color defines the color to use
  29983. * @param backBuffer defines if the back buffer must be cleared
  29984. * @param depth defines if the depth buffer must be cleared
  29985. * @param stencil defines if the stencil buffer must be cleared
  29986. */
  29987. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  29988. /**
  29989. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  29990. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  29991. * @param y defines the y-coordinate of the corner of the clear rectangle
  29992. * @param width defines the width of the clear rectangle
  29993. * @param height defines the height of the clear rectangle
  29994. * @param clearColor defines the clear color
  29995. */
  29996. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  29997. /**
  29998. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  29999. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  30000. * @param y defines the y-coordinate of the corner of the clear rectangle
  30001. * @param width defines the width of the clear rectangle
  30002. * @param height defines the height of the clear rectangle
  30003. */
  30004. enableScissor(x: number, y: number, width: number, height: number): void;
  30005. /**
  30006. * Disable previously set scissor test rectangle
  30007. */
  30008. disableScissor(): void;
  30009. private _viewportCached;
  30010. /** @hidden */ private _viewport(x: number, y: number, width: number, height: number): void;
  30011. /**
  30012. * Set the WebGL's viewport
  30013. * @param viewport defines the viewport element to be used
  30014. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30015. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30016. */
  30017. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30018. /**
  30019. * Directly set the WebGL Viewport
  30020. * @param x defines the x coordinate of the viewport (in screen space)
  30021. * @param y defines the y coordinate of the viewport (in screen space)
  30022. * @param width defines the width of the viewport (in screen space)
  30023. * @param height defines the height of the viewport (in screen space)
  30024. * @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
  30025. */
  30026. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  30027. /**
  30028. * Begin a new frame
  30029. */
  30030. beginFrame(): void;
  30031. /**
  30032. * Enf the current frame
  30033. */
  30034. endFrame(): void;
  30035. /**
  30036. * Resize the view according to the canvas' size
  30037. */
  30038. resize(): void;
  30039. /**
  30040. * Force a specific size of the canvas
  30041. * @param width defines the new canvas' width
  30042. * @param height defines the new canvas' height
  30043. */
  30044. setSize(width: number, height: number): void;
  30045. /**
  30046. * Binds the frame buffer to the specified texture.
  30047. * @param texture The texture to render to or null for the default canvas
  30048. * @param faceIndex The face of the texture to render to in case of cube texture
  30049. * @param requiredWidth The width of the target to render to
  30050. * @param requiredHeight The height of the target to render to
  30051. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30052. * @param depthStencilTexture The depth stencil texture to use to render
  30053. * @param lodLevel defines le lod level to bind to the frame buffer
  30054. */
  30055. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30056. /** @hidden */ private _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30057. /**
  30058. * Unbind the current render target texture from the webGL context
  30059. * @param texture defines the render target texture to unbind
  30060. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30061. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30062. */
  30063. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30064. /**
  30065. * Force the mipmap generation for the given render target texture
  30066. * @param texture defines the render target texture to use
  30067. */
  30068. generateMipMapsForCubemap(texture: InternalTexture): void;
  30069. /**
  30070. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30071. */
  30072. flushFramebuffer(): void;
  30073. /**
  30074. * Unbind the current render target and bind the default framebuffer
  30075. */
  30076. restoreDefaultFramebuffer(): void;
  30077. /**
  30078. * Create an uniform buffer
  30079. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30080. * @param elements defines the content of the uniform buffer
  30081. * @returns the webGL uniform buffer
  30082. */
  30083. createUniformBuffer(elements: FloatArray): DataBuffer;
  30084. /**
  30085. * Create a dynamic uniform buffer
  30086. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30087. * @param elements defines the content of the uniform buffer
  30088. * @returns the webGL uniform buffer
  30089. */
  30090. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  30091. /**
  30092. * Update an existing uniform buffer
  30093. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30094. * @param uniformBuffer defines the target uniform buffer
  30095. * @param elements defines the content to update
  30096. * @param offset defines the offset in the uniform buffer where update should start
  30097. * @param count defines the size of the data to update
  30098. */
  30099. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  30100. private _resetVertexBufferBinding;
  30101. /**
  30102. * Creates a vertex buffer
  30103. * @param data the data for the vertex buffer
  30104. * @returns the new WebGL static buffer
  30105. */
  30106. createVertexBuffer(data: DataArray): DataBuffer;
  30107. /**
  30108. * Creates a dynamic vertex buffer
  30109. * @param data the data for the dynamic vertex buffer
  30110. * @returns the new WebGL dynamic buffer
  30111. */
  30112. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30113. /**
  30114. * Update a dynamic index buffer
  30115. * @param indexBuffer defines the target index buffer
  30116. * @param indices defines the data to update
  30117. * @param offset defines the offset in the target index buffer where update should start
  30118. */
  30119. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  30120. /**
  30121. * Updates a dynamic vertex buffer.
  30122. * @param vertexBuffer the vertex buffer to update
  30123. * @param data the data used to update the vertex buffer
  30124. * @param byteOffset the byte offset of the data
  30125. * @param byteLength the byte length of the data
  30126. */
  30127. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30128. private _resetIndexBufferBinding;
  30129. /**
  30130. * Creates a new index buffer
  30131. * @param indices defines the content of the index buffer
  30132. * @param updatable defines if the index buffer must be updatable
  30133. * @returns a new webGL buffer
  30134. */
  30135. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30136. /**
  30137. * Bind a webGL buffer to the webGL context
  30138. * @param buffer defines the buffer to bind
  30139. */
  30140. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30141. /**
  30142. * Bind an uniform buffer to the current webGL context
  30143. * @param buffer defines the buffer to bind
  30144. */
  30145. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  30146. /**
  30147. * Bind a buffer to the current webGL context at a given location
  30148. * @param buffer defines the buffer to bind
  30149. * @param location defines the index where to bind the buffer
  30150. */
  30151. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  30152. /**
  30153. * Bind a specific block at a given index in a specific shader program
  30154. * @param pipelineContext defines the pipeline context to use
  30155. * @param blockName defines the block name
  30156. * @param index defines the index where to bind the block
  30157. */
  30158. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  30159. private bindIndexBuffer;
  30160. private bindBuffer;
  30161. /**
  30162. * update the bound buffer with the given data
  30163. * @param data defines the data to update
  30164. */
  30165. updateArrayBuffer(data: Float32Array): void;
  30166. private _vertexAttribPointer;
  30167. private _bindIndexBufferWithCache;
  30168. private _bindVertexBuffersAttributes;
  30169. /**
  30170. * Records a vertex array object
  30171. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30172. * @param vertexBuffers defines the list of vertex buffers to store
  30173. * @param indexBuffer defines the index buffer to store
  30174. * @param effect defines the effect to store
  30175. * @returns the new vertex array object
  30176. */
  30177. recordVertexArrayObject(vertexBuffers: {
  30178. [key: string]: VertexBuffer;
  30179. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30180. /**
  30181. * Bind a specific vertex array object
  30182. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30183. * @param vertexArrayObject defines the vertex array object to bind
  30184. * @param indexBuffer defines the index buffer to bind
  30185. */
  30186. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30187. /**
  30188. * Bind webGl buffers directly to the webGL context
  30189. * @param vertexBuffer defines the vertex buffer to bind
  30190. * @param indexBuffer defines the index buffer to bind
  30191. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30192. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30193. * @param effect defines the effect associated with the vertex buffer
  30194. */
  30195. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30196. private _unbindVertexArrayObject;
  30197. /**
  30198. * Bind a list of vertex buffers to the webGL context
  30199. * @param vertexBuffers defines the list of vertex buffers to bind
  30200. * @param indexBuffer defines the index buffer to bind
  30201. * @param effect defines the effect associated with the vertex buffers
  30202. */
  30203. bindBuffers(vertexBuffers: {
  30204. [key: string]: Nullable<VertexBuffer>;
  30205. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30206. /**
  30207. * Unbind all instance attributes
  30208. */
  30209. unbindInstanceAttributes(): void;
  30210. /**
  30211. * Release and free the memory of a vertex array object
  30212. * @param vao defines the vertex array object to delete
  30213. */
  30214. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30215. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  30216. /**
  30217. * Creates a webGL buffer to use with instanciation
  30218. * @param capacity defines the size of the buffer
  30219. * @returns the webGL buffer
  30220. */
  30221. createInstancesBuffer(capacity: number): DataBuffer;
  30222. /**
  30223. * Delete a webGL buffer used with instanciation
  30224. * @param buffer defines the webGL buffer to delete
  30225. */
  30226. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30227. /**
  30228. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30229. * @param instancesBuffer defines the webGL buffer to update and bind
  30230. * @param data defines the data to store in the buffer
  30231. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30232. */
  30233. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30234. /**
  30235. * Apply all cached states (depth, culling, stencil and alpha)
  30236. */
  30237. applyStates(): void;
  30238. /**
  30239. * Send a draw order
  30240. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30241. * @param indexStart defines the starting index
  30242. * @param indexCount defines the number of index to draw
  30243. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30244. */
  30245. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30246. /**
  30247. * Draw a list of points
  30248. * @param verticesStart defines the index of first vertex to draw
  30249. * @param verticesCount defines the count of vertices to draw
  30250. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30251. */
  30252. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30253. /**
  30254. * Draw a list of unindexed primitives
  30255. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30256. * @param verticesStart defines the index of first vertex to draw
  30257. * @param verticesCount defines the count of vertices to draw
  30258. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30259. */
  30260. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30261. /**
  30262. * Draw a list of indexed primitives
  30263. * @param fillMode defines the primitive to use
  30264. * @param indexStart defines the starting index
  30265. * @param indexCount defines the number of index to draw
  30266. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30267. */
  30268. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30269. /**
  30270. * Draw a list of unindexed primitives
  30271. * @param fillMode defines the primitive to use
  30272. * @param verticesStart defines the index of first vertex to draw
  30273. * @param verticesCount defines the count of vertices to draw
  30274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30275. */
  30276. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30277. private _drawMode;
  30278. /** @hidden */ private _releaseEffect(effect: Effect): void;
  30279. /** @hidden */ private _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30280. /**
  30281. * Create a new effect (used to store vertex/fragment shaders)
  30282. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30283. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30284. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30285. * @param samplers defines an array of string used to represent textures
  30286. * @param defines defines the string containing the defines to use to compile the shaders
  30287. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30288. * @param onCompiled defines a function to call when the effect creation is successful
  30289. * @param onError defines a function to call when the effect creation has failed
  30290. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30291. * @returns the new Effect
  30292. */
  30293. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30294. private _compileShader;
  30295. private _compileRawShader;
  30296. /**
  30297. * Directly creates a webGL program
  30298. * @param pipelineContext defines the pipeline context to attach to
  30299. * @param vertexCode defines the vertex shader code to use
  30300. * @param fragmentCode defines the fragment shader code to use
  30301. * @param context defines the webGL context to use (if not set, the current one will be used)
  30302. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30303. * @returns the new webGL program
  30304. */
  30305. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30306. /**
  30307. * Creates a webGL program
  30308. * @param pipelineContext defines the pipeline context to attach to
  30309. * @param vertexCode defines the vertex shader code to use
  30310. * @param fragmentCode defines the fragment shader code to use
  30311. * @param defines defines the string containing the defines to use to compile the shaders
  30312. * @param context defines the webGL context to use (if not set, the current one will be used)
  30313. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30314. * @returns the new webGL program
  30315. */
  30316. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30317. /**
  30318. * Creates a new pipeline context
  30319. * @returns the new pipeline
  30320. */
  30321. createPipelineContext(): WebGLPipelineContext;
  30322. private _createShaderProgram;
  30323. private _finalizePipelineContext;
  30324. /** @hidden */ private _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30325. /** @hidden */ private _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30326. /** @hidden */ private _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30327. /**
  30328. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30329. * @param pipelineContext defines the pipeline context to use
  30330. * @param uniformsNames defines the list of uniform names
  30331. * @returns an array of webGL uniform locations
  30332. */
  30333. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30334. /**
  30335. * Gets the lsit of active attributes for a given webGL program
  30336. * @param pipelineContext defines the pipeline context to use
  30337. * @param attributesNames defines the list of attribute names to get
  30338. * @returns an array of indices indicating the offset of each attribute
  30339. */
  30340. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30341. /**
  30342. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30343. * @param effect defines the effect to activate
  30344. */
  30345. enableEffect(effect: Nullable<Effect>): void;
  30346. /**
  30347. * Set the value of an uniform to an array of int32
  30348. * @param uniform defines the webGL uniform location where to store the value
  30349. * @param array defines the array of int32 to store
  30350. */
  30351. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30352. /**
  30353. * Set the value of an uniform to an array of int32 (stored as vec2)
  30354. * @param uniform defines the webGL uniform location where to store the value
  30355. * @param array defines the array of int32 to store
  30356. */
  30357. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30358. /**
  30359. * Set the value of an uniform to an array of int32 (stored as vec3)
  30360. * @param uniform defines the webGL uniform location where to store the value
  30361. * @param array defines the array of int32 to store
  30362. */
  30363. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30364. /**
  30365. * Set the value of an uniform to an array of int32 (stored as vec4)
  30366. * @param uniform defines the webGL uniform location where to store the value
  30367. * @param array defines the array of int32 to store
  30368. */
  30369. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30370. /**
  30371. * Set the value of an uniform to an array of float32
  30372. * @param uniform defines the webGL uniform location where to store the value
  30373. * @param array defines the array of float32 to store
  30374. */
  30375. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30376. /**
  30377. * Set the value of an uniform to an array of float32 (stored as vec2)
  30378. * @param uniform defines the webGL uniform location where to store the value
  30379. * @param array defines the array of float32 to store
  30380. */
  30381. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30382. /**
  30383. * Set the value of an uniform to an array of float32 (stored as vec3)
  30384. * @param uniform defines the webGL uniform location where to store the value
  30385. * @param array defines the array of float32 to store
  30386. */
  30387. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30388. /**
  30389. * Set the value of an uniform to an array of float32 (stored as vec4)
  30390. * @param uniform defines the webGL uniform location where to store the value
  30391. * @param array defines the array of float32 to store
  30392. */
  30393. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30394. /**
  30395. * Set the value of an uniform to an array of number
  30396. * @param uniform defines the webGL uniform location where to store the value
  30397. * @param array defines the array of number to store
  30398. */
  30399. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30400. /**
  30401. * Set the value of an uniform to an array of number (stored as vec2)
  30402. * @param uniform defines the webGL uniform location where to store the value
  30403. * @param array defines the array of number to store
  30404. */
  30405. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30406. /**
  30407. * Set the value of an uniform to an array of number (stored as vec3)
  30408. * @param uniform defines the webGL uniform location where to store the value
  30409. * @param array defines the array of number to store
  30410. */
  30411. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30412. /**
  30413. * Set the value of an uniform to an array of number (stored as vec4)
  30414. * @param uniform defines the webGL uniform location where to store the value
  30415. * @param array defines the array of number to store
  30416. */
  30417. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30418. /**
  30419. * Set the value of an uniform to an array of float32 (stored as matrices)
  30420. * @param uniform defines the webGL uniform location where to store the value
  30421. * @param matrices defines the array of float32 to store
  30422. */
  30423. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30424. /**
  30425. * Set the value of an uniform to a matrix (3x3)
  30426. * @param uniform defines the webGL uniform location where to store the value
  30427. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30428. */
  30429. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30430. /**
  30431. * Set the value of an uniform to a matrix (2x2)
  30432. * @param uniform defines the webGL uniform location where to store the value
  30433. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30434. */
  30435. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30436. /**
  30437. * Set the value of an uniform to a number (int)
  30438. * @param uniform defines the webGL uniform location where to store the value
  30439. * @param value defines the int number to store
  30440. */
  30441. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30442. /**
  30443. * Set the value of an uniform to a number (float)
  30444. * @param uniform defines the webGL uniform location where to store the value
  30445. * @param value defines the float number to store
  30446. */
  30447. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30448. /**
  30449. * Set the value of an uniform to a vec2
  30450. * @param uniform defines the webGL uniform location where to store the value
  30451. * @param x defines the 1st component of the value
  30452. * @param y defines the 2nd component of the value
  30453. */
  30454. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30455. /**
  30456. * Set the value of an uniform to a vec3
  30457. * @param uniform defines the webGL uniform location where to store the value
  30458. * @param x defines the 1st component of the value
  30459. * @param y defines the 2nd component of the value
  30460. * @param z defines the 3rd component of the value
  30461. */
  30462. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30463. /**
  30464. * Set the value of an uniform to a boolean
  30465. * @param uniform defines the webGL uniform location where to store the value
  30466. * @param bool defines the boolean to store
  30467. */
  30468. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30469. /**
  30470. * Set the value of an uniform to a vec4
  30471. * @param uniform defines the webGL uniform location where to store the value
  30472. * @param x defines the 1st component of the value
  30473. * @param y defines the 2nd component of the value
  30474. * @param z defines the 3rd component of the value
  30475. * @param w defines the 4th component of the value
  30476. */
  30477. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30478. /**
  30479. * Sets a Color4 on a uniform variable
  30480. * @param uniform defines the uniform location
  30481. * @param color4 defines the value to be set
  30482. */
  30483. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30484. /**
  30485. * Set various states to the webGL context
  30486. * @param culling defines backface culling state
  30487. * @param zOffset defines the value to apply to zOffset (0 by default)
  30488. * @param force defines if states must be applied even if cache is up to date
  30489. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30490. */
  30491. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  30492. /**
  30493. * Set the z offset to apply to current rendering
  30494. * @param value defines the offset to apply
  30495. */
  30496. setZOffset(value: number): void;
  30497. /**
  30498. * Gets the current value of the zOffset
  30499. * @returns the current zOffset state
  30500. */
  30501. getZOffset(): number;
  30502. /**
  30503. * Enable or disable depth buffering
  30504. * @param enable defines the state to set
  30505. */
  30506. setDepthBuffer(enable: boolean): void;
  30507. /**
  30508. * Gets a boolean indicating if depth writing is enabled
  30509. * @returns the current depth writing state
  30510. */
  30511. getDepthWrite(): boolean;
  30512. /**
  30513. * Enable or disable depth writing
  30514. * @param enable defines the state to set
  30515. */
  30516. setDepthWrite(enable: boolean): void;
  30517. /**
  30518. * Enable or disable color writing
  30519. * @param enable defines the state to set
  30520. */
  30521. setColorWrite(enable: boolean): void;
  30522. /**
  30523. * Gets a boolean indicating if color writing is enabled
  30524. * @returns the current color writing state
  30525. */
  30526. getColorWrite(): boolean;
  30527. /**
  30528. * Sets alpha constants used by some alpha blending modes
  30529. * @param r defines the red component
  30530. * @param g defines the green component
  30531. * @param b defines the blue component
  30532. * @param a defines the alpha component
  30533. */
  30534. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  30535. /**
  30536. * Sets the current alpha mode
  30537. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30538. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30539. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30540. */
  30541. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  30542. /**
  30543. * Gets the current alpha mode
  30544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30545. * @returns the current alpha mode
  30546. */
  30547. getAlphaMode(): number;
  30548. /**
  30549. * Clears the list of texture accessible through engine.
  30550. * This can help preventing texture load conflict due to name collision.
  30551. */
  30552. clearInternalTexturesCache(): void;
  30553. /**
  30554. * Force the entire cache to be cleared
  30555. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30556. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30557. */
  30558. wipeCaches(bruteForce?: boolean): void;
  30559. /**
  30560. * Set the compressed texture format to use, based on the formats you have, and the formats
  30561. * supported by the hardware / browser.
  30562. *
  30563. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30564. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30565. * to API arguments needed to compressed textures. This puts the burden on the container
  30566. * generator to house the arcane code for determining these for current & future formats.
  30567. *
  30568. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30569. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30570. *
  30571. * Note: The result of this call is not taken into account when a texture is base64.
  30572. *
  30573. * @param formatsAvailable defines the list of those format families you have created
  30574. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30575. *
  30576. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30577. * @returns The extension selected.
  30578. */
  30579. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  30580. /** @hidden */ private _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30581. min: number;
  30582. mag: number;
  30583. };
  30584. /** @hidden */ private _createTexture(): WebGLTexture;
  30585. /**
  30586. * Usually called from Texture.ts.
  30587. * Passed information to create a WebGLTexture
  30588. * @param urlArg defines a value which contains one of the following:
  30589. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30590. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30591. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30592. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30593. * @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)
  30594. * @param scene needed for loading to the correct scene
  30595. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30596. * @param onLoad optional callback to be called upon successful completion
  30597. * @param onError optional callback to be called upon failure
  30598. * @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
  30599. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30600. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30601. * @param forcedExtension defines the extension to use to pick the right loader
  30602. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30603. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30604. */
  30605. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<Scene>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30606. /**
  30607. * @hidden
  30608. * Rescales a texture
  30609. * @param source input texutre
  30610. * @param destination destination texture
  30611. * @param scene scene to use to render the resize
  30612. * @param internalFormat format to use when resizing
  30613. * @param onComplete callback to be called when resize has completed
  30614. */ private _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<Scene>, internalFormat: number, onComplete: () => void): void;
  30615. private _unpackFlipYCached;
  30616. /**
  30617. * In case you are sharing the context with other applications, it might
  30618. * be interested to not cache the unpack flip y state to ensure a consistent
  30619. * value would be set.
  30620. */
  30621. enableUnpackFlipYCached: boolean;
  30622. /** @hidden */ private _unpackFlipY(value: boolean): void;
  30623. /** @hidden */ private _getUnpackAlignement(): number;
  30624. /**
  30625. * Creates a dynamic texture
  30626. * @param width defines the width of the texture
  30627. * @param height defines the height of the texture
  30628. * @param generateMipMaps defines if the engine should generate the mip levels
  30629. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30630. * @returns the dynamic texture inside an InternalTexture
  30631. */
  30632. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  30633. /**
  30634. * Update the sampling mode of a given texture
  30635. * @param samplingMode defines the required sampling mode
  30636. * @param texture defines the texture to update
  30637. */
  30638. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30639. /**
  30640. * Update the content of a dynamic texture
  30641. * @param texture defines the texture to update
  30642. * @param canvas defines the canvas containing the source
  30643. * @param invertY defines if data must be stored with Y axis inverted
  30644. * @param premulAlpha defines if alpha is stored as premultiplied
  30645. * @param format defines the format of the data
  30646. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  30647. */
  30648. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  30649. /**
  30650. * Update a video texture
  30651. * @param texture defines the texture to update
  30652. * @param video defines the video element to use
  30653. * @param invertY defines if data must be stored with Y axis inverted
  30654. */
  30655. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  30656. /**
  30657. * Updates a depth texture Comparison Mode and Function.
  30658. * If the comparison Function is equal to 0, the mode will be set to none.
  30659. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30660. * @param texture The texture to set the comparison function for
  30661. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30662. */
  30663. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30664. /** @hidden */ private _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30665. width: number;
  30666. height: number;
  30667. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30668. /**
  30669. * Creates a depth stencil texture.
  30670. * This is only available in WebGL 2 or with the depth texture extension available.
  30671. * @param size The size of face edge in the texture.
  30672. * @param options The options defining the texture.
  30673. * @returns The texture
  30674. */
  30675. createDepthStencilTexture(size: number | {
  30676. width: number;
  30677. height: number;
  30678. }, options: DepthTextureCreationOptions): InternalTexture;
  30679. /**
  30680. * Creates a depth stencil texture.
  30681. * This is only available in WebGL 2 or with the depth texture extension available.
  30682. * @param size The size of face edge in the texture.
  30683. * @param options The options defining the texture.
  30684. * @returns The texture
  30685. */
  30686. private _createDepthStencilTexture;
  30687. /**
  30688. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  30689. * @param renderTarget The render target to set the frame buffer for
  30690. */
  30691. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  30692. /**
  30693. * Creates a new render target texture
  30694. * @param size defines the size of the texture
  30695. * @param options defines the options used to create the texture
  30696. * @returns a new render target texture stored in an InternalTexture
  30697. */
  30698. createRenderTargetTexture(size: number | {
  30699. width: number;
  30700. height: number;
  30701. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  30702. /** @hidden */ private _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30703. /**
  30704. * Updates the sample count of a render target texture
  30705. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  30706. * @param texture defines the texture to update
  30707. * @param samples defines the sample count to set
  30708. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  30709. */
  30710. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  30711. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30712. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30713. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30714. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30715. /**
  30716. * @hidden
  30717. */ private _setCubeMapTextureParams(loadMipmap: boolean): void;
  30718. private _prepareWebGLTextureContinuation;
  30719. private _prepareWebGLTexture;
  30720. /** @hidden */ private _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  30721. /** @hidden */ private _releaseFramebufferObjects(texture: InternalTexture): void;
  30722. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  30723. private setProgram;
  30724. private _boundUniforms;
  30725. /**
  30726. * Binds an effect to the webGL context
  30727. * @param effect defines the effect to bind
  30728. */
  30729. bindSamplers(effect: Effect): void;
  30730. private _activateCurrentTexture;
  30731. /** @hidden */ private _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30732. /** @hidden */ private _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30733. /**
  30734. * Sets a texture to the webGL context from a postprocess
  30735. * @param channel defines the channel to use
  30736. * @param postProcess defines the source postprocess
  30737. */
  30738. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  30739. /**
  30740. * Binds the output of the passed in post process to the texture channel specified
  30741. * @param channel The channel the texture should be bound to
  30742. * @param postProcess The post process which's output should be bound
  30743. */
  30744. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  30745. /**
  30746. * Unbind all textures from the webGL context
  30747. */
  30748. unbindAllTextures(): void;
  30749. /**
  30750. * Sets a texture to the according uniform.
  30751. * @param channel The texture channel
  30752. * @param uniform The uniform to set
  30753. * @param texture The texture to apply
  30754. */
  30755. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30756. /**
  30757. * Sets a depth stencil texture from a render target to the according uniform.
  30758. * @param channel The texture channel
  30759. * @param uniform The uniform to set
  30760. * @param texture The render target texture containing the depth stencil texture to apply
  30761. */
  30762. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  30763. private _bindSamplerUniformToChannel;
  30764. private _getTextureWrapMode;
  30765. private _setTexture;
  30766. /**
  30767. * Sets an array of texture to the webGL context
  30768. * @param channel defines the channel where the texture array must be set
  30769. * @param uniform defines the associated uniform location
  30770. * @param textures defines the array of textures to bind
  30771. */
  30772. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30773. /** @hidden */ private _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30774. private _setTextureParameterFloat;
  30775. private _setTextureParameterInteger;
  30776. /**
  30777. * Reads pixels from the current frame buffer. Please note that this function can be slow
  30778. * @param x defines the x coordinate of the rectangle where pixels must be read
  30779. * @param y defines the y coordinate of the rectangle where pixels must be read
  30780. * @param width defines the width of the rectangle where pixels must be read
  30781. * @param height defines the height of the rectangle where pixels must be read
  30782. * @returns a Uint8Array containing RGBA colors
  30783. */
  30784. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  30785. /**
  30786. * Add an externaly attached data from its key.
  30787. * This method call will fail and return false, if such key already exists.
  30788. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  30789. * @param key the unique key that identifies the data
  30790. * @param data the data object to associate to the key for this Engine instance
  30791. * @return true if no such key were already present and the data was added successfully, false otherwise
  30792. */
  30793. addExternalData<T>(key: string, data: T): boolean;
  30794. /**
  30795. * Get an externaly attached data from its key
  30796. * @param key the unique key that identifies the data
  30797. * @return the associated data, if present (can be null), or undefined if not present
  30798. */
  30799. getExternalData<T>(key: string): T;
  30800. /**
  30801. * Get an externaly attached data from its key, create it using a factory if it's not already present
  30802. * @param key the unique key that identifies the data
  30803. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  30804. * @return the associated data, can be null if the factory returned null.
  30805. */
  30806. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  30807. /**
  30808. * Remove an externaly attached data from the Engine instance
  30809. * @param key the unique key that identifies the data
  30810. * @return true if the data was successfully removed, false if it doesn't exist
  30811. */
  30812. removeExternalData(key: string): boolean;
  30813. /**
  30814. * Unbind all vertex attributes from the webGL context
  30815. */
  30816. unbindAllAttributes(): void;
  30817. /**
  30818. * 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
  30819. */
  30820. releaseEffects(): void;
  30821. /**
  30822. * Dispose and release all associated resources
  30823. */
  30824. dispose(): void;
  30825. /**
  30826. * Display the loading screen
  30827. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30828. */
  30829. displayLoadingUI(): void;
  30830. /**
  30831. * Hide the loading screen
  30832. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30833. */
  30834. hideLoadingUI(): void;
  30835. /**
  30836. * Gets the current loading screen object
  30837. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30838. */
  30839. /**
  30840. * Sets the current loading screen object
  30841. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30842. */
  30843. loadingScreen: ILoadingScreen;
  30844. /**
  30845. * Sets the current loading screen text
  30846. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30847. */
  30848. loadingUIText: string;
  30849. /**
  30850. * Sets the current loading screen background color
  30851. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  30852. */
  30853. loadingUIBackgroundColor: string;
  30854. /**
  30855. * Attach a new callback raised when context lost event is fired
  30856. * @param callback defines the callback to call
  30857. */
  30858. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30859. /**
  30860. * Attach a new callback raised when context restored event is fired
  30861. * @param callback defines the callback to call
  30862. */
  30863. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  30864. /**
  30865. * Gets the source code of the vertex shader associated with a specific webGL program
  30866. * @param program defines the program to use
  30867. * @returns a string containing the source code of the vertex shader associated with the program
  30868. */
  30869. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  30870. /**
  30871. * Gets the source code of the fragment shader associated with a specific webGL program
  30872. * @param program defines the program to use
  30873. * @returns a string containing the source code of the fragment shader associated with the program
  30874. */
  30875. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  30876. /**
  30877. * Get the current error code of the webGL context
  30878. * @returns the error code
  30879. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  30880. */
  30881. getError(): number;
  30882. /**
  30883. * Gets the current framerate
  30884. * @returns a number representing the framerate
  30885. */
  30886. getFps(): number;
  30887. /**
  30888. * Gets the time spent between current and previous frame
  30889. * @returns a number representing the delta time in ms
  30890. */
  30891. getDeltaTime(): number;
  30892. private _measureFps;
  30893. /** @hidden */ private _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  30894. private _canRenderToFloatFramebuffer;
  30895. private _canRenderToHalfFloatFramebuffer;
  30896. private _canRenderToFramebuffer;
  30897. /** @hidden */ private _getWebGLTextureType(type: number): number;
  30898. /** @hidden */ private _getInternalFormat(format: number): number;
  30899. /** @hidden */ private _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  30900. /** @hidden */ private _getRGBAMultiSampleBufferFormat(type: number): number;
  30901. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  30902. /** @hidden */ private _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  30903. /**
  30904. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  30905. * @returns true if the engine can be created
  30906. * @ignorenaming
  30907. */
  30908. static isSupported(): boolean;
  30909. /**
  30910. * Find the next highest power of two.
  30911. * @param x Number to start search from.
  30912. * @return Next highest power of two.
  30913. */
  30914. static CeilingPOT(x: number): number;
  30915. /**
  30916. * Find the next lowest power of two.
  30917. * @param x Number to start search from.
  30918. * @return Next lowest power of two.
  30919. */
  30920. static FloorPOT(x: number): number;
  30921. /**
  30922. * Find the nearest power of two.
  30923. * @param x Number to start search from.
  30924. * @return Next nearest power of two.
  30925. */
  30926. static NearestPOT(x: number): number;
  30927. /**
  30928. * Get the closest exponent of two
  30929. * @param value defines the value to approximate
  30930. * @param max defines the maximum value to return
  30931. * @param mode defines how to define the closest value
  30932. * @returns closest exponent of two of the given value
  30933. */
  30934. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  30935. /**
  30936. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  30937. * @param func - the function to be called
  30938. * @param requester - the object that will request the next frame. Falls back to window.
  30939. * @returns frame number
  30940. */
  30941. static QueueNewFrame(func: () => void, requester?: any): number;
  30942. /**
  30943. * Ask the browser to promote the current element to pointerlock mode
  30944. * @param element defines the DOM element to promote
  30945. */ private static _RequestPointerlock(element: HTMLElement): void;
  30946. /**
  30947. * Asks the browser to exit pointerlock mode
  30948. */ private static _ExitPointerlock(): void;
  30949. /**
  30950. * Ask the browser to promote the current element to fullscreen rendering mode
  30951. * @param element defines the DOM element to promote
  30952. */ private static _RequestFullscreen(element: HTMLElement): void;
  30953. /**
  30954. * Asks the browser to exit fullscreen mode
  30955. */ private static _ExitFullscreen(): void;
  30956. }
  30957. }
  30958. declare module BABYLON {
  30959. /**
  30960. * The engine store class is responsible to hold all the instances of Engine and Scene created
  30961. * during the life time of the application.
  30962. */
  30963. export class EngineStore {
  30964. /** Gets the list of created engines */
  30965. static Instances: Engine[];
  30966. /** @hidden */ private static _LastCreatedScene: Nullable<Scene>;
  30967. /**
  30968. * Gets the latest created engine
  30969. */
  30970. static readonly LastCreatedEngine: Nullable<Engine>;
  30971. /**
  30972. * Gets the latest created scene
  30973. */
  30974. static readonly LastCreatedScene: Nullable<Scene>;
  30975. /**
  30976. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  30977. * @ignorenaming
  30978. */
  30979. static UseFallbackTexture: boolean;
  30980. /**
  30981. * Texture content used if a texture cannot loaded
  30982. * @ignorenaming
  30983. */
  30984. static FallbackTexture: string;
  30985. }
  30986. }
  30987. declare module BABYLON {
  30988. /**
  30989. * Helper class that provides a small promise polyfill
  30990. */
  30991. export class PromisePolyfill {
  30992. /**
  30993. * Static function used to check if the polyfill is required
  30994. * If this is the case then the function will inject the polyfill to window.Promise
  30995. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  30996. */
  30997. static Apply(force?: boolean): void;
  30998. }
  30999. }
  31000. declare module BABYLON {
  31001. /**
  31002. * Interface for screenshot methods with describe argument called `size` as object with options
  31003. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  31004. */
  31005. export interface IScreenshotSize {
  31006. /**
  31007. * number in pixels for canvas height
  31008. */
  31009. height?: number;
  31010. /**
  31011. * multiplier allowing render at a higher or lower resolution
  31012. * If value is defined then height and width will be ignored and taken from camera
  31013. */
  31014. precision?: number;
  31015. /**
  31016. * number in pixels for canvas width
  31017. */
  31018. width?: number;
  31019. }
  31020. }
  31021. declare module BABYLON {
  31022. interface IColor4Like {
  31023. r: float;
  31024. g: float;
  31025. b: float;
  31026. a: float;
  31027. }
  31028. /**
  31029. * Class containing a set of static utilities functions
  31030. */
  31031. export class Tools {
  31032. /**
  31033. * Gets or sets the base URL to use to load assets
  31034. */
  31035. static BaseUrl: string;
  31036. /**
  31037. * Enable/Disable Custom HTTP Request Headers globally.
  31038. * default = false
  31039. * @see CustomRequestHeaders
  31040. */
  31041. static UseCustomRequestHeaders: boolean;
  31042. /**
  31043. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31044. * i.e. when loading files, where the server/service expects an Authorization header
  31045. */
  31046. static CustomRequestHeaders: {
  31047. [key: string]: string;
  31048. };
  31049. /**
  31050. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31051. */
  31052. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31053. /**
  31054. * Default behaviour for cors in the application.
  31055. * It can be a string if the expected behavior is identical in the entire app.
  31056. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31057. */
  31058. static CorsBehavior: string | ((url: string | string[]) => string);
  31059. /**
  31060. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31061. * @ignorenaming
  31062. */
  31063. static UseFallbackTexture: boolean;
  31064. /**
  31065. * Use this object to register external classes like custom textures or material
  31066. * to allow the laoders to instantiate them
  31067. */
  31068. static RegisteredExternalClasses: {
  31069. [key: string]: Object;
  31070. };
  31071. /**
  31072. * Texture content used if a texture cannot loaded
  31073. * @ignorenaming
  31074. */
  31075. static fallbackTexture: string;
  31076. /**
  31077. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31078. * @param u defines the coordinate on X axis
  31079. * @param v defines the coordinate on Y axis
  31080. * @param width defines the width of the source data
  31081. * @param height defines the height of the source data
  31082. * @param pixels defines the source byte array
  31083. * @param color defines the output color
  31084. */
  31085. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  31086. /**
  31087. * Interpolates between a and b via alpha
  31088. * @param a The lower value (returned when alpha = 0)
  31089. * @param b The upper value (returned when alpha = 1)
  31090. * @param alpha The interpolation-factor
  31091. * @return The mixed value
  31092. */
  31093. static Mix(a: number, b: number, alpha: number): number;
  31094. /**
  31095. * Tries to instantiate a new object from a given class name
  31096. * @param className defines the class name to instantiate
  31097. * @returns the new object or null if the system was not able to do the instantiation
  31098. */
  31099. static Instantiate(className: string): any;
  31100. /**
  31101. * Provides a slice function that will work even on IE
  31102. * @param data defines the array to slice
  31103. * @param start defines the start of the data (optional)
  31104. * @param end defines the end of the data (optional)
  31105. * @returns the new sliced array
  31106. */
  31107. static Slice<T>(data: T, start?: number, end?: number): T;
  31108. /**
  31109. * Polyfill for setImmediate
  31110. * @param action defines the action to execute after the current execution block
  31111. */
  31112. static SetImmediate(action: () => void): void;
  31113. /**
  31114. * Function indicating if a number is an exponent of 2
  31115. * @param value defines the value to test
  31116. * @returns true if the value is an exponent of 2
  31117. */
  31118. static IsExponentOfTwo(value: number): boolean;
  31119. private static _tmpFloatArray;
  31120. /**
  31121. * Returns the nearest 32-bit single precision float representation of a Number
  31122. * @param value A Number. If the parameter is of a different type, it will get converted
  31123. * to a number or to NaN if it cannot be converted
  31124. * @returns number
  31125. */
  31126. static FloatRound(value: number): number;
  31127. /**
  31128. * Extracts the filename from a path
  31129. * @param path defines the path to use
  31130. * @returns the filename
  31131. */
  31132. static GetFilename(path: string): string;
  31133. /**
  31134. * Extracts the "folder" part of a path (everything before the filename).
  31135. * @param uri The URI to extract the info from
  31136. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31137. * @returns The "folder" part of the path
  31138. */
  31139. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31140. /**
  31141. * Extracts text content from a DOM element hierarchy
  31142. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31143. */
  31144. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31145. /**
  31146. * Convert an angle in radians to degrees
  31147. * @param angle defines the angle to convert
  31148. * @returns the angle in degrees
  31149. */
  31150. static ToDegrees(angle: number): number;
  31151. /**
  31152. * Convert an angle in degrees to radians
  31153. * @param angle defines the angle to convert
  31154. * @returns the angle in radians
  31155. */
  31156. static ToRadians(angle: number): number;
  31157. /**
  31158. * Encode a buffer to a base64 string
  31159. * @param buffer defines the buffer to encode
  31160. * @returns the encoded string
  31161. */
  31162. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31163. /**
  31164. * Returns an array if obj is not an array
  31165. * @param obj defines the object to evaluate as an array
  31166. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31167. * @returns either obj directly if obj is an array or a new array containing obj
  31168. */
  31169. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31170. /**
  31171. * Gets the pointer prefix to use
  31172. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31173. */
  31174. static GetPointerPrefix(): string;
  31175. /**
  31176. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31177. * @param url define the url we are trying
  31178. * @param element define the dom element where to configure the cors policy
  31179. */
  31180. static SetCorsBehavior(url: string | string[], element: {
  31181. crossOrigin: string | null;
  31182. }): void;
  31183. /**
  31184. * Removes unwanted characters from an url
  31185. * @param url defines the url to clean
  31186. * @returns the cleaned url
  31187. */
  31188. static CleanUrl(url: string): string;
  31189. /**
  31190. * Gets or sets a function used to pre-process url before using them to load assets
  31191. */
  31192. static PreprocessUrl: (url: string) => string;
  31193. /**
  31194. * Loads an image as an HTMLImageElement.
  31195. * @param input url string, ArrayBuffer, or Blob to load
  31196. * @param onLoad callback called when the image successfully loads
  31197. * @param onError callback called when the image fails to load
  31198. * @param offlineProvider offline provider for caching
  31199. * @returns the HTMLImageElement of the loaded image
  31200. */
  31201. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31202. /**
  31203. * Loads a file
  31204. * @param url url string, ArrayBuffer, or Blob to load
  31205. * @param onSuccess callback called when the file successfully loads
  31206. * @param onProgress callback called while file is loading (if the server supports this mode)
  31207. * @param offlineProvider defines the offline provider for caching
  31208. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31209. * @param onError callback called when the file fails to load
  31210. * @returns a file request object
  31211. */
  31212. 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;
  31213. /**
  31214. * Loads a file from a url
  31215. * @param url the file url to load
  31216. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  31217. */
  31218. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  31219. /**
  31220. * Load a script (identified by an url). When the url returns, the
  31221. * content of this file is added into a new script element, attached to the DOM (body element)
  31222. * @param scriptUrl defines the url of the script to laod
  31223. * @param onSuccess defines the callback called when the script is loaded
  31224. * @param onError defines the callback to call if an error occurs
  31225. * @param scriptId defines the id of the script element
  31226. */
  31227. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31228. /**
  31229. * Load an asynchronous script (identified by an url). When the url returns, the
  31230. * content of this file is added into a new script element, attached to the DOM (body element)
  31231. * @param scriptUrl defines the url of the script to laod
  31232. * @param scriptId defines the id of the script element
  31233. * @returns a promise request object
  31234. */
  31235. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  31236. /**
  31237. * Loads a file from a blob
  31238. * @param fileToLoad defines the blob to use
  31239. * @param callback defines the callback to call when data is loaded
  31240. * @param progressCallback defines the callback to call during loading process
  31241. * @returns a file request object
  31242. */
  31243. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31244. /**
  31245. * Loads a file
  31246. * @param fileToLoad defines the file to load
  31247. * @param callback defines the callback to call when data is loaded
  31248. * @param progressCallBack defines the callback to call during loading process
  31249. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31250. * @returns a file request object
  31251. */
  31252. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31253. /**
  31254. * Creates a data url from a given string content
  31255. * @param content defines the content to convert
  31256. * @returns the new data url link
  31257. */
  31258. static FileAsURL(content: string): string;
  31259. /**
  31260. * Format the given number to a specific decimal format
  31261. * @param value defines the number to format
  31262. * @param decimals defines the number of decimals to use
  31263. * @returns the formatted string
  31264. */
  31265. static Format(value: number, decimals?: number): string;
  31266. /**
  31267. * Tries to copy an object by duplicating every property
  31268. * @param source defines the source object
  31269. * @param destination defines the target object
  31270. * @param doNotCopyList defines a list of properties to avoid
  31271. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31272. */
  31273. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31274. /**
  31275. * Gets a boolean indicating if the given object has no own property
  31276. * @param obj defines the object to test
  31277. * @returns true if object has no own property
  31278. */
  31279. static IsEmpty(obj: any): boolean;
  31280. /**
  31281. * Function used to register events at window level
  31282. * @param windowElement defines the Window object to use
  31283. * @param events defines the events to register
  31284. */
  31285. static RegisterTopRootEvents(windowElement: Window, events: {
  31286. name: string;
  31287. handler: Nullable<(e: FocusEvent) => any>;
  31288. }[]): void;
  31289. /**
  31290. * Function used to unregister events from window level
  31291. * @param windowElement defines the Window object to use
  31292. * @param events defines the events to unregister
  31293. */
  31294. static UnregisterTopRootEvents(windowElement: Window, events: {
  31295. name: string;
  31296. handler: Nullable<(e: FocusEvent) => any>;
  31297. }[]): void;
  31298. /**
  31299. * @ignore
  31300. */ private static _ScreenshotCanvas: HTMLCanvasElement;
  31301. /**
  31302. * Dumps the current bound framebuffer
  31303. * @param width defines the rendering width
  31304. * @param height defines the rendering height
  31305. * @param engine defines the hosting engine
  31306. * @param successCallback defines the callback triggered once the data are available
  31307. * @param mimeType defines the mime type of the result
  31308. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31309. */
  31310. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31311. /**
  31312. * Converts the canvas data to blob.
  31313. * This acts as a polyfill for browsers not supporting the to blob function.
  31314. * @param canvas Defines the canvas to extract the data from
  31315. * @param successCallback Defines the callback triggered once the data are available
  31316. * @param mimeType Defines the mime type of the result
  31317. */
  31318. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31319. /**
  31320. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31321. * @param successCallback defines the callback triggered once the data are available
  31322. * @param mimeType defines the mime type of the result
  31323. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31324. */
  31325. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31326. /**
  31327. * Downloads a blob in the browser
  31328. * @param blob defines the blob to download
  31329. * @param fileName defines the name of the downloaded file
  31330. */
  31331. static Download(blob: Blob, fileName: string): void;
  31332. /**
  31333. * Captures a screenshot of the current rendering
  31334. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31335. * @param engine defines the rendering engine
  31336. * @param camera defines the source camera
  31337. * @param size This parameter can be set to a single number or to an object with the
  31338. * following (optional) properties: precision, width, height. If a single number is passed,
  31339. * it will be used for both width and height. If an object is passed, the screenshot size
  31340. * will be derived from the parameters. The precision property is a multiplier allowing
  31341. * rendering at a higher or lower resolution
  31342. * @param successCallback defines the callback receives a single parameter which contains the
  31343. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31344. * src parameter of an <img> to display it
  31345. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31346. * Check your browser for supported MIME types
  31347. */
  31348. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  31349. /**
  31350. * Captures a screenshot of the current rendering
  31351. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31352. * @param engine defines the rendering engine
  31353. * @param camera defines the source camera
  31354. * @param size This parameter can be set to a single number or to an object with the
  31355. * following (optional) properties: precision, width, height. If a single number is passed,
  31356. * it will be used for both width and height. If an object is passed, the screenshot size
  31357. * will be derived from the parameters. The precision property is a multiplier allowing
  31358. * rendering at a higher or lower resolution
  31359. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31360. * Check your browser for supported MIME types
  31361. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31362. * to the src parameter of an <img> to display it
  31363. */
  31364. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  31365. /**
  31366. * Generates an image screenshot from the specified camera.
  31367. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31368. * @param engine The engine to use for rendering
  31369. * @param camera The camera to use for rendering
  31370. * @param size This parameter can be set to a single number or to an object with the
  31371. * following (optional) properties: precision, width, height. If a single number is passed,
  31372. * it will be used for both width and height. If an object is passed, the screenshot size
  31373. * will be derived from the parameters. The precision property is a multiplier allowing
  31374. * rendering at a higher or lower resolution
  31375. * @param successCallback The callback receives a single parameter which contains the
  31376. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31377. * src parameter of an <img> to display it
  31378. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31379. * Check your browser for supported MIME types
  31380. * @param samples Texture samples (default: 1)
  31381. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31382. * @param fileName A name for for the downloaded file.
  31383. */
  31384. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31385. /**
  31386. * Generates an image screenshot from the specified camera.
  31387. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31388. * @param engine The engine to use for rendering
  31389. * @param camera The camera to use for rendering
  31390. * @param size This parameter can be set to a single number or to an object with the
  31391. * following (optional) properties: precision, width, height. If a single number is passed,
  31392. * it will be used for both width and height. If an object is passed, the screenshot size
  31393. * will be derived from the parameters. The precision property is a multiplier allowing
  31394. * rendering at a higher or lower resolution
  31395. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31396. * Check your browser for supported MIME types
  31397. * @param samples Texture samples (default: 1)
  31398. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31399. * @param fileName A name for for the downloaded file.
  31400. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  31401. * to the src parameter of an <img> to display it
  31402. */
  31403. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  31404. /**
  31405. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31406. * Be aware Math.random() could cause collisions, but:
  31407. * "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"
  31408. * @returns a pseudo random id
  31409. */
  31410. static RandomId(): string;
  31411. /**
  31412. * Test if the given uri is a base64 string
  31413. * @param uri The uri to test
  31414. * @return True if the uri is a base64 string or false otherwise
  31415. */
  31416. static IsBase64(uri: string): boolean;
  31417. /**
  31418. * Decode the given base64 uri.
  31419. * @param uri The uri to decode
  31420. * @return The decoded base64 data.
  31421. */
  31422. static DecodeBase64(uri: string): ArrayBuffer;
  31423. /**
  31424. * Gets the absolute url.
  31425. * @param url the input url
  31426. * @return the absolute url
  31427. */
  31428. static GetAbsoluteUrl(url: string): string;
  31429. /**
  31430. * No log
  31431. */
  31432. static readonly NoneLogLevel: number;
  31433. /**
  31434. * Only message logs
  31435. */
  31436. static readonly MessageLogLevel: number;
  31437. /**
  31438. * Only warning logs
  31439. */
  31440. static readonly WarningLogLevel: number;
  31441. /**
  31442. * Only error logs
  31443. */
  31444. static readonly ErrorLogLevel: number;
  31445. /**
  31446. * All logs
  31447. */
  31448. static readonly AllLogLevel: number;
  31449. /**
  31450. * Gets a value indicating the number of loading errors
  31451. * @ignorenaming
  31452. */
  31453. static readonly errorsCount: number;
  31454. /**
  31455. * Callback called when a new log is added
  31456. */
  31457. static OnNewCacheEntry: (entry: string) => void;
  31458. /**
  31459. * Log a message to the console
  31460. * @param message defines the message to log
  31461. */
  31462. static Log(message: string): void;
  31463. /**
  31464. * Write a warning message to the console
  31465. * @param message defines the message to log
  31466. */
  31467. static Warn(message: string): void;
  31468. /**
  31469. * Write an error message to the console
  31470. * @param message defines the message to log
  31471. */
  31472. static Error(message: string): void;
  31473. /**
  31474. * Gets current log cache (list of logs)
  31475. */
  31476. static readonly LogCache: string;
  31477. /**
  31478. * Clears the log cache
  31479. */
  31480. static ClearLogCache(): void;
  31481. /**
  31482. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  31483. */
  31484. static LogLevels: number;
  31485. /**
  31486. * Checks if the window object exists
  31487. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  31488. */
  31489. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  31490. /**
  31491. * No performance log
  31492. */
  31493. static readonly PerformanceNoneLogLevel: number;
  31494. /**
  31495. * Use user marks to log performance
  31496. */
  31497. static readonly PerformanceUserMarkLogLevel: number;
  31498. /**
  31499. * Log performance to the console
  31500. */
  31501. static readonly PerformanceConsoleLogLevel: number;
  31502. private static _performance;
  31503. /**
  31504. * Sets the current performance log level
  31505. */
  31506. static PerformanceLogLevel: number;
  31507. private static _StartPerformanceCounterDisabled;
  31508. private static _EndPerformanceCounterDisabled;
  31509. private static _StartUserMark;
  31510. private static _EndUserMark;
  31511. private static _StartPerformanceConsole;
  31512. private static _EndPerformanceConsole;
  31513. /**
  31514. * Starts a performance counter
  31515. */
  31516. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31517. /**
  31518. * Ends a specific performance coutner
  31519. */
  31520. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  31521. /**
  31522. * Gets either window.performance.now() if supported or Date.now() else
  31523. */
  31524. static readonly Now: number;
  31525. /**
  31526. * This method will return the name of the class used to create the instance of the given object.
  31527. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  31528. * @param object the object to get the class name from
  31529. * @param isType defines if the object is actually a type
  31530. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  31531. */
  31532. static GetClassName(object: any, isType?: boolean): string;
  31533. /**
  31534. * Gets the first element of an array satisfying a given predicate
  31535. * @param array defines the array to browse
  31536. * @param predicate defines the predicate to use
  31537. * @returns null if not found or the element
  31538. */
  31539. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  31540. /**
  31541. * This method will return the name of the full name of the class, including its owning module (if any).
  31542. * 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).
  31543. * @param object the object to get the class name from
  31544. * @param isType defines if the object is actually a type
  31545. * @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.
  31546. * @ignorenaming
  31547. */
  31548. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  31549. /**
  31550. * Returns a promise that resolves after the given amount of time.
  31551. * @param delay Number of milliseconds to delay
  31552. * @returns Promise that resolves after the given amount of time
  31553. */
  31554. static DelayAsync(delay: number): Promise<void>;
  31555. }
  31556. /**
  31557. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  31558. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  31559. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  31560. * @param name The name of the class, case should be preserved
  31561. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  31562. */
  31563. export function className(name: string, module?: string): (target: Object) => void;
  31564. /**
  31565. * An implementation of a loop for asynchronous functions.
  31566. */
  31567. export class AsyncLoop {
  31568. /**
  31569. * Defines the number of iterations for the loop
  31570. */
  31571. iterations: number;
  31572. /**
  31573. * Defines the current index of the loop.
  31574. */
  31575. index: number;
  31576. private _done;
  31577. private _fn;
  31578. private _successCallback;
  31579. /**
  31580. * Constructor.
  31581. * @param iterations the number of iterations.
  31582. * @param func the function to run each iteration
  31583. * @param successCallback the callback that will be called upon succesful execution
  31584. * @param offset starting offset.
  31585. */
  31586. constructor(
  31587. /**
  31588. * Defines the number of iterations for the loop
  31589. */
  31590. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  31591. /**
  31592. * Execute the next iteration. Must be called after the last iteration was finished.
  31593. */
  31594. executeNext(): void;
  31595. /**
  31596. * Break the loop and run the success callback.
  31597. */
  31598. breakLoop(): void;
  31599. /**
  31600. * Create and run an async loop.
  31601. * @param iterations the number of iterations.
  31602. * @param fn the function to run each iteration
  31603. * @param successCallback the callback that will be called upon succesful execution
  31604. * @param offset starting offset.
  31605. * @returns the created async loop object
  31606. */
  31607. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  31608. /**
  31609. * A for-loop that will run a given number of iterations synchronous and the rest async.
  31610. * @param iterations total number of iterations
  31611. * @param syncedIterations number of synchronous iterations in each async iteration.
  31612. * @param fn the function to call each iteration.
  31613. * @param callback a success call back that will be called when iterating stops.
  31614. * @param breakFunction a break condition (optional)
  31615. * @param timeout timeout settings for the setTimeout function. default - 0.
  31616. * @returns the created async loop object
  31617. */
  31618. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  31619. }
  31620. }
  31621. declare module BABYLON {
  31622. /** @hidden */
  31623. export interface ICollisionCoordinator {
  31624. createCollider(): Collider;
  31625. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31626. init(scene: Scene): void;
  31627. }
  31628. /** @hidden */
  31629. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  31630. private _scene;
  31631. private _scaledPosition;
  31632. private _scaledVelocity;
  31633. private _finalPosition;
  31634. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  31635. createCollider(): Collider;
  31636. init(scene: Scene): void;
  31637. private _collideWithWorld;
  31638. }
  31639. }
  31640. declare module BABYLON {
  31641. /**
  31642. * Class used to manage all inputs for the scene.
  31643. */
  31644. export class InputManager {
  31645. /** The distance in pixel that you have to move to prevent some events */
  31646. static DragMovementThreshold: number;
  31647. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  31648. static LongPressDelay: number;
  31649. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  31650. static DoubleClickDelay: number;
  31651. /** If you need to check double click without raising a single click at first click, enable this flag */
  31652. static ExclusiveDoubleClickMode: boolean;
  31653. private _wheelEventName;
  31654. private _onPointerMove;
  31655. private _onPointerDown;
  31656. private _onPointerUp;
  31657. private _initClickEvent;
  31658. private _initActionManager;
  31659. private _delayedSimpleClick;
  31660. private _delayedSimpleClickTimeout;
  31661. private _previousDelayedSimpleClickTimeout;
  31662. private _meshPickProceed;
  31663. private _previousButtonPressed;
  31664. private _currentPickResult;
  31665. private _previousPickResult;
  31666. private _totalPointersPressed;
  31667. private _doubleClickOccured;
  31668. private _pointerOverMesh;
  31669. private _pickedDownMesh;
  31670. private _pickedUpMesh;
  31671. private _pointerX;
  31672. private _pointerY;
  31673. private _unTranslatedPointerX;
  31674. private _unTranslatedPointerY;
  31675. private _startingPointerPosition;
  31676. private _previousStartingPointerPosition;
  31677. private _startingPointerTime;
  31678. private _previousStartingPointerTime;
  31679. private _pointerCaptures;
  31680. private _onKeyDown;
  31681. private _onKeyUp;
  31682. private _onCanvasFocusObserver;
  31683. private _onCanvasBlurObserver;
  31684. private _scene;
  31685. /**
  31686. * Creates a new InputManager
  31687. * @param scene defines the hosting scene
  31688. */
  31689. constructor(scene: Scene);
  31690. /**
  31691. * Gets the mesh that is currently under the pointer
  31692. */
  31693. readonly meshUnderPointer: Nullable<AbstractMesh>;
  31694. /**
  31695. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  31696. */
  31697. readonly unTranslatedPointer: Vector2;
  31698. /**
  31699. * Gets or sets the current on-screen X position of the pointer
  31700. */
  31701. pointerX: number;
  31702. /**
  31703. * Gets or sets the current on-screen Y position of the pointer
  31704. */
  31705. pointerY: number;
  31706. private _updatePointerPosition;
  31707. private _processPointerMove;
  31708. private _setRayOnPointerInfo;
  31709. private _checkPrePointerObservable;
  31710. /**
  31711. * Use this method to simulate a pointer move on a mesh
  31712. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31713. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31714. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31715. */
  31716. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31717. /**
  31718. * Use this method to simulate a pointer down on a mesh
  31719. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31720. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31721. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31722. */
  31723. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  31724. private _processPointerDown;
  31725. /** @hidden */ private _isPointerSwiping(): boolean;
  31726. /**
  31727. * Use this method to simulate a pointer up on a mesh
  31728. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  31729. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  31730. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  31731. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  31732. */
  31733. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  31734. private _processPointerUp;
  31735. /**
  31736. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  31737. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  31738. * @returns true if the pointer was captured
  31739. */
  31740. isPointerCaptured(pointerId?: number): boolean;
  31741. /**
  31742. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  31743. * @param attachUp defines if you want to attach events to pointerup
  31744. * @param attachDown defines if you want to attach events to pointerdown
  31745. * @param attachMove defines if you want to attach events to pointermove
  31746. */
  31747. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  31748. /**
  31749. * Detaches all event handlers
  31750. */
  31751. detachControl(): void;
  31752. /**
  31753. * Force the value of meshUnderPointer
  31754. * @param mesh defines the mesh to use
  31755. */
  31756. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  31757. /**
  31758. * Gets the mesh under the pointer
  31759. * @returns a Mesh or null if no mesh is under the pointer
  31760. */
  31761. getPointerOverMesh(): Nullable<AbstractMesh>;
  31762. }
  31763. }
  31764. declare module BABYLON {
  31765. /**
  31766. * Helper class used to generate session unique ID
  31767. */
  31768. export class UniqueIdGenerator {
  31769. private static _UniqueIdCounter;
  31770. /**
  31771. * Gets an unique (relatively to the current scene) Id
  31772. */
  31773. static readonly UniqueId: number;
  31774. }
  31775. }
  31776. declare module BABYLON {
  31777. /**
  31778. * This class defines the direct association between an animation and a target
  31779. */
  31780. export class TargetedAnimation {
  31781. /**
  31782. * Animation to perform
  31783. */
  31784. animation: Animation;
  31785. /**
  31786. * Target to animate
  31787. */
  31788. target: any;
  31789. /**
  31790. * Serialize the object
  31791. * @returns the JSON object representing the current entity
  31792. */
  31793. serialize(): any;
  31794. }
  31795. /**
  31796. * Use this class to create coordinated animations on multiple targets
  31797. */
  31798. export class AnimationGroup implements IDisposable {
  31799. /** The name of the animation group */
  31800. name: string;
  31801. private _scene;
  31802. private _targetedAnimations;
  31803. private _animatables;
  31804. private _from;
  31805. private _to;
  31806. private _isStarted;
  31807. private _isPaused;
  31808. private _speedRatio;
  31809. private _loopAnimation;
  31810. /**
  31811. * Gets or sets the unique id of the node
  31812. */
  31813. uniqueId: number;
  31814. /**
  31815. * This observable will notify when one animation have ended
  31816. */
  31817. onAnimationEndObservable: Observable<TargetedAnimation>;
  31818. /**
  31819. * Observer raised when one animation loops
  31820. */
  31821. onAnimationLoopObservable: Observable<TargetedAnimation>;
  31822. /**
  31823. * This observable will notify when all animations have ended.
  31824. */
  31825. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  31826. /**
  31827. * This observable will notify when all animations have paused.
  31828. */
  31829. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  31830. /**
  31831. * This observable will notify when all animations are playing.
  31832. */
  31833. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  31834. /**
  31835. * Gets the first frame
  31836. */
  31837. readonly from: number;
  31838. /**
  31839. * Gets the last frame
  31840. */
  31841. readonly to: number;
  31842. /**
  31843. * Define if the animations are started
  31844. */
  31845. readonly isStarted: boolean;
  31846. /**
  31847. * Gets a value indicating that the current group is playing
  31848. */
  31849. readonly isPlaying: boolean;
  31850. /**
  31851. * Gets or sets the speed ratio to use for all animations
  31852. */
  31853. /**
  31854. * Gets or sets the speed ratio to use for all animations
  31855. */
  31856. speedRatio: number;
  31857. /**
  31858. * Gets or sets if all animations should loop or not
  31859. */
  31860. loopAnimation: boolean;
  31861. /**
  31862. * Gets the targeted animations for this animation group
  31863. */
  31864. readonly targetedAnimations: Array<TargetedAnimation>;
  31865. /**
  31866. * returning the list of animatables controlled by this animation group.
  31867. */
  31868. readonly animatables: Array<Animatable>;
  31869. /**
  31870. * Instantiates a new Animation Group.
  31871. * This helps managing several animations at once.
  31872. * @see http://doc.babylonjs.com/how_to/group
  31873. * @param name Defines the name of the group
  31874. * @param scene Defines the scene the group belongs to
  31875. */
  31876. constructor(
  31877. /** The name of the animation group */
  31878. name: string, scene?: Nullable<Scene>);
  31879. /**
  31880. * Add an animation (with its target) in the group
  31881. * @param animation defines the animation we want to add
  31882. * @param target defines the target of the animation
  31883. * @returns the TargetedAnimation object
  31884. */
  31885. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  31886. /**
  31887. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  31888. * It can add constant keys at begin or end
  31889. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  31890. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  31891. * @returns the animation group
  31892. */
  31893. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  31894. /**
  31895. * Start all animations on given targets
  31896. * @param loop defines if animations must loop
  31897. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  31898. * @param from defines the from key (optional)
  31899. * @param to defines the to key (optional)
  31900. * @returns the current animation group
  31901. */
  31902. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  31903. /**
  31904. * Pause all animations
  31905. * @returns the animation group
  31906. */
  31907. pause(): AnimationGroup;
  31908. /**
  31909. * Play all animations to initial state
  31910. * This function will start() the animations if they were not started or will restart() them if they were paused
  31911. * @param loop defines if animations must loop
  31912. * @returns the animation group
  31913. */
  31914. play(loop?: boolean): AnimationGroup;
  31915. /**
  31916. * Reset all animations to initial state
  31917. * @returns the animation group
  31918. */
  31919. reset(): AnimationGroup;
  31920. /**
  31921. * Restart animations from key 0
  31922. * @returns the animation group
  31923. */
  31924. restart(): AnimationGroup;
  31925. /**
  31926. * Stop all animations
  31927. * @returns the animation group
  31928. */
  31929. stop(): AnimationGroup;
  31930. /**
  31931. * Set animation weight for all animatables
  31932. * @param weight defines the weight to use
  31933. * @return the animationGroup
  31934. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31935. */
  31936. setWeightForAllAnimatables(weight: number): AnimationGroup;
  31937. /**
  31938. * Synchronize and normalize all animatables with a source animatable
  31939. * @param root defines the root animatable to synchronize with
  31940. * @return the animationGroup
  31941. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  31942. */
  31943. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  31944. /**
  31945. * Goes to a specific frame in this animation group
  31946. * @param frame the frame number to go to
  31947. * @return the animationGroup
  31948. */
  31949. goToFrame(frame: number): AnimationGroup;
  31950. /**
  31951. * Dispose all associated resources
  31952. */
  31953. dispose(): void;
  31954. private _checkAnimationGroupEnded;
  31955. /**
  31956. * Clone the current animation group and returns a copy
  31957. * @param newName defines the name of the new group
  31958. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  31959. * @returns the new aniamtion group
  31960. */
  31961. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  31962. /**
  31963. * Serializes the animationGroup to an object
  31964. * @returns Serialized object
  31965. */
  31966. serialize(): any;
  31967. /**
  31968. * Returns a new AnimationGroup object parsed from the source provided.
  31969. * @param parsedAnimationGroup defines the source
  31970. * @param scene defines the scene that will receive the animationGroup
  31971. * @returns a new AnimationGroup
  31972. */
  31973. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  31974. /**
  31975. * Returns the string "AnimationGroup"
  31976. * @returns "AnimationGroup"
  31977. */
  31978. getClassName(): string;
  31979. /**
  31980. * Creates a detailled string about the object
  31981. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  31982. * @returns a string representing the object
  31983. */
  31984. toString(fullDetails?: boolean): string;
  31985. }
  31986. }
  31987. declare module BABYLON {
  31988. /**
  31989. * Define an interface for all classes that will hold resources
  31990. */
  31991. export interface IDisposable {
  31992. /**
  31993. * Releases all held resources
  31994. */
  31995. dispose(): void;
  31996. }
  31997. /** Interface defining initialization parameters for Scene class */
  31998. export interface SceneOptions {
  31999. /**
  32000. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32001. * It will improve performance when the number of geometries becomes important.
  32002. */
  32003. useGeometryUniqueIdsMap?: boolean;
  32004. /**
  32005. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32006. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32007. */
  32008. useMaterialMeshMap?: boolean;
  32009. /**
  32010. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32011. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32012. */
  32013. useClonedMeshhMap?: boolean;
  32014. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  32015. virtual?: boolean;
  32016. }
  32017. /**
  32018. * Represents a scene to be rendered by the engine.
  32019. * @see http://doc.babylonjs.com/features/scene
  32020. */
  32021. export class Scene extends AbstractScene implements IAnimatable {
  32022. /** The fog is deactivated */
  32023. static readonly FOGMODE_NONE: number;
  32024. /** The fog density is following an exponential function */
  32025. static readonly FOGMODE_EXP: number;
  32026. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32027. static readonly FOGMODE_EXP2: number;
  32028. /** The fog density is following a linear function. */
  32029. static readonly FOGMODE_LINEAR: number;
  32030. /**
  32031. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32032. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32033. */
  32034. static MinDeltaTime: number;
  32035. /**
  32036. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32037. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32038. */
  32039. static MaxDeltaTime: number;
  32040. /**
  32041. * Factory used to create the default material.
  32042. * @param name The name of the material to create
  32043. * @param scene The scene to create the material for
  32044. * @returns The default material
  32045. */
  32046. static DefaultMaterialFactory(scene: Scene): Material;
  32047. /**
  32048. * Factory used to create the a collision coordinator.
  32049. * @returns The collision coordinator
  32050. */
  32051. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32052. /** @hidden */ private _inputManager: InputManager;
  32053. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32054. cameraToUseForPointers: Nullable<Camera>;
  32055. /** @hidden */ protected readonly _isScene: boolean;
  32056. /**
  32057. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32058. */
  32059. autoClear: boolean;
  32060. /**
  32061. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32062. */
  32063. autoClearDepthAndStencil: boolean;
  32064. /**
  32065. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32066. */
  32067. clearColor: Color4;
  32068. /**
  32069. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32070. */
  32071. ambientColor: Color3;
  32072. /**
  32073. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32074. * It should only be one of the following (if not the default embedded one):
  32075. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32076. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32077. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32078. * The material properties need to be setup according to the type of texture in use.
  32079. */
  32080. environmentBRDFTexture: BaseTexture;
  32081. /** @hidden */
  32082. protected _environmentTexture: Nullable<BaseTexture>;
  32083. /**
  32084. * Texture used in all pbr material as the reflection texture.
  32085. * As in the majority of the scene they are the same (exception for multi room and so on),
  32086. * this is easier to reference from here than from all the materials.
  32087. */
  32088. /**
  32089. * Texture used in all pbr material as the reflection texture.
  32090. * As in the majority of the scene they are the same (exception for multi room and so on),
  32091. * this is easier to set here than in all the materials.
  32092. */
  32093. environmentTexture: Nullable<BaseTexture>;
  32094. /** @hidden */
  32095. protected _environmentIntensity: number;
  32096. /**
  32097. * Intensity of the environment in all pbr material.
  32098. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32099. * As in the majority of the scene they are the same (exception for multi room and so on),
  32100. * this is easier to reference from here than from all the materials.
  32101. */
  32102. /**
  32103. * Intensity of the environment in all pbr material.
  32104. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  32105. * As in the majority of the scene they are the same (exception for multi room and so on),
  32106. * this is easier to set here than in all the materials.
  32107. */
  32108. environmentIntensity: number;
  32109. /** @hidden */
  32110. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32111. /**
  32112. * Default image processing configuration used either in the rendering
  32113. * Forward main pass or through the imageProcessingPostProcess if present.
  32114. * As in the majority of the scene they are the same (exception for multi camera),
  32115. * this is easier to reference from here than from all the materials and post process.
  32116. *
  32117. * No setter as we it is a shared configuration, you can set the values instead.
  32118. */
  32119. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32120. private _forceWireframe;
  32121. /**
  32122. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32123. */
  32124. forceWireframe: boolean;
  32125. private _forcePointsCloud;
  32126. /**
  32127. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32128. */
  32129. forcePointsCloud: boolean;
  32130. /**
  32131. * Gets or sets the active clipplane 1
  32132. */
  32133. clipPlane: Nullable<Plane>;
  32134. /**
  32135. * Gets or sets the active clipplane 2
  32136. */
  32137. clipPlane2: Nullable<Plane>;
  32138. /**
  32139. * Gets or sets the active clipplane 3
  32140. */
  32141. clipPlane3: Nullable<Plane>;
  32142. /**
  32143. * Gets or sets the active clipplane 4
  32144. */
  32145. clipPlane4: Nullable<Plane>;
  32146. /**
  32147. * Gets or sets a boolean indicating if animations are enabled
  32148. */
  32149. animationsEnabled: boolean;
  32150. private _animationPropertiesOverride;
  32151. /**
  32152. * Gets or sets the animation properties override
  32153. */
  32154. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32155. /**
  32156. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32157. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32158. */
  32159. useConstantAnimationDeltaTime: boolean;
  32160. /**
  32161. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32162. * Please note that it requires to run a ray cast through the scene on every frame
  32163. */
  32164. constantlyUpdateMeshUnderPointer: boolean;
  32165. /**
  32166. * Defines the HTML cursor to use when hovering over interactive elements
  32167. */
  32168. hoverCursor: string;
  32169. /**
  32170. * Defines the HTML default cursor to use (empty by default)
  32171. */
  32172. defaultCursor: string;
  32173. /**
  32174. * This is used to call preventDefault() on pointer down
  32175. * in order to block unwanted artifacts like system double clicks
  32176. */
  32177. preventDefaultOnPointerDown: boolean;
  32178. /**
  32179. * This is used to call preventDefault() on pointer up
  32180. * in order to block unwanted artifacts like system double clicks
  32181. */
  32182. preventDefaultOnPointerUp: boolean;
  32183. /**
  32184. * Gets or sets user defined metadata
  32185. */
  32186. metadata: any;
  32187. /**
  32188. * For internal use only. Please do not use.
  32189. */
  32190. reservedDataStore: any;
  32191. /**
  32192. * Gets the name of the plugin used to load this scene (null by default)
  32193. */
  32194. loadingPluginName: string;
  32195. /**
  32196. * Use this array to add regular expressions used to disable offline support for specific urls
  32197. */
  32198. disableOfflineSupportExceptionRules: RegExp[];
  32199. /**
  32200. * An event triggered when the scene is disposed.
  32201. */
  32202. onDisposeObservable: Observable<Scene>;
  32203. private _onDisposeObserver;
  32204. /** Sets a function to be executed when this scene is disposed. */
  32205. onDispose: () => void;
  32206. /**
  32207. * An event triggered before rendering the scene (right after animations and physics)
  32208. */
  32209. onBeforeRenderObservable: Observable<Scene>;
  32210. private _onBeforeRenderObserver;
  32211. /** Sets a function to be executed before rendering this scene */
  32212. beforeRender: Nullable<() => void>;
  32213. /**
  32214. * An event triggered after rendering the scene
  32215. */
  32216. onAfterRenderObservable: Observable<Scene>;
  32217. /**
  32218. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  32219. */
  32220. onAfterRenderCameraObservable: Observable<Camera>;
  32221. private _onAfterRenderObserver;
  32222. /** Sets a function to be executed after rendering this scene */
  32223. afterRender: Nullable<() => void>;
  32224. /**
  32225. * An event triggered before animating the scene
  32226. */
  32227. onBeforeAnimationsObservable: Observable<Scene>;
  32228. /**
  32229. * An event triggered after animations processing
  32230. */
  32231. onAfterAnimationsObservable: Observable<Scene>;
  32232. /**
  32233. * An event triggered before draw calls are ready to be sent
  32234. */
  32235. onBeforeDrawPhaseObservable: Observable<Scene>;
  32236. /**
  32237. * An event triggered after draw calls have been sent
  32238. */
  32239. onAfterDrawPhaseObservable: Observable<Scene>;
  32240. /**
  32241. * An event triggered when the scene is ready
  32242. */
  32243. onReadyObservable: Observable<Scene>;
  32244. /**
  32245. * An event triggered before rendering a camera
  32246. */
  32247. onBeforeCameraRenderObservable: Observable<Camera>;
  32248. private _onBeforeCameraRenderObserver;
  32249. /** Sets a function to be executed before rendering a camera*/
  32250. beforeCameraRender: () => void;
  32251. /**
  32252. * An event triggered after rendering a camera
  32253. */
  32254. onAfterCameraRenderObservable: Observable<Camera>;
  32255. private _onAfterCameraRenderObserver;
  32256. /** Sets a function to be executed after rendering a camera*/
  32257. afterCameraRender: () => void;
  32258. /**
  32259. * An event triggered when active meshes evaluation is about to start
  32260. */
  32261. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32262. /**
  32263. * An event triggered when active meshes evaluation is done
  32264. */
  32265. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32266. /**
  32267. * An event triggered when particles rendering is about to start
  32268. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32269. */
  32270. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32271. /**
  32272. * An event triggered when particles rendering is done
  32273. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32274. */
  32275. onAfterParticlesRenderingObservable: Observable<Scene>;
  32276. /**
  32277. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32278. */
  32279. onDataLoadedObservable: Observable<Scene>;
  32280. /**
  32281. * An event triggered when a camera is created
  32282. */
  32283. onNewCameraAddedObservable: Observable<Camera>;
  32284. /**
  32285. * An event triggered when a camera is removed
  32286. */
  32287. onCameraRemovedObservable: Observable<Camera>;
  32288. /**
  32289. * An event triggered when a light is created
  32290. */
  32291. onNewLightAddedObservable: Observable<Light>;
  32292. /**
  32293. * An event triggered when a light is removed
  32294. */
  32295. onLightRemovedObservable: Observable<Light>;
  32296. /**
  32297. * An event triggered when a geometry is created
  32298. */
  32299. onNewGeometryAddedObservable: Observable<Geometry>;
  32300. /**
  32301. * An event triggered when a geometry is removed
  32302. */
  32303. onGeometryRemovedObservable: Observable<Geometry>;
  32304. /**
  32305. * An event triggered when a transform node is created
  32306. */
  32307. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32308. /**
  32309. * An event triggered when a transform node is removed
  32310. */
  32311. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32312. /**
  32313. * An event triggered when a mesh is created
  32314. */
  32315. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32316. /**
  32317. * An event triggered when a mesh is removed
  32318. */
  32319. onMeshRemovedObservable: Observable<AbstractMesh>;
  32320. /**
  32321. * An event triggered when a skeleton is created
  32322. */
  32323. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32324. /**
  32325. * An event triggered when a skeleton is removed
  32326. */
  32327. onSkeletonRemovedObservable: Observable<Skeleton>;
  32328. /**
  32329. * An event triggered when a material is created
  32330. */
  32331. onNewMaterialAddedObservable: Observable<Material>;
  32332. /**
  32333. * An event triggered when a material is removed
  32334. */
  32335. onMaterialRemovedObservable: Observable<Material>;
  32336. /**
  32337. * An event triggered when a texture is created
  32338. */
  32339. onNewTextureAddedObservable: Observable<BaseTexture>;
  32340. /**
  32341. * An event triggered when a texture is removed
  32342. */
  32343. onTextureRemovedObservable: Observable<BaseTexture>;
  32344. /**
  32345. * An event triggered when render targets are about to be rendered
  32346. * Can happen multiple times per frame.
  32347. */
  32348. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32349. /**
  32350. * An event triggered when render targets were rendered.
  32351. * Can happen multiple times per frame.
  32352. */
  32353. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32354. /**
  32355. * An event triggered before calculating deterministic simulation step
  32356. */
  32357. onBeforeStepObservable: Observable<Scene>;
  32358. /**
  32359. * An event triggered after calculating deterministic simulation step
  32360. */
  32361. onAfterStepObservable: Observable<Scene>;
  32362. /**
  32363. * An event triggered when the activeCamera property is updated
  32364. */
  32365. onActiveCameraChanged: Observable<Scene>;
  32366. /**
  32367. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32368. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32369. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32370. */
  32371. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32372. /**
  32373. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32374. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32375. * If you wish to register an Observer only for a given set of renderingGroup, use the mask with a combination of the renderingGroup index elevated to the power of two (1 for renderingGroup 0, 2 for renderingrOup1, 4 for 2 and 8 for 3)
  32376. */
  32377. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32378. /**
  32379. * This Observable will when a mesh has been imported into the scene.
  32380. */
  32381. onMeshImportedObservable: Observable<AbstractMesh>;
  32382. /**
  32383. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32384. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32385. */
  32386. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32387. /** @hidden */ private _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32388. /**
  32389. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32390. */
  32391. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32392. /**
  32393. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32394. */
  32395. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32396. /**
  32397. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32398. */
  32399. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32400. /** Callback called when a pointer move is detected */
  32401. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32402. /** Callback called when a pointer down is detected */
  32403. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32404. /** Callback called when a pointer up is detected */
  32405. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32406. /** Callback called when a pointer pick is detected */
  32407. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32408. /**
  32409. * This observable event is triggered when any ponter event is triggered. It is registered during Scene.attachControl() and it is called BEFORE the 3D engine process anything (mesh/sprite picking for instance).
  32410. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32411. */
  32412. onPrePointerObservable: Observable<PointerInfoPre>;
  32413. /**
  32414. * Observable event triggered each time an input event is received from the rendering canvas
  32415. */
  32416. onPointerObservable: Observable<PointerInfo>;
  32417. /**
  32418. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32419. */
  32420. readonly unTranslatedPointer: Vector2;
  32421. /**
  32422. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  32423. */
  32424. static DragMovementThreshold: number;
  32425. /**
  32426. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  32427. */
  32428. static LongPressDelay: number;
  32429. /**
  32430. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  32431. */
  32432. static DoubleClickDelay: number;
  32433. /** If you need to check double click without raising a single click at first click, enable this flag */
  32434. static ExclusiveDoubleClickMode: boolean;
  32435. /** @hidden */ private _mirroredCameraPosition: Nullable<Vector3>;
  32436. /**
  32437. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32438. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32439. */
  32440. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32441. /**
  32442. * Observable event triggered each time an keyboard event is received from the hosting window
  32443. */
  32444. onKeyboardObservable: Observable<KeyboardInfo>;
  32445. private _useRightHandedSystem;
  32446. /**
  32447. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32448. */
  32449. useRightHandedSystem: boolean;
  32450. private _timeAccumulator;
  32451. private _currentStepId;
  32452. private _currentInternalStep;
  32453. /**
  32454. * Sets the step Id used by deterministic lock step
  32455. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32456. * @param newStepId defines the step Id
  32457. */
  32458. setStepId(newStepId: number): void;
  32459. /**
  32460. * Gets the step Id used by deterministic lock step
  32461. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32462. * @returns the step Id
  32463. */
  32464. getStepId(): number;
  32465. /**
  32466. * Gets the internal step used by deterministic lock step
  32467. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32468. * @returns the internal step
  32469. */
  32470. getInternalStep(): number;
  32471. private _fogEnabled;
  32472. /**
  32473. * Gets or sets a boolean indicating if fog is enabled on this scene
  32474. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32475. * (Default is true)
  32476. */
  32477. fogEnabled: boolean;
  32478. private _fogMode;
  32479. /**
  32480. * Gets or sets the fog mode to use
  32481. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32482. * | mode | value |
  32483. * | --- | --- |
  32484. * | FOGMODE_NONE | 0 |
  32485. * | FOGMODE_EXP | 1 |
  32486. * | FOGMODE_EXP2 | 2 |
  32487. * | FOGMODE_LINEAR | 3 |
  32488. */
  32489. fogMode: number;
  32490. /**
  32491. * Gets or sets the fog color to use
  32492. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32493. * (Default is Color3(0.2, 0.2, 0.3))
  32494. */
  32495. fogColor: Color3;
  32496. /**
  32497. * Gets or sets the fog density to use
  32498. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32499. * (Default is 0.1)
  32500. */
  32501. fogDensity: number;
  32502. /**
  32503. * Gets or sets the fog start distance to use
  32504. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32505. * (Default is 0)
  32506. */
  32507. fogStart: number;
  32508. /**
  32509. * Gets or sets the fog end distance to use
  32510. * @see http://doc.babylonjs.com/babylon101/environment#fog
  32511. * (Default is 1000)
  32512. */
  32513. fogEnd: number;
  32514. private _shadowsEnabled;
  32515. /**
  32516. * Gets or sets a boolean indicating if shadows are enabled on this scene
  32517. */
  32518. shadowsEnabled: boolean;
  32519. private _lightsEnabled;
  32520. /**
  32521. * Gets or sets a boolean indicating if lights are enabled on this scene
  32522. */
  32523. lightsEnabled: boolean;
  32524. /** All of the active cameras added to this scene. */
  32525. activeCameras: Camera[];
  32526. /** @hidden */ private _activeCamera: Nullable<Camera>;
  32527. /** Gets or sets the current active camera */
  32528. activeCamera: Nullable<Camera>;
  32529. private _defaultMaterial;
  32530. /** The default material used on meshes when no material is affected */
  32531. /** The default material used on meshes when no material is affected */
  32532. defaultMaterial: Material;
  32533. private _texturesEnabled;
  32534. /**
  32535. * Gets or sets a boolean indicating if textures are enabled on this scene
  32536. */
  32537. texturesEnabled: boolean;
  32538. /**
  32539. * Gets or sets a boolean indicating if particles are enabled on this scene
  32540. */
  32541. particlesEnabled: boolean;
  32542. /**
  32543. * Gets or sets a boolean indicating if sprites are enabled on this scene
  32544. */
  32545. spritesEnabled: boolean;
  32546. private _skeletonsEnabled;
  32547. /**
  32548. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  32549. */
  32550. skeletonsEnabled: boolean;
  32551. /**
  32552. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  32553. */
  32554. lensFlaresEnabled: boolean;
  32555. /**
  32556. * Gets or sets a boolean indicating if collisions are enabled on this scene
  32557. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32558. */
  32559. collisionsEnabled: boolean;
  32560. private _collisionCoordinator;
  32561. /** @hidden */
  32562. readonly collisionCoordinator: ICollisionCoordinator;
  32563. /**
  32564. * Defines the gravity applied to this scene (used only for collisions)
  32565. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  32566. */
  32567. gravity: Vector3;
  32568. /**
  32569. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  32570. */
  32571. postProcessesEnabled: boolean;
  32572. /**
  32573. * The list of postprocesses added to the scene
  32574. */
  32575. postProcesses: PostProcess[];
  32576. /**
  32577. * Gets the current postprocess manager
  32578. */
  32579. postProcessManager: PostProcessManager;
  32580. /**
  32581. * Gets or sets a boolean indicating if render targets are enabled on this scene
  32582. */
  32583. renderTargetsEnabled: boolean;
  32584. /**
  32585. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  32586. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  32587. */
  32588. dumpNextRenderTargets: boolean;
  32589. /**
  32590. * The list of user defined render targets added to the scene
  32591. */
  32592. customRenderTargets: RenderTargetTexture[];
  32593. /**
  32594. * Defines if texture loading must be delayed
  32595. * If true, textures will only be loaded when they need to be rendered
  32596. */
  32597. useDelayedTextureLoading: boolean;
  32598. /**
  32599. * Gets the list of meshes imported to the scene through SceneLoader
  32600. */
  32601. importedMeshesFiles: String[];
  32602. /**
  32603. * Gets or sets a boolean indicating if probes are enabled on this scene
  32604. */
  32605. probesEnabled: boolean;
  32606. /**
  32607. * Gets or sets the current offline provider to use to store scene data
  32608. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  32609. */
  32610. offlineProvider: IOfflineProvider;
  32611. /**
  32612. * Gets or sets the action manager associated with the scene
  32613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  32614. */
  32615. actionManager: AbstractActionManager;
  32616. private _meshesForIntersections;
  32617. /**
  32618. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  32619. */
  32620. proceduralTexturesEnabled: boolean;
  32621. private _engine;
  32622. private _totalVertices;
  32623. /** @hidden */ private _activeIndices: PerfCounter;
  32624. /** @hidden */ private _activeParticles: PerfCounter;
  32625. /** @hidden */ private _activeBones: PerfCounter;
  32626. private _animationRatio;
  32627. /** @hidden */ private _animationTimeLast: number;
  32628. /** @hidden */ private _animationTime: number;
  32629. /**
  32630. * Gets or sets a general scale for animation speed
  32631. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  32632. */
  32633. animationTimeScale: number;
  32634. /** @hidden */ private _cachedMaterial: Nullable<Material>;
  32635. /** @hidden */ private _cachedEffect: Nullable<Effect>;
  32636. /** @hidden */ private _cachedVisibility: Nullable<number>;
  32637. private _renderId;
  32638. private _frameId;
  32639. private _executeWhenReadyTimeoutId;
  32640. private _intermediateRendering;
  32641. private _viewUpdateFlag;
  32642. private _projectionUpdateFlag;
  32643. /** @hidden */ private _toBeDisposed: Nullable<IDisposable>[];
  32644. private _activeRequests;
  32645. /** @hidden */ private _pendingData: any[];
  32646. private _isDisposed;
  32647. /**
  32648. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  32649. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  32650. */
  32651. dispatchAllSubMeshesOfActiveMeshes: boolean;
  32652. private _activeMeshes;
  32653. private _processedMaterials;
  32654. private _renderTargets;
  32655. /** @hidden */ private _activeParticleSystems: SmartArray<IParticleSystem>;
  32656. private _activeSkeletons;
  32657. private _softwareSkinnedMeshes;
  32658. private _renderingManager;
  32659. /** @hidden */ private _activeAnimatables: Animatable[];
  32660. private _transformMatrix;
  32661. private _sceneUbo;
  32662. /** @hidden */ private _viewMatrix: Matrix;
  32663. private _projectionMatrix;
  32664. /** @hidden */ private _forcedViewPosition: Nullable<Vector3>;
  32665. /** @hidden */ private _frustumPlanes: Plane[];
  32666. /**
  32667. * Gets the list of frustum planes (built from the active camera)
  32668. */
  32669. readonly frustumPlanes: Plane[];
  32670. /**
  32671. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  32672. * This is useful if there are more lights that the maximum simulteanous authorized
  32673. */
  32674. requireLightSorting: boolean;
  32675. /** @hidden */
  32676. readonly useMaterialMeshMap: boolean;
  32677. /** @hidden */
  32678. readonly useClonedMeshhMap: boolean;
  32679. private _externalData;
  32680. private _uid;
  32681. /**
  32682. * @hidden
  32683. * Backing store of defined scene components.
  32684. */ private _components: ISceneComponent[];
  32685. /**
  32686. * @hidden
  32687. * Backing store of defined scene components.
  32688. */ private _serializableComponents: ISceneSerializableComponent[];
  32689. /**
  32690. * List of components to register on the next registration step.
  32691. */
  32692. private _transientComponents;
  32693. /**
  32694. * Registers the transient components if needed.
  32695. */
  32696. private _registerTransientComponents;
  32697. /**
  32698. * @hidden
  32699. * Add a component to the scene.
  32700. * Note that the ccomponent could be registered on th next frame if this is called after
  32701. * the register component stage.
  32702. * @param component Defines the component to add to the scene
  32703. */ private _addComponent(component: ISceneComponent): void;
  32704. /**
  32705. * @hidden
  32706. * Gets a component from the scene.
  32707. * @param name defines the name of the component to retrieve
  32708. * @returns the component or null if not present
  32709. */ private _getComponent(name: string): Nullable<ISceneComponent>;
  32710. /**
  32711. * @hidden
  32712. * Defines the actions happening before camera updates.
  32713. */ private _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  32714. /**
  32715. * @hidden
  32716. * Defines the actions happening before clear the canvas.
  32717. */ private _beforeClearStage: Stage<SimpleStageAction>;
  32718. /**
  32719. * @hidden
  32720. * Defines the actions when collecting render targets for the frame.
  32721. */ private _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32722. /**
  32723. * @hidden
  32724. * Defines the actions happening for one camera in the frame.
  32725. */ private _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  32726. /**
  32727. * @hidden
  32728. * Defines the actions happening during the per mesh ready checks.
  32729. */ private _isReadyForMeshStage: Stage<MeshStageAction>;
  32730. /**
  32731. * @hidden
  32732. * Defines the actions happening before evaluate active mesh checks.
  32733. */ private _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  32734. /**
  32735. * @hidden
  32736. * Defines the actions happening during the evaluate sub mesh checks.
  32737. */ private _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  32738. /**
  32739. * @hidden
  32740. * Defines the actions happening during the active mesh stage.
  32741. */ private _activeMeshStage: Stage<ActiveMeshStageAction>;
  32742. /**
  32743. * @hidden
  32744. * Defines the actions happening during the per camera render target step.
  32745. */ private _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  32746. /**
  32747. * @hidden
  32748. * Defines the actions happening just before the active camera is drawing.
  32749. */ private _beforeCameraDrawStage: Stage<CameraStageAction>;
  32750. /**
  32751. * @hidden
  32752. * Defines the actions happening just before a render target is drawing.
  32753. */ private _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32754. /**
  32755. * @hidden
  32756. * Defines the actions happening just before a rendering group is drawing.
  32757. */ private _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32758. /**
  32759. * @hidden
  32760. * Defines the actions happening just before a mesh is drawing.
  32761. */ private _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32762. /**
  32763. * @hidden
  32764. * Defines the actions happening just after a mesh has been drawn.
  32765. */ private _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  32766. /**
  32767. * @hidden
  32768. * Defines the actions happening just after a rendering group has been drawn.
  32769. */ private _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  32770. /**
  32771. * @hidden
  32772. * Defines the actions happening just after the active camera has been drawn.
  32773. */ private _afterCameraDrawStage: Stage<CameraStageAction>;
  32774. /**
  32775. * @hidden
  32776. * Defines the actions happening just after a render target has been drawn.
  32777. */ private _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  32778. /**
  32779. * @hidden
  32780. * Defines the actions happening just after rendering all cameras and computing intersections.
  32781. */ private _afterRenderStage: Stage<SimpleStageAction>;
  32782. /**
  32783. * @hidden
  32784. * Defines the actions happening when a pointer move event happens.
  32785. */ private _pointerMoveStage: Stage<PointerMoveStageAction>;
  32786. /**
  32787. * @hidden
  32788. * Defines the actions happening when a pointer down event happens.
  32789. */ private _pointerDownStage: Stage<PointerUpDownStageAction>;
  32790. /**
  32791. * @hidden
  32792. * Defines the actions happening when a pointer up event happens.
  32793. */ private _pointerUpStage: Stage<PointerUpDownStageAction>;
  32794. /**
  32795. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  32796. */
  32797. private geometriesByUniqueId;
  32798. /**
  32799. * Creates a new Scene
  32800. * @param engine defines the engine to use to render this scene
  32801. * @param options defines the scene options
  32802. */
  32803. constructor(engine: Engine, options?: SceneOptions);
  32804. /**
  32805. * Gets a string idenfifying the name of the class
  32806. * @returns "Scene" string
  32807. */
  32808. getClassName(): string;
  32809. private _defaultMeshCandidates;
  32810. /**
  32811. * @hidden
  32812. */ private _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  32813. private _defaultSubMeshCandidates;
  32814. /**
  32815. * @hidden
  32816. */ private _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  32817. /**
  32818. * Sets the default candidate providers for the scene.
  32819. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  32820. * and getCollidingSubMeshCandidates to their default function
  32821. */
  32822. setDefaultCandidateProviders(): void;
  32823. /**
  32824. * Gets the mesh that is currently under the pointer
  32825. */
  32826. readonly meshUnderPointer: Nullable<AbstractMesh>;
  32827. /**
  32828. * Gets or sets the current on-screen X position of the pointer
  32829. */
  32830. pointerX: number;
  32831. /**
  32832. * Gets or sets the current on-screen Y position of the pointer
  32833. */
  32834. pointerY: number;
  32835. /**
  32836. * Gets the cached material (ie. the latest rendered one)
  32837. * @returns the cached material
  32838. */
  32839. getCachedMaterial(): Nullable<Material>;
  32840. /**
  32841. * Gets the cached effect (ie. the latest rendered one)
  32842. * @returns the cached effect
  32843. */
  32844. getCachedEffect(): Nullable<Effect>;
  32845. /**
  32846. * Gets the cached visibility state (ie. the latest rendered one)
  32847. * @returns the cached visibility state
  32848. */
  32849. getCachedVisibility(): Nullable<number>;
  32850. /**
  32851. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  32852. * @param material defines the current material
  32853. * @param effect defines the current effect
  32854. * @param visibility defines the current visibility state
  32855. * @returns true if one parameter is not cached
  32856. */
  32857. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  32858. /**
  32859. * Gets the engine associated with the scene
  32860. * @returns an Engine
  32861. */
  32862. getEngine(): Engine;
  32863. /**
  32864. * Gets the total number of vertices rendered per frame
  32865. * @returns the total number of vertices rendered per frame
  32866. */
  32867. getTotalVertices(): number;
  32868. /**
  32869. * Gets the performance counter for total vertices
  32870. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32871. */
  32872. readonly totalVerticesPerfCounter: PerfCounter;
  32873. /**
  32874. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  32875. * @returns the total number of active indices rendered per frame
  32876. */
  32877. getActiveIndices(): number;
  32878. /**
  32879. * Gets the performance counter for active indices
  32880. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32881. */
  32882. readonly totalActiveIndicesPerfCounter: PerfCounter;
  32883. /**
  32884. * Gets the total number of active particles rendered per frame
  32885. * @returns the total number of active particles rendered per frame
  32886. */
  32887. getActiveParticles(): number;
  32888. /**
  32889. * Gets the performance counter for active particles
  32890. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32891. */
  32892. readonly activeParticlesPerfCounter: PerfCounter;
  32893. /**
  32894. * Gets the total number of active bones rendered per frame
  32895. * @returns the total number of active bones rendered per frame
  32896. */
  32897. getActiveBones(): number;
  32898. /**
  32899. * Gets the performance counter for active bones
  32900. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  32901. */
  32902. readonly activeBonesPerfCounter: PerfCounter;
  32903. /**
  32904. * Gets the array of active meshes
  32905. * @returns an array of AbstractMesh
  32906. */
  32907. getActiveMeshes(): SmartArray<AbstractMesh>;
  32908. /**
  32909. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  32910. * @returns a number
  32911. */
  32912. getAnimationRatio(): number;
  32913. /**
  32914. * Gets an unique Id for the current render phase
  32915. * @returns a number
  32916. */
  32917. getRenderId(): number;
  32918. /**
  32919. * Gets an unique Id for the current frame
  32920. * @returns a number
  32921. */
  32922. getFrameId(): number;
  32923. /** Call this function if you want to manually increment the render Id*/
  32924. incrementRenderId(): void;
  32925. private _createUbo;
  32926. /**
  32927. * Use this method to simulate a pointer move on a mesh
  32928. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32929. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32930. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32931. * @returns the current scene
  32932. */
  32933. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32934. /**
  32935. * Use this method to simulate a pointer down on a mesh
  32936. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32937. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32938. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32939. * @returns the current scene
  32940. */
  32941. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  32942. /**
  32943. * Use this method to simulate a pointer up on a mesh
  32944. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  32945. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  32946. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  32947. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  32948. * @returns the current scene
  32949. */
  32950. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  32951. /**
  32952. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  32953. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  32954. * @returns true if the pointer was captured
  32955. */
  32956. isPointerCaptured(pointerId?: number): boolean;
  32957. /**
  32958. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  32959. * @param attachUp defines if you want to attach events to pointerup
  32960. * @param attachDown defines if you want to attach events to pointerdown
  32961. * @param attachMove defines if you want to attach events to pointermove
  32962. */
  32963. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  32964. /** Detaches all event handlers*/
  32965. detachControl(): void;
  32966. /**
  32967. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  32968. * Delay loaded resources are not taking in account
  32969. * @return true if all required resources are ready
  32970. */
  32971. isReady(): boolean;
  32972. /** Resets all cached information relative to material (including effect and visibility) */
  32973. resetCachedMaterial(): void;
  32974. /**
  32975. * Registers a function to be called before every frame render
  32976. * @param func defines the function to register
  32977. */
  32978. registerBeforeRender(func: () => void): void;
  32979. /**
  32980. * Unregisters a function called before every frame render
  32981. * @param func defines the function to unregister
  32982. */
  32983. unregisterBeforeRender(func: () => void): void;
  32984. /**
  32985. * Registers a function to be called after every frame render
  32986. * @param func defines the function to register
  32987. */
  32988. registerAfterRender(func: () => void): void;
  32989. /**
  32990. * Unregisters a function called after every frame render
  32991. * @param func defines the function to unregister
  32992. */
  32993. unregisterAfterRender(func: () => void): void;
  32994. private _executeOnceBeforeRender;
  32995. /**
  32996. * The provided function will run before render once and will be disposed afterwards.
  32997. * A timeout delay can be provided so that the function will be executed in N ms.
  32998. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  32999. * @param func The function to be executed.
  33000. * @param timeout optional delay in ms
  33001. */
  33002. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33003. /** @hidden */ private _addPendingData(data: any): void;
  33004. /** @hidden */ private _removePendingData(data: any): void;
  33005. /**
  33006. * Returns the number of items waiting to be loaded
  33007. * @returns the number of items waiting to be loaded
  33008. */
  33009. getWaitingItemsCount(): number;
  33010. /**
  33011. * Returns a boolean indicating if the scene is still loading data
  33012. */
  33013. readonly isLoading: boolean;
  33014. /**
  33015. * Registers a function to be executed when the scene is ready
  33016. * @param {Function} func - the function to be executed
  33017. */
  33018. executeWhenReady(func: () => void): void;
  33019. /**
  33020. * Returns a promise that resolves when the scene is ready
  33021. * @returns A promise that resolves when the scene is ready
  33022. */
  33023. whenReadyAsync(): Promise<void>;
  33024. /** @hidden */ private _checkIsReady(): void;
  33025. /**
  33026. * Gets all animatable attached to the scene
  33027. */
  33028. readonly animatables: Animatable[];
  33029. /**
  33030. * Resets the last animation time frame.
  33031. * Useful to override when animations start running when loading a scene for the first time.
  33032. */
  33033. resetLastAnimationTimeFrame(): void;
  33034. /**
  33035. * Gets the current view matrix
  33036. * @returns a Matrix
  33037. */
  33038. getViewMatrix(): Matrix;
  33039. /**
  33040. * Gets the current projection matrix
  33041. * @returns a Matrix
  33042. */
  33043. getProjectionMatrix(): Matrix;
  33044. /**
  33045. * Gets the current transform matrix
  33046. * @returns a Matrix made of View * Projection
  33047. */
  33048. getTransformMatrix(): Matrix;
  33049. /**
  33050. * Sets the current transform matrix
  33051. * @param viewL defines the View matrix to use
  33052. * @param projectionL defines the Projection matrix to use
  33053. * @param viewR defines the right View matrix to use (if provided)
  33054. * @param projectionR defines the right Projection matrix to use (if provided)
  33055. */
  33056. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33057. /**
  33058. * Gets the uniform buffer used to store scene data
  33059. * @returns a UniformBuffer
  33060. */
  33061. getSceneUniformBuffer(): UniformBuffer;
  33062. /**
  33063. * Gets an unique (relatively to the current scene) Id
  33064. * @returns an unique number for the scene
  33065. */
  33066. getUniqueId(): number;
  33067. /**
  33068. * Add a mesh to the list of scene's meshes
  33069. * @param newMesh defines the mesh to add
  33070. * @param recursive if all child meshes should also be added to the scene
  33071. */
  33072. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33073. /**
  33074. * Remove a mesh for the list of scene's meshes
  33075. * @param toRemove defines the mesh to remove
  33076. * @param recursive if all child meshes should also be removed from the scene
  33077. * @returns the index where the mesh was in the mesh list
  33078. */
  33079. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33080. /**
  33081. * Add a transform node to the list of scene's transform nodes
  33082. * @param newTransformNode defines the transform node to add
  33083. */
  33084. addTransformNode(newTransformNode: TransformNode): void;
  33085. /**
  33086. * Remove a transform node for the list of scene's transform nodes
  33087. * @param toRemove defines the transform node to remove
  33088. * @returns the index where the transform node was in the transform node list
  33089. */
  33090. removeTransformNode(toRemove: TransformNode): number;
  33091. /**
  33092. * Remove a skeleton for the list of scene's skeletons
  33093. * @param toRemove defines the skeleton to remove
  33094. * @returns the index where the skeleton was in the skeleton list
  33095. */
  33096. removeSkeleton(toRemove: Skeleton): number;
  33097. /**
  33098. * Remove a morph target for the list of scene's morph targets
  33099. * @param toRemove defines the morph target to remove
  33100. * @returns the index where the morph target was in the morph target list
  33101. */
  33102. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33103. /**
  33104. * Remove a light for the list of scene's lights
  33105. * @param toRemove defines the light to remove
  33106. * @returns the index where the light was in the light list
  33107. */
  33108. removeLight(toRemove: Light): number;
  33109. /**
  33110. * Remove a camera for the list of scene's cameras
  33111. * @param toRemove defines the camera to remove
  33112. * @returns the index where the camera was in the camera list
  33113. */
  33114. removeCamera(toRemove: Camera): number;
  33115. /**
  33116. * Remove a particle system for the list of scene's particle systems
  33117. * @param toRemove defines the particle system to remove
  33118. * @returns the index where the particle system was in the particle system list
  33119. */
  33120. removeParticleSystem(toRemove: IParticleSystem): number;
  33121. /**
  33122. * Remove a animation for the list of scene's animations
  33123. * @param toRemove defines the animation to remove
  33124. * @returns the index where the animation was in the animation list
  33125. */
  33126. removeAnimation(toRemove: Animation): number;
  33127. /**
  33128. * Will stop the animation of the given target
  33129. * @param target - the target
  33130. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  33131. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  33132. */
  33133. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  33134. /**
  33135. * Removes the given animation group from this scene.
  33136. * @param toRemove The animation group to remove
  33137. * @returns The index of the removed animation group
  33138. */
  33139. removeAnimationGroup(toRemove: AnimationGroup): number;
  33140. /**
  33141. * Removes the given multi-material from this scene.
  33142. * @param toRemove The multi-material to remove
  33143. * @returns The index of the removed multi-material
  33144. */
  33145. removeMultiMaterial(toRemove: MultiMaterial): number;
  33146. /**
  33147. * Removes the given material from this scene.
  33148. * @param toRemove The material to remove
  33149. * @returns The index of the removed material
  33150. */
  33151. removeMaterial(toRemove: Material): number;
  33152. /**
  33153. * Removes the given action manager from this scene.
  33154. * @param toRemove The action manager to remove
  33155. * @returns The index of the removed action manager
  33156. */
  33157. removeActionManager(toRemove: AbstractActionManager): number;
  33158. /**
  33159. * Removes the given texture from this scene.
  33160. * @param toRemove The texture to remove
  33161. * @returns The index of the removed texture
  33162. */
  33163. removeTexture(toRemove: BaseTexture): number;
  33164. /**
  33165. * Adds the given light to this scene
  33166. * @param newLight The light to add
  33167. */
  33168. addLight(newLight: Light): void;
  33169. /**
  33170. * Sorts the list list based on light priorities
  33171. */
  33172. sortLightsByPriority(): void;
  33173. /**
  33174. * Adds the given camera to this scene
  33175. * @param newCamera The camera to add
  33176. */
  33177. addCamera(newCamera: Camera): void;
  33178. /**
  33179. * Adds the given skeleton to this scene
  33180. * @param newSkeleton The skeleton to add
  33181. */
  33182. addSkeleton(newSkeleton: Skeleton): void;
  33183. /**
  33184. * Adds the given particle system to this scene
  33185. * @param newParticleSystem The particle system to add
  33186. */
  33187. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33188. /**
  33189. * Adds the given animation to this scene
  33190. * @param newAnimation The animation to add
  33191. */
  33192. addAnimation(newAnimation: Animation): void;
  33193. /**
  33194. * Adds the given animation group to this scene.
  33195. * @param newAnimationGroup The animation group to add
  33196. */
  33197. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33198. /**
  33199. * Adds the given multi-material to this scene
  33200. * @param newMultiMaterial The multi-material to add
  33201. */
  33202. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33203. /**
  33204. * Adds the given material to this scene
  33205. * @param newMaterial The material to add
  33206. */
  33207. addMaterial(newMaterial: Material): void;
  33208. /**
  33209. * Adds the given morph target to this scene
  33210. * @param newMorphTargetManager The morph target to add
  33211. */
  33212. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33213. /**
  33214. * Adds the given geometry to this scene
  33215. * @param newGeometry The geometry to add
  33216. */
  33217. addGeometry(newGeometry: Geometry): void;
  33218. /**
  33219. * Adds the given action manager to this scene
  33220. * @param newActionManager The action manager to add
  33221. */
  33222. addActionManager(newActionManager: AbstractActionManager): void;
  33223. /**
  33224. * Adds the given texture to this scene.
  33225. * @param newTexture The texture to add
  33226. */
  33227. addTexture(newTexture: BaseTexture): void;
  33228. /**
  33229. * Switch active camera
  33230. * @param newCamera defines the new active camera
  33231. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33232. */
  33233. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33234. /**
  33235. * sets the active camera of the scene using its ID
  33236. * @param id defines the camera's ID
  33237. * @return the new active camera or null if none found.
  33238. */
  33239. setActiveCameraByID(id: string): Nullable<Camera>;
  33240. /**
  33241. * sets the active camera of the scene using its name
  33242. * @param name defines the camera's name
  33243. * @returns the new active camera or null if none found.
  33244. */
  33245. setActiveCameraByName(name: string): Nullable<Camera>;
  33246. /**
  33247. * get an animation group using its name
  33248. * @param name defines the material's name
  33249. * @return the animation group or null if none found.
  33250. */
  33251. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33252. /**
  33253. * Get a material using its unique id
  33254. * @param uniqueId defines the material's unique id
  33255. * @return the material or null if none found.
  33256. */
  33257. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33258. /**
  33259. * get a material using its id
  33260. * @param id defines the material's ID
  33261. * @return the material or null if none found.
  33262. */
  33263. getMaterialByID(id: string): Nullable<Material>;
  33264. /**
  33265. * Gets a the last added material using a given id
  33266. * @param id defines the material's ID
  33267. * @return the last material with the given id or null if none found.
  33268. */
  33269. getLastMaterialByID(id: string): Nullable<Material>;
  33270. /**
  33271. * Gets a material using its name
  33272. * @param name defines the material's name
  33273. * @return the material or null if none found.
  33274. */
  33275. getMaterialByName(name: string): Nullable<Material>;
  33276. /**
  33277. * Get a texture using its unique id
  33278. * @param uniqueId defines the texture's unique id
  33279. * @return the texture or null if none found.
  33280. */
  33281. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  33282. /**
  33283. * Gets a camera using its id
  33284. * @param id defines the id to look for
  33285. * @returns the camera or null if not found
  33286. */
  33287. getCameraByID(id: string): Nullable<Camera>;
  33288. /**
  33289. * Gets a camera using its unique id
  33290. * @param uniqueId defines the unique id to look for
  33291. * @returns the camera or null if not found
  33292. */
  33293. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33294. /**
  33295. * Gets a camera using its name
  33296. * @param name defines the camera's name
  33297. * @return the camera or null if none found.
  33298. */
  33299. getCameraByName(name: string): Nullable<Camera>;
  33300. /**
  33301. * Gets a bone using its id
  33302. * @param id defines the bone's id
  33303. * @return the bone or null if not found
  33304. */
  33305. getBoneByID(id: string): Nullable<Bone>;
  33306. /**
  33307. * Gets a bone using its id
  33308. * @param name defines the bone's name
  33309. * @return the bone or null if not found
  33310. */
  33311. getBoneByName(name: string): Nullable<Bone>;
  33312. /**
  33313. * Gets a light node using its name
  33314. * @param name defines the the light's name
  33315. * @return the light or null if none found.
  33316. */
  33317. getLightByName(name: string): Nullable<Light>;
  33318. /**
  33319. * Gets a light node using its id
  33320. * @param id defines the light's id
  33321. * @return the light or null if none found.
  33322. */
  33323. getLightByID(id: string): Nullable<Light>;
  33324. /**
  33325. * Gets a light node using its scene-generated unique ID
  33326. * @param uniqueId defines the light's unique id
  33327. * @return the light or null if none found.
  33328. */
  33329. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33330. /**
  33331. * Gets a particle system by id
  33332. * @param id defines the particle system id
  33333. * @return the corresponding system or null if none found
  33334. */
  33335. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33336. /**
  33337. * Gets a geometry using its ID
  33338. * @param id defines the geometry's id
  33339. * @return the geometry or null if none found.
  33340. */
  33341. getGeometryByID(id: string): Nullable<Geometry>;
  33342. private _getGeometryByUniqueID;
  33343. /**
  33344. * Add a new geometry to this scene
  33345. * @param geometry defines the geometry to be added to the scene.
  33346. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33347. * @return a boolean defining if the geometry was added or not
  33348. */
  33349. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33350. /**
  33351. * Removes an existing geometry
  33352. * @param geometry defines the geometry to be removed from the scene
  33353. * @return a boolean defining if the geometry was removed or not
  33354. */
  33355. removeGeometry(geometry: Geometry): boolean;
  33356. /**
  33357. * Gets the list of geometries attached to the scene
  33358. * @returns an array of Geometry
  33359. */
  33360. getGeometries(): Geometry[];
  33361. /**
  33362. * Gets the first added mesh found of a given ID
  33363. * @param id defines the id to search for
  33364. * @return the mesh found or null if not found at all
  33365. */
  33366. getMeshByID(id: string): Nullable<AbstractMesh>;
  33367. /**
  33368. * Gets a list of meshes using their id
  33369. * @param id defines the id to search for
  33370. * @returns a list of meshes
  33371. */
  33372. getMeshesByID(id: string): Array<AbstractMesh>;
  33373. /**
  33374. * Gets the first added transform node found of a given ID
  33375. * @param id defines the id to search for
  33376. * @return the found transform node or null if not found at all.
  33377. */
  33378. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33379. /**
  33380. * Gets a transform node with its auto-generated unique id
  33381. * @param uniqueId efines the unique id to search for
  33382. * @return the found transform node or null if not found at all.
  33383. */
  33384. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33385. /**
  33386. * Gets a list of transform nodes using their id
  33387. * @param id defines the id to search for
  33388. * @returns a list of transform nodes
  33389. */
  33390. getTransformNodesByID(id: string): Array<TransformNode>;
  33391. /**
  33392. * Gets a mesh with its auto-generated unique id
  33393. * @param uniqueId defines the unique id to search for
  33394. * @return the found mesh or null if not found at all.
  33395. */
  33396. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33397. /**
  33398. * Gets a the last added mesh using a given id
  33399. * @param id defines the id to search for
  33400. * @return the found mesh or null if not found at all.
  33401. */
  33402. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33403. /**
  33404. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33405. * @param id defines the id to search for
  33406. * @return the found node or null if not found at all
  33407. */
  33408. getLastEntryByID(id: string): Nullable<Node>;
  33409. /**
  33410. * Gets a node (Mesh, Camera, Light) using a given id
  33411. * @param id defines the id to search for
  33412. * @return the found node or null if not found at all
  33413. */
  33414. getNodeByID(id: string): Nullable<Node>;
  33415. /**
  33416. * Gets a node (Mesh, Camera, Light) using a given name
  33417. * @param name defines the name to search for
  33418. * @return the found node or null if not found at all.
  33419. */
  33420. getNodeByName(name: string): Nullable<Node>;
  33421. /**
  33422. * Gets a mesh using a given name
  33423. * @param name defines the name to search for
  33424. * @return the found mesh or null if not found at all.
  33425. */
  33426. getMeshByName(name: string): Nullable<AbstractMesh>;
  33427. /**
  33428. * Gets a transform node using a given name
  33429. * @param name defines the name to search for
  33430. * @return the found transform node or null if not found at all.
  33431. */
  33432. getTransformNodeByName(name: string): Nullable<TransformNode>;
  33433. /**
  33434. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  33435. * @param id defines the id to search for
  33436. * @return the found skeleton or null if not found at all.
  33437. */
  33438. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  33439. /**
  33440. * Gets a skeleton using a given auto generated unique id
  33441. * @param uniqueId defines the unique id to search for
  33442. * @return the found skeleton or null if not found at all.
  33443. */
  33444. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  33445. /**
  33446. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  33447. * @param id defines the id to search for
  33448. * @return the found skeleton or null if not found at all.
  33449. */
  33450. getSkeletonById(id: string): Nullable<Skeleton>;
  33451. /**
  33452. * Gets a skeleton using a given name
  33453. * @param name defines the name to search for
  33454. * @return the found skeleton or null if not found at all.
  33455. */
  33456. getSkeletonByName(name: string): Nullable<Skeleton>;
  33457. /**
  33458. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  33459. * @param id defines the id to search for
  33460. * @return the found morph target manager or null if not found at all.
  33461. */
  33462. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  33463. /**
  33464. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  33465. * @param id defines the id to search for
  33466. * @return the found morph target or null if not found at all.
  33467. */
  33468. getMorphTargetById(id: string): Nullable<MorphTarget>;
  33469. /**
  33470. * Gets a boolean indicating if the given mesh is active
  33471. * @param mesh defines the mesh to look for
  33472. * @returns true if the mesh is in the active list
  33473. */
  33474. isActiveMesh(mesh: AbstractMesh): boolean;
  33475. /**
  33476. * Return a unique id as a string which can serve as an identifier for the scene
  33477. */
  33478. readonly uid: string;
  33479. /**
  33480. * Add an externaly attached data from its key.
  33481. * This method call will fail and return false, if such key already exists.
  33482. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  33483. * @param key the unique key that identifies the data
  33484. * @param data the data object to associate to the key for this Engine instance
  33485. * @return true if no such key were already present and the data was added successfully, false otherwise
  33486. */
  33487. addExternalData<T>(key: string, data: T): boolean;
  33488. /**
  33489. * Get an externaly attached data from its key
  33490. * @param key the unique key that identifies the data
  33491. * @return the associated data, if present (can be null), or undefined if not present
  33492. */
  33493. getExternalData<T>(key: string): Nullable<T>;
  33494. /**
  33495. * Get an externaly attached data from its key, create it using a factory if it's not already present
  33496. * @param key the unique key that identifies the data
  33497. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  33498. * @return the associated data, can be null if the factory returned null.
  33499. */
  33500. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  33501. /**
  33502. * Remove an externaly attached data from the Engine instance
  33503. * @param key the unique key that identifies the data
  33504. * @return true if the data was successfully removed, false if it doesn't exist
  33505. */
  33506. removeExternalData(key: string): boolean;
  33507. private _evaluateSubMesh;
  33508. /**
  33509. * Clear the processed materials smart array preventing retention point in material dispose.
  33510. */
  33511. freeProcessedMaterials(): void;
  33512. private _preventFreeActiveMeshesAndRenderingGroups;
  33513. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  33514. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  33515. * when disposing several meshes in a row or a hierarchy of meshes.
  33516. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  33517. */
  33518. blockfreeActiveMeshesAndRenderingGroups: boolean;
  33519. /**
  33520. * Clear the active meshes smart array preventing retention point in mesh dispose.
  33521. */
  33522. freeActiveMeshes(): void;
  33523. /**
  33524. * Clear the info related to rendering groups preventing retention points during dispose.
  33525. */
  33526. freeRenderingGroups(): void;
  33527. /** @hidden */ private _isInIntermediateRendering(): boolean;
  33528. /**
  33529. * Lambda returning the list of potentially active meshes.
  33530. */
  33531. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  33532. /**
  33533. * Lambda returning the list of potentially active sub meshes.
  33534. */
  33535. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  33536. /**
  33537. * Lambda returning the list of potentially intersecting sub meshes.
  33538. */
  33539. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  33540. /**
  33541. * Lambda returning the list of potentially colliding sub meshes.
  33542. */
  33543. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  33544. private _activeMeshesFrozen;
  33545. /**
  33546. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  33547. * @returns the current scene
  33548. */
  33549. freezeActiveMeshes(): Scene;
  33550. /**
  33551. * Use this function to restart evaluating active meshes on every frame
  33552. * @returns the current scene
  33553. */
  33554. unfreezeActiveMeshes(): Scene;
  33555. private _evaluateActiveMeshes;
  33556. private _activeMesh;
  33557. /**
  33558. * Update the transform matrix to update from the current active camera
  33559. * @param force defines a boolean used to force the update even if cache is up to date
  33560. */
  33561. updateTransformMatrix(force?: boolean): void;
  33562. private _bindFrameBuffer;
  33563. /** @hidden */ private _allowPostProcessClearColor: boolean;
  33564. /** @hidden */ private _renderForCamera(camera: Camera, rigParent?: Camera): void;
  33565. private _processSubCameras;
  33566. private _checkIntersections;
  33567. /** @hidden */ private _advancePhysicsEngineStep(step: number): void;
  33568. /**
  33569. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  33570. */
  33571. getDeterministicFrameTime: () => number;
  33572. /** @hidden */ private _animate(): void;
  33573. /** Execute all animations (for a frame) */
  33574. animate(): void;
  33575. /**
  33576. * Render the scene
  33577. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  33578. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  33579. */
  33580. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  33581. /**
  33582. * Freeze all materials
  33583. * A frozen material will not be updatable but should be faster to render
  33584. */
  33585. freezeMaterials(): void;
  33586. /**
  33587. * Unfreeze all materials
  33588. * A frozen material will not be updatable but should be faster to render
  33589. */
  33590. unfreezeMaterials(): void;
  33591. /**
  33592. * Releases all held ressources
  33593. */
  33594. dispose(): void;
  33595. /**
  33596. * Gets if the scene is already disposed
  33597. */
  33598. readonly isDisposed: boolean;
  33599. /**
  33600. * Call this function to reduce memory footprint of the scene.
  33601. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  33602. */
  33603. clearCachedVertexData(): void;
  33604. /**
  33605. * This function will remove the local cached buffer data from texture.
  33606. * It will save memory but will prevent the texture from being rebuilt
  33607. */
  33608. cleanCachedTextureBuffer(): void;
  33609. /**
  33610. * Get the world extend vectors with an optional filter
  33611. *
  33612. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  33613. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  33614. */
  33615. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  33616. min: Vector3;
  33617. max: Vector3;
  33618. };
  33619. /**
  33620. * Creates a ray that can be used to pick in the scene
  33621. * @param x defines the x coordinate of the origin (on-screen)
  33622. * @param y defines the y coordinate of the origin (on-screen)
  33623. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33624. * @param camera defines the camera to use for the picking
  33625. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33626. * @returns a Ray
  33627. */
  33628. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  33629. /**
  33630. * Creates a ray that can be used to pick in the scene
  33631. * @param x defines the x coordinate of the origin (on-screen)
  33632. * @param y defines the y coordinate of the origin (on-screen)
  33633. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  33634. * @param result defines the ray where to store the picking ray
  33635. * @param camera defines the camera to use for the picking
  33636. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  33637. * @returns the current scene
  33638. */
  33639. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  33640. /**
  33641. * Creates a ray that can be used to pick in the scene
  33642. * @param x defines the x coordinate of the origin (on-screen)
  33643. * @param y defines the y coordinate of the origin (on-screen)
  33644. * @param camera defines the camera to use for the picking
  33645. * @returns a Ray
  33646. */
  33647. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  33648. /**
  33649. * Creates a ray that can be used to pick in the scene
  33650. * @param x defines the x coordinate of the origin (on-screen)
  33651. * @param y defines the y coordinate of the origin (on-screen)
  33652. * @param result defines the ray where to store the picking ray
  33653. * @param camera defines the camera to use for the picking
  33654. * @returns the current scene
  33655. */
  33656. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  33657. /** Launch a ray to try to pick a mesh in the scene
  33658. * @param x position on screen
  33659. * @param y position on screen
  33660. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33661. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  33662. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33663. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33664. * @returns a PickingInfo
  33665. */
  33666. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33667. /** Use the given ray to pick a mesh in the scene
  33668. * @param ray The ray to use to pick meshes
  33669. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must have isPickable set to true
  33670. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  33671. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33672. * @returns a PickingInfo
  33673. */
  33674. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  33675. /**
  33676. * Launch a ray to try to pick a mesh in the scene
  33677. * @param x X position on screen
  33678. * @param y Y position on screen
  33679. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33680. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  33681. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33682. * @returns an array of PickingInfo
  33683. */
  33684. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33685. /**
  33686. * Launch a ray to try to pick a mesh in the scene
  33687. * @param ray Ray to use
  33688. * @param predicate Predicate function used to determine eligible meshes. Can be set to null. In this case, a mesh must be enabled, visible and with isPickable set to true
  33689. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33690. * @returns an array of PickingInfo
  33691. */
  33692. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  33693. /**
  33694. * Force the value of meshUnderPointer
  33695. * @param mesh defines the mesh to use
  33696. */
  33697. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33698. /**
  33699. * Gets the mesh under the pointer
  33700. * @returns a Mesh or null if no mesh is under the pointer
  33701. */
  33702. getPointerOverMesh(): Nullable<AbstractMesh>;
  33703. /** @hidden */ private _rebuildGeometries(): void;
  33704. /** @hidden */ private _rebuildTextures(): void;
  33705. private _getByTags;
  33706. /**
  33707. * Get a list of meshes by tags
  33708. * @param tagsQuery defines the tags query to use
  33709. * @param forEach defines a predicate used to filter results
  33710. * @returns an array of Mesh
  33711. */
  33712. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  33713. /**
  33714. * Get a list of cameras by tags
  33715. * @param tagsQuery defines the tags query to use
  33716. * @param forEach defines a predicate used to filter results
  33717. * @returns an array of Camera
  33718. */
  33719. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  33720. /**
  33721. * Get a list of lights by tags
  33722. * @param tagsQuery defines the tags query to use
  33723. * @param forEach defines a predicate used to filter results
  33724. * @returns an array of Light
  33725. */
  33726. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  33727. /**
  33728. * Get a list of materials by tags
  33729. * @param tagsQuery defines the tags query to use
  33730. * @param forEach defines a predicate used to filter results
  33731. * @returns an array of Material
  33732. */
  33733. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  33734. /**
  33735. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  33736. * This allowed control for front to back rendering or reversly depending of the special needs.
  33737. *
  33738. * @param renderingGroupId The rendering group id corresponding to its index
  33739. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  33740. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  33741. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  33742. */
  33743. setRenderingOrder(renderingGroupId: number, opaqueSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, alphaTestSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>, transparentSortCompareFn?: Nullable<(a: SubMesh, b: SubMesh) => number>): void;
  33744. /**
  33745. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  33746. *
  33747. * @param renderingGroupId The rendering group id corresponding to its index
  33748. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  33749. * @param depth Automatically clears depth between groups if true and autoClear is true.
  33750. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  33751. */
  33752. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  33753. /**
  33754. * Gets the current auto clear configuration for one rendering group of the rendering
  33755. * manager.
  33756. * @param index the rendering group index to get the information for
  33757. * @returns The auto clear setup for the requested rendering group
  33758. */
  33759. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  33760. private _blockMaterialDirtyMechanism;
  33761. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  33762. blockMaterialDirtyMechanism: boolean;
  33763. /**
  33764. * Will flag all materials as dirty to trigger new shader compilation
  33765. * @param flag defines the flag used to specify which material part must be marked as dirty
  33766. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  33767. */
  33768. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  33769. /** @hidden */ private _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onError?: (request?: WebRequest, exception?: any) => void): IFileRequest;
  33770. /** @hidden */ private _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  33771. }
  33772. }
  33773. declare module BABYLON {
  33774. /**
  33775. * Set of assets to keep when moving a scene into an asset container.
  33776. */
  33777. export class KeepAssets extends AbstractScene {
  33778. }
  33779. /**
  33780. * Container with a set of assets that can be added or removed from a scene.
  33781. */
  33782. export class AssetContainer extends AbstractScene {
  33783. /**
  33784. * The scene the AssetContainer belongs to.
  33785. */
  33786. scene: Scene;
  33787. /**
  33788. * Instantiates an AssetContainer.
  33789. * @param scene The scene the AssetContainer belongs to.
  33790. */
  33791. constructor(scene: Scene);
  33792. /**
  33793. * Adds all the assets from the container to the scene.
  33794. */
  33795. addAllToScene(): void;
  33796. /**
  33797. * Removes all the assets in the container from the scene
  33798. */
  33799. removeAllFromScene(): void;
  33800. /**
  33801. * Disposes all the assets in the container
  33802. */
  33803. dispose(): void;
  33804. private _moveAssets;
  33805. /**
  33806. * Removes all the assets contained in the scene and adds them to the container.
  33807. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  33808. */
  33809. moveAllFromScene(keepAssets?: KeepAssets): void;
  33810. /**
  33811. * Adds all meshes in the asset container to a root mesh that can be used to position all the contained meshes. The root mesh is then added to the front of the meshes in the assetContainer.
  33812. * @returns the root mesh
  33813. */
  33814. createRootMesh(): Mesh;
  33815. }
  33816. }
  33817. declare module BABYLON {
  33818. /**
  33819. * Defines how the parser contract is defined.
  33820. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  33821. */
  33822. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  33823. /**
  33824. * Defines how the individual parser contract is defined.
  33825. * These parser can parse an individual asset
  33826. */
  33827. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  33828. /**
  33829. * Base class of the scene acting as a container for the different elements composing a scene.
  33830. * This class is dynamically extended by the different components of the scene increasing
  33831. * flexibility and reducing coupling
  33832. */
  33833. export abstract class AbstractScene {
  33834. /**
  33835. * Stores the list of available parsers in the application.
  33836. */
  33837. private static _BabylonFileParsers;
  33838. /**
  33839. * Stores the list of available individual parsers in the application.
  33840. */
  33841. private static _IndividualBabylonFileParsers;
  33842. /**
  33843. * Adds a parser in the list of available ones
  33844. * @param name Defines the name of the parser
  33845. * @param parser Defines the parser to add
  33846. */
  33847. static AddParser(name: string, parser: BabylonFileParser): void;
  33848. /**
  33849. * Gets a general parser from the list of avaialble ones
  33850. * @param name Defines the name of the parser
  33851. * @returns the requested parser or null
  33852. */
  33853. static GetParser(name: string): Nullable<BabylonFileParser>;
  33854. /**
  33855. * Adds n individual parser in the list of available ones
  33856. * @param name Defines the name of the parser
  33857. * @param parser Defines the parser to add
  33858. */
  33859. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  33860. /**
  33861. * Gets an individual parser from the list of avaialble ones
  33862. * @param name Defines the name of the parser
  33863. * @returns the requested parser or null
  33864. */
  33865. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  33866. /**
  33867. * Parser json data and populate both a scene and its associated container object
  33868. * @param jsonData Defines the data to parse
  33869. * @param scene Defines the scene to parse the data for
  33870. * @param container Defines the container attached to the parsing sequence
  33871. * @param rootUrl Defines the root url of the data
  33872. */
  33873. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  33874. /**
  33875. * Gets the list of root nodes (ie. nodes with no parent)
  33876. */
  33877. rootNodes: Node[];
  33878. /** All of the cameras added to this scene
  33879. * @see http://doc.babylonjs.com/babylon101/cameras
  33880. */
  33881. cameras: Camera[];
  33882. /**
  33883. * All of the lights added to this scene
  33884. * @see http://doc.babylonjs.com/babylon101/lights
  33885. */
  33886. lights: Light[];
  33887. /**
  33888. * All of the (abstract) meshes added to this scene
  33889. */
  33890. meshes: AbstractMesh[];
  33891. /**
  33892. * The list of skeletons added to the scene
  33893. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33894. */
  33895. skeletons: Skeleton[];
  33896. /**
  33897. * All of the particle systems added to this scene
  33898. * @see http://doc.babylonjs.com/babylon101/particles
  33899. */
  33900. particleSystems: IParticleSystem[];
  33901. /**
  33902. * Gets a list of Animations associated with the scene
  33903. */
  33904. animations: Animation[];
  33905. /**
  33906. * All of the animation groups added to this scene
  33907. * @see http://doc.babylonjs.com/how_to/group
  33908. */
  33909. animationGroups: AnimationGroup[];
  33910. /**
  33911. * All of the multi-materials added to this scene
  33912. * @see http://doc.babylonjs.com/how_to/multi_materials
  33913. */
  33914. multiMaterials: MultiMaterial[];
  33915. /**
  33916. * All of the materials added to this scene
  33917. * In the context of a Scene, it is not supposed to be modified manually.
  33918. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  33919. * Note also that the order of the Material wihin the array is not significant and might change.
  33920. * @see http://doc.babylonjs.com/babylon101/materials
  33921. */
  33922. materials: Material[];
  33923. /**
  33924. * The list of morph target managers added to the scene
  33925. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  33926. */
  33927. morphTargetManagers: MorphTargetManager[];
  33928. /**
  33929. * The list of geometries used in the scene.
  33930. */
  33931. geometries: Geometry[];
  33932. /**
  33933. * All of the tranform nodes added to this scene
  33934. * In the context of a Scene, it is not supposed to be modified manually.
  33935. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  33936. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  33937. * @see http://doc.babylonjs.com/how_to/transformnode
  33938. */
  33939. transformNodes: TransformNode[];
  33940. /**
  33941. * ActionManagers available on the scene.
  33942. */
  33943. actionManagers: AbstractActionManager[];
  33944. /**
  33945. * Textures to keep.
  33946. */
  33947. textures: BaseTexture[];
  33948. /**
  33949. * Environment texture for the scene
  33950. */
  33951. environmentTexture: Nullable<BaseTexture>;
  33952. }
  33953. }
  33954. declare module BABYLON {
  33955. /**
  33956. * Interface used to define options for Sound class
  33957. */
  33958. export interface ISoundOptions {
  33959. /**
  33960. * Does the sound autoplay once loaded.
  33961. */
  33962. autoplay?: boolean;
  33963. /**
  33964. * Does the sound loop after it finishes playing once.
  33965. */
  33966. loop?: boolean;
  33967. /**
  33968. * Sound's volume
  33969. */
  33970. volume?: number;
  33971. /**
  33972. * Is it a spatial sound?
  33973. */
  33974. spatialSound?: boolean;
  33975. /**
  33976. * Maximum distance to hear that sound
  33977. */
  33978. maxDistance?: number;
  33979. /**
  33980. * Uses user defined attenuation function
  33981. */
  33982. useCustomAttenuation?: boolean;
  33983. /**
  33984. * Define the roll off factor of spatial sounds.
  33985. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33986. */
  33987. rolloffFactor?: number;
  33988. /**
  33989. * Define the reference distance the sound should be heard perfectly.
  33990. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33991. */
  33992. refDistance?: number;
  33993. /**
  33994. * Define the distance attenuation model the sound will follow.
  33995. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  33996. */
  33997. distanceModel?: string;
  33998. /**
  33999. * Defines the playback speed (1 by default)
  34000. */
  34001. playbackRate?: number;
  34002. /**
  34003. * Defines if the sound is from a streaming source
  34004. */
  34005. streaming?: boolean;
  34006. /**
  34007. * Defines an optional length (in seconds) inside the sound file
  34008. */
  34009. length?: number;
  34010. /**
  34011. * Defines an optional offset (in seconds) inside the sound file
  34012. */
  34013. offset?: number;
  34014. /**
  34015. * If true, URLs will not be required to state the audio file codec to use.
  34016. */
  34017. skipCodecCheck?: boolean;
  34018. }
  34019. /**
  34020. * Defines a sound that can be played in the application.
  34021. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34022. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34023. */
  34024. export class Sound {
  34025. /**
  34026. * The name of the sound in the scene.
  34027. */
  34028. name: string;
  34029. /**
  34030. * Does the sound autoplay once loaded.
  34031. */
  34032. autoplay: boolean;
  34033. /**
  34034. * Does the sound loop after it finishes playing once.
  34035. */
  34036. loop: boolean;
  34037. /**
  34038. * Does the sound use a custom attenuation curve to simulate the falloff
  34039. * happening when the source gets further away from the camera.
  34040. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34041. */
  34042. useCustomAttenuation: boolean;
  34043. /**
  34044. * The sound track id this sound belongs to.
  34045. */
  34046. soundTrackId: number;
  34047. /**
  34048. * Is this sound currently played.
  34049. */
  34050. isPlaying: boolean;
  34051. /**
  34052. * Is this sound currently paused.
  34053. */
  34054. isPaused: boolean;
  34055. /**
  34056. * Does this sound enables spatial sound.
  34057. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34058. */
  34059. spatialSound: boolean;
  34060. /**
  34061. * Define the reference distance the sound should be heard perfectly.
  34062. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34063. */
  34064. refDistance: number;
  34065. /**
  34066. * Define the roll off factor of spatial sounds.
  34067. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34068. */
  34069. rolloffFactor: number;
  34070. /**
  34071. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34072. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34073. */
  34074. maxDistance: number;
  34075. /**
  34076. * Define the distance attenuation model the sound will follow.
  34077. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34078. */
  34079. distanceModel: string;
  34080. /**
  34081. * @hidden
  34082. * Back Compat
  34083. **/
  34084. onended: () => any;
  34085. /**
  34086. * Observable event when the current playing sound finishes.
  34087. */
  34088. onEndedObservable: Observable<Sound>;
  34089. private _panningModel;
  34090. private _playbackRate;
  34091. private _streaming;
  34092. private _startTime;
  34093. private _startOffset;
  34094. private _position;
  34095. /** @hidden */ private _positionInEmitterSpace: boolean;
  34096. private _localDirection;
  34097. private _volume;
  34098. private _isReadyToPlay;
  34099. private _isDirectional;
  34100. private _readyToPlayCallback;
  34101. private _audioBuffer;
  34102. private _soundSource;
  34103. private _streamingSource;
  34104. private _soundPanner;
  34105. private _soundGain;
  34106. private _inputAudioNode;
  34107. private _outputAudioNode;
  34108. private _coneInnerAngle;
  34109. private _coneOuterAngle;
  34110. private _coneOuterGain;
  34111. private _scene;
  34112. private _connectedTransformNode;
  34113. private _customAttenuationFunction;
  34114. private _registerFunc;
  34115. private _isOutputConnected;
  34116. private _htmlAudioElement;
  34117. private _urlType;
  34118. private _length?;
  34119. private _offset?;
  34120. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  34121. /**
  34122. * Create a sound and attach it to a scene
  34123. * @param name Name of your sound
  34124. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34125. * @param scene defines the scene the sound belongs to
  34126. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34127. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34128. */
  34129. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  34130. /**
  34131. * Release the sound and its associated resources
  34132. */
  34133. dispose(): void;
  34134. /**
  34135. * Gets if the sounds is ready to be played or not.
  34136. * @returns true if ready, otherwise false
  34137. */
  34138. isReady(): boolean;
  34139. private _soundLoaded;
  34140. /**
  34141. * Sets the data of the sound from an audiobuffer
  34142. * @param audioBuffer The audioBuffer containing the data
  34143. */
  34144. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34145. /**
  34146. * Updates the current sounds options such as maxdistance, loop...
  34147. * @param options A JSON object containing values named as the object properties
  34148. */
  34149. updateOptions(options: ISoundOptions): void;
  34150. private _createSpatialParameters;
  34151. private _updateSpatialParameters;
  34152. /**
  34153. * Switch the panning model to HRTF:
  34154. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34155. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34156. */
  34157. switchPanningModelToHRTF(): void;
  34158. /**
  34159. * Switch the panning model to Equal Power:
  34160. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34161. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34162. */
  34163. switchPanningModelToEqualPower(): void;
  34164. private _switchPanningModel;
  34165. /**
  34166. * Connect this sound to a sound track audio node like gain...
  34167. * @param soundTrackAudioNode the sound track audio node to connect to
  34168. */
  34169. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34170. /**
  34171. * Transform this sound into a directional source
  34172. * @param coneInnerAngle Size of the inner cone in degree
  34173. * @param coneOuterAngle Size of the outer cone in degree
  34174. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34175. */
  34176. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34177. /**
  34178. * Gets or sets the inner angle for the directional cone.
  34179. */
  34180. /**
  34181. * Gets or sets the inner angle for the directional cone.
  34182. */
  34183. directionalConeInnerAngle: number;
  34184. /**
  34185. * Gets or sets the outer angle for the directional cone.
  34186. */
  34187. /**
  34188. * Gets or sets the outer angle for the directional cone.
  34189. */
  34190. directionalConeOuterAngle: number;
  34191. /**
  34192. * Sets the position of the emitter if spatial sound is enabled
  34193. * @param newPosition Defines the new posisiton
  34194. */
  34195. setPosition(newPosition: Vector3): void;
  34196. /**
  34197. * Sets the local direction of the emitter if spatial sound is enabled
  34198. * @param newLocalDirection Defines the new local direction
  34199. */
  34200. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34201. private _updateDirection;
  34202. /** @hidden */
  34203. updateDistanceFromListener(): void;
  34204. /**
  34205. * Sets a new custom attenuation function for the sound.
  34206. * @param callback Defines the function used for the attenuation
  34207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34208. */
  34209. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34210. /**
  34211. * Play the sound
  34212. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34213. * @param offset (optional) Start the sound at a specific time in seconds
  34214. * @param length (optional) Sound duration (in seconds)
  34215. */
  34216. play(time?: number, offset?: number, length?: number): void;
  34217. private _onended;
  34218. /**
  34219. * Stop the sound
  34220. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34221. */
  34222. stop(time?: number): void;
  34223. /**
  34224. * Put the sound in pause
  34225. */
  34226. pause(): void;
  34227. /**
  34228. * Sets a dedicated volume for this sounds
  34229. * @param newVolume Define the new volume of the sound
  34230. * @param time Define time for gradual change to new volume
  34231. */
  34232. setVolume(newVolume: number, time?: number): void;
  34233. /**
  34234. * Set the sound play back rate
  34235. * @param newPlaybackRate Define the playback rate the sound should be played at
  34236. */
  34237. setPlaybackRate(newPlaybackRate: number): void;
  34238. /**
  34239. * Gets the volume of the sound.
  34240. * @returns the volume of the sound
  34241. */
  34242. getVolume(): number;
  34243. /**
  34244. * Attach the sound to a dedicated mesh
  34245. * @param transformNode The transform node to connect the sound with
  34246. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34247. */
  34248. attachToMesh(transformNode: TransformNode): void;
  34249. /**
  34250. * Detach the sound from the previously attached mesh
  34251. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34252. */
  34253. detachFromMesh(): void;
  34254. private _onRegisterAfterWorldMatrixUpdate;
  34255. /**
  34256. * Clone the current sound in the scene.
  34257. * @returns the new sound clone
  34258. */
  34259. clone(): Nullable<Sound>;
  34260. /**
  34261. * Gets the current underlying audio buffer containing the data
  34262. * @returns the audio buffer
  34263. */
  34264. getAudioBuffer(): Nullable<AudioBuffer>;
  34265. /**
  34266. * Serializes the Sound in a JSON representation
  34267. * @returns the JSON representation of the sound
  34268. */
  34269. serialize(): any;
  34270. /**
  34271. * Parse a JSON representation of a sound to innstantiate in a given scene
  34272. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34273. * @param scene Define the scene the new parsed sound should be created in
  34274. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34275. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34276. * @returns the newly parsed sound
  34277. */
  34278. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34279. }
  34280. }
  34281. declare module BABYLON {
  34282. /**
  34283. * This defines an action helpful to play a defined sound on a triggered action.
  34284. */
  34285. export class PlaySoundAction extends Action {
  34286. private _sound;
  34287. /**
  34288. * Instantiate the action
  34289. * @param triggerOptions defines the trigger options
  34290. * @param sound defines the sound to play
  34291. * @param condition defines the trigger related conditions
  34292. */
  34293. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34294. /** @hidden */ private _prepare(): void;
  34295. /**
  34296. * Execute the action and play the sound.
  34297. */
  34298. execute(): void;
  34299. /**
  34300. * Serializes the actions and its related information.
  34301. * @param parent defines the object to serialize in
  34302. * @returns the serialized object
  34303. */
  34304. serialize(parent: any): any;
  34305. }
  34306. /**
  34307. * This defines an action helpful to stop a defined sound on a triggered action.
  34308. */
  34309. export class StopSoundAction extends Action {
  34310. private _sound;
  34311. /**
  34312. * Instantiate the action
  34313. * @param triggerOptions defines the trigger options
  34314. * @param sound defines the sound to stop
  34315. * @param condition defines the trigger related conditions
  34316. */
  34317. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34318. /** @hidden */ private _prepare(): void;
  34319. /**
  34320. * Execute the action and stop the sound.
  34321. */
  34322. execute(): void;
  34323. /**
  34324. * Serializes the actions and its related information.
  34325. * @param parent defines the object to serialize in
  34326. * @returns the serialized object
  34327. */
  34328. serialize(parent: any): any;
  34329. }
  34330. }
  34331. declare module BABYLON {
  34332. /**
  34333. * This defines an action responsible to change the value of a property
  34334. * by interpolating between its current value and the newly set one once triggered.
  34335. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34336. */
  34337. export class InterpolateValueAction extends Action {
  34338. /**
  34339. * Defines the path of the property where the value should be interpolated
  34340. */
  34341. propertyPath: string;
  34342. /**
  34343. * Defines the target value at the end of the interpolation.
  34344. */
  34345. value: any;
  34346. /**
  34347. * Defines the time it will take for the property to interpolate to the value.
  34348. */
  34349. duration: number;
  34350. /**
  34351. * Defines if the other scene animations should be stopped when the action has been triggered
  34352. */
  34353. stopOtherAnimations?: boolean;
  34354. /**
  34355. * Defines a callback raised once the interpolation animation has been done.
  34356. */
  34357. onInterpolationDone?: () => void;
  34358. /**
  34359. * Observable triggered once the interpolation animation has been done.
  34360. */
  34361. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34362. private _target;
  34363. private _effectiveTarget;
  34364. private _property;
  34365. /**
  34366. * Instantiate the action
  34367. * @param triggerOptions defines the trigger options
  34368. * @param target defines the object containing the value to interpolate
  34369. * @param propertyPath defines the path to the property in the target object
  34370. * @param value defines the target value at the end of the interpolation
  34371. * @param duration deines the time it will take for the property to interpolate to the value.
  34372. * @param condition defines the trigger related conditions
  34373. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34374. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34375. */
  34376. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34377. /** @hidden */ private _prepare(): void;
  34378. /**
  34379. * Execute the action starts the value interpolation.
  34380. */
  34381. execute(): void;
  34382. /**
  34383. * Serializes the actions and its related information.
  34384. * @param parent defines the object to serialize in
  34385. * @returns the serialized object
  34386. */
  34387. serialize(parent: any): any;
  34388. }
  34389. }
  34390. declare module BABYLON {
  34391. /**
  34392. * Options allowed during the creation of a sound track.
  34393. */
  34394. export interface ISoundTrackOptions {
  34395. /**
  34396. * The volume the sound track should take during creation
  34397. */
  34398. volume?: number;
  34399. /**
  34400. * Define if the sound track is the main sound track of the scene
  34401. */
  34402. mainTrack?: boolean;
  34403. }
  34404. /**
  34405. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34406. * It will be also used in a future release to apply effects on a specific track.
  34407. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34408. */
  34409. export class SoundTrack {
  34410. /**
  34411. * The unique identifier of the sound track in the scene.
  34412. */
  34413. id: number;
  34414. /**
  34415. * The list of sounds included in the sound track.
  34416. */
  34417. soundCollection: Array<Sound>;
  34418. private _outputAudioNode;
  34419. private _scene;
  34420. private _isMainTrack;
  34421. private _connectedAnalyser;
  34422. private _options;
  34423. private _isInitialized;
  34424. /**
  34425. * Creates a new sound track.
  34426. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34427. * @param scene Define the scene the sound track belongs to
  34428. * @param options
  34429. */
  34430. constructor(scene: Scene, options?: ISoundTrackOptions);
  34431. private _initializeSoundTrackAudioGraph;
  34432. /**
  34433. * Release the sound track and its associated resources
  34434. */
  34435. dispose(): void;
  34436. /**
  34437. * Adds a sound to this sound track
  34438. * @param sound define the cound to add
  34439. * @ignoreNaming
  34440. */
  34441. AddSound(sound: Sound): void;
  34442. /**
  34443. * Removes a sound to this sound track
  34444. * @param sound define the cound to remove
  34445. * @ignoreNaming
  34446. */
  34447. RemoveSound(sound: Sound): void;
  34448. /**
  34449. * Set a global volume for the full sound track.
  34450. * @param newVolume Define the new volume of the sound track
  34451. */
  34452. setVolume(newVolume: number): void;
  34453. /**
  34454. * Switch the panning model to HRTF:
  34455. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34456. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34457. */
  34458. switchPanningModelToHRTF(): void;
  34459. /**
  34460. * Switch the panning model to Equal Power:
  34461. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34462. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34463. */
  34464. switchPanningModelToEqualPower(): void;
  34465. /**
  34466. * Connect the sound track to an audio analyser allowing some amazing
  34467. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34468. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34469. * @param analyser The analyser to connect to the engine
  34470. */
  34471. connectToAnalyser(analyser: Analyser): void;
  34472. }
  34473. }
  34474. declare module BABYLON {
  34475. interface AbstractScene {
  34476. /**
  34477. * The list of sounds used in the scene.
  34478. */
  34479. sounds: Nullable<Array<Sound>>;
  34480. }
  34481. interface Scene {
  34482. /**
  34483. * @hidden
  34484. * Backing field
  34485. */ private _mainSoundTrack: SoundTrack;
  34486. /**
  34487. * The main sound track played by the scene.
  34488. * It cotains your primary collection of sounds.
  34489. */
  34490. mainSoundTrack: SoundTrack;
  34491. /**
  34492. * The list of sound tracks added to the scene
  34493. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34494. */
  34495. soundTracks: Nullable<Array<SoundTrack>>;
  34496. /**
  34497. * Gets a sound using a given name
  34498. * @param name defines the name to search for
  34499. * @return the found sound or null if not found at all.
  34500. */
  34501. getSoundByName(name: string): Nullable<Sound>;
  34502. /**
  34503. * Gets or sets if audio support is enabled
  34504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34505. */
  34506. audioEnabled: boolean;
  34507. /**
  34508. * Gets or sets if audio will be output to headphones
  34509. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34510. */
  34511. headphone: boolean;
  34512. /**
  34513. * Gets or sets custom audio listener position provider
  34514. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34515. */
  34516. audioListenerPositionProvider: Nullable<() => Vector3>;
  34517. }
  34518. /**
  34519. * Defines the sound scene component responsible to manage any sounds
  34520. * in a given scene.
  34521. */
  34522. export class AudioSceneComponent implements ISceneSerializableComponent {
  34523. /**
  34524. * The component name helpfull to identify the component in the list of scene components.
  34525. */
  34526. readonly name: string;
  34527. /**
  34528. * The scene the component belongs to.
  34529. */
  34530. scene: Scene;
  34531. private _audioEnabled;
  34532. /**
  34533. * Gets whether audio is enabled or not.
  34534. * Please use related enable/disable method to switch state.
  34535. */
  34536. readonly audioEnabled: boolean;
  34537. private _headphone;
  34538. /**
  34539. * Gets whether audio is outputing to headphone or not.
  34540. * Please use the according Switch methods to change output.
  34541. */
  34542. readonly headphone: boolean;
  34543. private _audioListenerPositionProvider;
  34544. /**
  34545. * Gets the current audio listener position provider
  34546. */
  34547. /**
  34548. * Sets a custom listener position for all sounds in the scene
  34549. * By default, this is the position of the first active camera
  34550. */
  34551. audioListenerPositionProvider: Nullable<() => Vector3>;
  34552. /**
  34553. * Creates a new instance of the component for the given scene
  34554. * @param scene Defines the scene to register the component in
  34555. */
  34556. constructor(scene: Scene);
  34557. /**
  34558. * Registers the component in a given scene
  34559. */
  34560. register(): void;
  34561. /**
  34562. * Rebuilds the elements related to this component in case of
  34563. * context lost for instance.
  34564. */
  34565. rebuild(): void;
  34566. /**
  34567. * Serializes the component data to the specified json object
  34568. * @param serializationObject The object to serialize to
  34569. */
  34570. serialize(serializationObject: any): void;
  34571. /**
  34572. * Adds all the elements from the container to the scene
  34573. * @param container the container holding the elements
  34574. */
  34575. addFromContainer(container: AbstractScene): void;
  34576. /**
  34577. * Removes all the elements in the container from the scene
  34578. * @param container contains the elements to remove
  34579. * @param dispose if the removed element should be disposed (default: false)
  34580. */
  34581. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  34582. /**
  34583. * Disposes the component and the associated ressources.
  34584. */
  34585. dispose(): void;
  34586. /**
  34587. * Disables audio in the associated scene.
  34588. */
  34589. disableAudio(): void;
  34590. /**
  34591. * Enables audio in the associated scene.
  34592. */
  34593. enableAudio(): void;
  34594. /**
  34595. * Switch audio to headphone output.
  34596. */
  34597. switchAudioModeForHeadphones(): void;
  34598. /**
  34599. * Switch audio to normal speakers.
  34600. */
  34601. switchAudioModeForNormalSpeakers(): void;
  34602. private _afterRender;
  34603. }
  34604. }
  34605. declare module BABYLON {
  34606. /**
  34607. * Wraps one or more Sound objects and selects one with random weight for playback.
  34608. */
  34609. export class WeightedSound {
  34610. /** When true a Sound will be selected and played when the current playing Sound completes. */
  34611. loop: boolean;
  34612. private _coneInnerAngle;
  34613. private _coneOuterAngle;
  34614. private _volume;
  34615. /** A Sound is currently playing. */
  34616. isPlaying: boolean;
  34617. /** A Sound is currently paused. */
  34618. isPaused: boolean;
  34619. private _sounds;
  34620. private _weights;
  34621. private _currentIndex?;
  34622. /**
  34623. * Creates a new WeightedSound from the list of sounds given.
  34624. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  34625. * @param sounds Array of Sounds that will be selected from.
  34626. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  34627. */
  34628. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  34629. /**
  34630. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  34631. */
  34632. /**
  34633. * The size of cone in degress for a directional sound in which there will be no attenuation.
  34634. */
  34635. directionalConeInnerAngle: number;
  34636. /**
  34637. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34638. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34639. */
  34640. /**
  34641. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  34642. * Listener angles between innerAngle and outerAngle will falloff linearly.
  34643. */
  34644. directionalConeOuterAngle: number;
  34645. /**
  34646. * Playback volume.
  34647. */
  34648. /**
  34649. * Playback volume.
  34650. */
  34651. volume: number;
  34652. private _onended;
  34653. /**
  34654. * Suspend playback
  34655. */
  34656. pause(): void;
  34657. /**
  34658. * Stop playback
  34659. */
  34660. stop(): void;
  34661. /**
  34662. * Start playback.
  34663. * @param startOffset Position the clip head at a specific time in seconds.
  34664. */
  34665. play(startOffset?: number): void;
  34666. }
  34667. }
  34668. declare module BABYLON {
  34669. /**
  34670. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  34671. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  34672. */
  34673. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  34674. /**
  34675. * Gets the name of the behavior.
  34676. */
  34677. readonly name: string;
  34678. /**
  34679. * The easing function used by animations
  34680. */
  34681. static EasingFunction: BackEase;
  34682. /**
  34683. * The easing mode used by animations
  34684. */
  34685. static EasingMode: number;
  34686. /**
  34687. * The duration of the animation, in milliseconds
  34688. */
  34689. transitionDuration: number;
  34690. /**
  34691. * Length of the distance animated by the transition when lower radius is reached
  34692. */
  34693. lowerRadiusTransitionRange: number;
  34694. /**
  34695. * Length of the distance animated by the transition when upper radius is reached
  34696. */
  34697. upperRadiusTransitionRange: number;
  34698. private _autoTransitionRange;
  34699. /**
  34700. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34701. */
  34702. /**
  34703. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  34704. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  34705. */
  34706. autoTransitionRange: boolean;
  34707. private _attachedCamera;
  34708. private _onAfterCheckInputsObserver;
  34709. private _onMeshTargetChangedObserver;
  34710. /**
  34711. * Initializes the behavior.
  34712. */
  34713. init(): void;
  34714. /**
  34715. * Attaches the behavior to its arc rotate camera.
  34716. * @param camera Defines the camera to attach the behavior to
  34717. */
  34718. attach(camera: ArcRotateCamera): void;
  34719. /**
  34720. * Detaches the behavior from its current arc rotate camera.
  34721. */
  34722. detach(): void;
  34723. private _radiusIsAnimating;
  34724. private _radiusBounceTransition;
  34725. private _animatables;
  34726. private _cachedWheelPrecision;
  34727. /**
  34728. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  34729. * @param radiusLimit The limit to check against.
  34730. * @return Bool to indicate if at limit.
  34731. */
  34732. private _isRadiusAtLimit;
  34733. /**
  34734. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  34735. * @param radiusDelta The delta by which to animate to. Can be negative.
  34736. */
  34737. private _applyBoundRadiusAnimation;
  34738. /**
  34739. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  34740. */
  34741. protected _clearAnimationLocks(): void;
  34742. /**
  34743. * Stops and removes all animations that have been applied to the camera
  34744. */
  34745. stopAllAnimations(): void;
  34746. }
  34747. }
  34748. declare module BABYLON {
  34749. /**
  34750. * The framing behavior (FramingBehavior) is designed to automatically position an ArcRotateCamera when its target is set to a mesh. It is also useful if you want to prevent the camera to go under a virtual horizontal plane.
  34751. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  34752. */
  34753. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  34754. /**
  34755. * Gets the name of the behavior.
  34756. */
  34757. readonly name: string;
  34758. private _mode;
  34759. private _radiusScale;
  34760. private _positionScale;
  34761. private _defaultElevation;
  34762. private _elevationReturnTime;
  34763. private _elevationReturnWaitTime;
  34764. private _zoomStopsAnimation;
  34765. private _framingTime;
  34766. /**
  34767. * The easing function used by animations
  34768. */
  34769. static EasingFunction: ExponentialEase;
  34770. /**
  34771. * The easing mode used by animations
  34772. */
  34773. static EasingMode: number;
  34774. /**
  34775. * Sets the current mode used by the behavior
  34776. */
  34777. /**
  34778. * Gets current mode used by the behavior.
  34779. */
  34780. mode: number;
  34781. /**
  34782. * Sets the scale applied to the radius (1 by default)
  34783. */
  34784. /**
  34785. * Gets the scale applied to the radius
  34786. */
  34787. radiusScale: number;
  34788. /**
  34789. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34790. */
  34791. /**
  34792. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  34793. */
  34794. positionScale: number;
  34795. /**
  34796. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34797. * behaviour is triggered, in radians.
  34798. */
  34799. /**
  34800. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  34801. * behaviour is triggered, in radians.
  34802. */
  34803. defaultElevation: number;
  34804. /**
  34805. * Sets the time (in milliseconds) taken to return to the default beta position.
  34806. * Negative value indicates camera should not return to default.
  34807. */
  34808. /**
  34809. * Gets the time (in milliseconds) taken to return to the default beta position.
  34810. * Negative value indicates camera should not return to default.
  34811. */
  34812. elevationReturnTime: number;
  34813. /**
  34814. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34815. */
  34816. /**
  34817. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  34818. */
  34819. elevationReturnWaitTime: number;
  34820. /**
  34821. * Sets the flag that indicates if user zooming should stop animation.
  34822. */
  34823. /**
  34824. * Gets the flag that indicates if user zooming should stop animation.
  34825. */
  34826. zoomStopsAnimation: boolean;
  34827. /**
  34828. * Sets the transition time when framing the mesh, in milliseconds
  34829. */
  34830. /**
  34831. * Gets the transition time when framing the mesh, in milliseconds
  34832. */
  34833. framingTime: number;
  34834. /**
  34835. * Define if the behavior should automatically change the configured
  34836. * camera limits and sensibilities.
  34837. */
  34838. autoCorrectCameraLimitsAndSensibility: boolean;
  34839. private _onPrePointerObservableObserver;
  34840. private _onAfterCheckInputsObserver;
  34841. private _onMeshTargetChangedObserver;
  34842. private _attachedCamera;
  34843. private _isPointerDown;
  34844. private _lastInteractionTime;
  34845. /**
  34846. * Initializes the behavior.
  34847. */
  34848. init(): void;
  34849. /**
  34850. * Attaches the behavior to its arc rotate camera.
  34851. * @param camera Defines the camera to attach the behavior to
  34852. */
  34853. attach(camera: ArcRotateCamera): void;
  34854. /**
  34855. * Detaches the behavior from its current arc rotate camera.
  34856. */
  34857. detach(): void;
  34858. private _animatables;
  34859. private _betaIsAnimating;
  34860. private _betaTransition;
  34861. private _radiusTransition;
  34862. private _vectorTransition;
  34863. /**
  34864. * Targets the given mesh and updates zoom level accordingly.
  34865. * @param mesh The mesh to target.
  34866. * @param radius Optional. If a cached radius position already exists, overrides default.
  34867. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34868. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34869. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34870. */
  34871. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34872. /**
  34873. * Targets the given mesh with its children and updates zoom level accordingly.
  34874. * @param mesh The mesh to target.
  34875. * @param radius Optional. If a cached radius position already exists, overrides default.
  34876. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34877. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34878. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34879. */
  34880. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34881. /**
  34882. * Targets the given meshes with their children and updates zoom level accordingly.
  34883. * @param meshes The mesh to target.
  34884. * @param radius Optional. If a cached radius position already exists, overrides default.
  34885. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  34886. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34887. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34888. */
  34889. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34890. /**
  34891. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  34892. * @param minimumWorld Determines the smaller position of the bounding box extend
  34893. * @param maximumWorld Determines the bigger position of the bounding box extend
  34894. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  34895. * @param onAnimationEnd Callback triggered at the end of the framing animation
  34896. */
  34897. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  34898. /**
  34899. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  34900. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  34901. * frustum width.
  34902. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  34903. * to fully enclose the mesh in the viewing frustum.
  34904. */
  34905. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  34906. /**
  34907. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  34908. * is automatically returned to its default position (expected to be above ground plane).
  34909. */
  34910. private _maintainCameraAboveGround;
  34911. /**
  34912. * Returns the frustum slope based on the canvas ratio and camera FOV
  34913. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  34914. */
  34915. private _getFrustumSlope;
  34916. /**
  34917. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  34918. */
  34919. private _clearAnimationLocks;
  34920. /**
  34921. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  34922. */
  34923. private _applyUserInteraction;
  34924. /**
  34925. * Stops and removes all animations that have been applied to the camera
  34926. */
  34927. stopAllAnimations(): void;
  34928. /**
  34929. * Gets a value indicating if the user is moving the camera
  34930. */
  34931. readonly isUserIsMoving: boolean;
  34932. /**
  34933. * The camera can move all the way towards the mesh.
  34934. */
  34935. static IgnoreBoundsSizeMode: number;
  34936. /**
  34937. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  34938. */
  34939. static FitFrustumSidesMode: number;
  34940. }
  34941. }
  34942. declare module BABYLON {
  34943. /**
  34944. * Base class for Camera Pointer Inputs.
  34945. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  34946. * for example usage.
  34947. */
  34948. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  34949. /**
  34950. * Defines the camera the input is attached to.
  34951. */
  34952. abstract camera: Camera;
  34953. /**
  34954. * Whether keyboard modifier keys are pressed at time of last mouse event.
  34955. */
  34956. protected _altKey: boolean;
  34957. protected _ctrlKey: boolean;
  34958. protected _metaKey: boolean;
  34959. protected _shiftKey: boolean;
  34960. /**
  34961. * Which mouse buttons were pressed at time of last mouse event.
  34962. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  34963. */
  34964. protected _buttonsPressed: number;
  34965. /**
  34966. * Defines the buttons associated with the input to handle camera move.
  34967. */
  34968. buttons: number[];
  34969. /**
  34970. * Attach the input controls to a specific dom element to get the input from.
  34971. * @param element Defines the element the controls should be listened from
  34972. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  34973. */
  34974. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  34975. /**
  34976. * Detach the current controls from the specified dom element.
  34977. * @param element Defines the element to stop listening the inputs from
  34978. */
  34979. detachControl(element: Nullable<HTMLElement>): void;
  34980. /**
  34981. * Gets the class name of the current input.
  34982. * @returns the class name
  34983. */
  34984. getClassName(): string;
  34985. /**
  34986. * Get the friendly name associated with the input class.
  34987. * @returns the input friendly name
  34988. */
  34989. getSimpleName(): string;
  34990. /**
  34991. * Called on pointer POINTERDOUBLETAP event.
  34992. * Override this method to provide functionality on POINTERDOUBLETAP event.
  34993. */
  34994. protected onDoubleTap(type: string): void;
  34995. /**
  34996. * Called on pointer POINTERMOVE event if only a single touch is active.
  34997. * Override this method to provide functionality.
  34998. */
  34999. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35000. /**
  35001. * Called on pointer POINTERMOVE event if multiple touches are active.
  35002. * Override this method to provide functionality.
  35003. */
  35004. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35005. /**
  35006. * Called on JS contextmenu event.
  35007. * Override this method to provide functionality.
  35008. */
  35009. protected onContextMenu(evt: PointerEvent): void;
  35010. /**
  35011. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35012. * press.
  35013. * Override this method to provide functionality.
  35014. */
  35015. protected onButtonDown(evt: PointerEvent): void;
  35016. /**
  35017. * Called each time a new POINTERUP event occurs. Ie, for each button
  35018. * release.
  35019. * Override this method to provide functionality.
  35020. */
  35021. protected onButtonUp(evt: PointerEvent): void;
  35022. /**
  35023. * Called when window becomes inactive.
  35024. * Override this method to provide functionality.
  35025. */
  35026. protected onLostFocus(): void;
  35027. private _pointerInput;
  35028. private _observer;
  35029. private _onLostFocus;
  35030. private pointA;
  35031. private pointB;
  35032. }
  35033. }
  35034. declare module BABYLON {
  35035. /**
  35036. * Manage the pointers inputs to control an arc rotate camera.
  35037. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35038. */
  35039. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35040. /**
  35041. * Defines the camera the input is attached to.
  35042. */
  35043. camera: ArcRotateCamera;
  35044. /**
  35045. * Gets the class name of the current input.
  35046. * @returns the class name
  35047. */
  35048. getClassName(): string;
  35049. /**
  35050. * Defines the buttons associated with the input to handle camera move.
  35051. */
  35052. buttons: number[];
  35053. /**
  35054. * Defines the pointer angular sensibility along the X axis or how fast is
  35055. * the camera rotating.
  35056. */
  35057. angularSensibilityX: number;
  35058. /**
  35059. * Defines the pointer angular sensibility along the Y axis or how fast is
  35060. * the camera rotating.
  35061. */
  35062. angularSensibilityY: number;
  35063. /**
  35064. * Defines the pointer pinch precision or how fast is the camera zooming.
  35065. */
  35066. pinchPrecision: number;
  35067. /**
  35068. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35069. * from 0.
  35070. * It defines the percentage of current camera.radius to use as delta when
  35071. * pinch zoom is used.
  35072. */
  35073. pinchDeltaPercentage: number;
  35074. /**
  35075. * Defines the pointer panning sensibility or how fast is the camera moving.
  35076. */
  35077. panningSensibility: number;
  35078. /**
  35079. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35080. */
  35081. multiTouchPanning: boolean;
  35082. /**
  35083. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35084. * zoom (pinch) through multitouch.
  35085. */
  35086. multiTouchPanAndZoom: boolean;
  35087. /**
  35088. * Revers pinch action direction.
  35089. */
  35090. pinchInwards: boolean;
  35091. private _isPanClick;
  35092. private _twoFingerActivityCount;
  35093. private _isPinching;
  35094. /**
  35095. * Called on pointer POINTERMOVE event if only a single touch is active.
  35096. */
  35097. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35098. /**
  35099. * Called on pointer POINTERDOUBLETAP event.
  35100. */
  35101. protected onDoubleTap(type: string): void;
  35102. /**
  35103. * Called on pointer POINTERMOVE event if multiple touches are active.
  35104. */
  35105. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35106. /**
  35107. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35108. * press.
  35109. */
  35110. protected onButtonDown(evt: PointerEvent): void;
  35111. /**
  35112. * Called each time a new POINTERUP event occurs. Ie, for each button
  35113. * release.
  35114. */
  35115. protected onButtonUp(evt: PointerEvent): void;
  35116. /**
  35117. * Called when window becomes inactive.
  35118. */
  35119. protected onLostFocus(): void;
  35120. }
  35121. }
  35122. declare module BABYLON {
  35123. /**
  35124. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35125. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35126. */
  35127. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35128. /**
  35129. * Defines the camera the input is attached to.
  35130. */
  35131. camera: ArcRotateCamera;
  35132. /**
  35133. * Defines the list of key codes associated with the up action (increase alpha)
  35134. */
  35135. keysUp: number[];
  35136. /**
  35137. * Defines the list of key codes associated with the down action (decrease alpha)
  35138. */
  35139. keysDown: number[];
  35140. /**
  35141. * Defines the list of key codes associated with the left action (increase beta)
  35142. */
  35143. keysLeft: number[];
  35144. /**
  35145. * Defines the list of key codes associated with the right action (decrease beta)
  35146. */
  35147. keysRight: number[];
  35148. /**
  35149. * Defines the list of key codes associated with the reset action.
  35150. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35151. */
  35152. keysReset: number[];
  35153. /**
  35154. * Defines the panning sensibility of the inputs.
  35155. * (How fast is the camera paning)
  35156. */
  35157. panningSensibility: number;
  35158. /**
  35159. * Defines the zooming sensibility of the inputs.
  35160. * (How fast is the camera zooming)
  35161. */
  35162. zoomingSensibility: number;
  35163. /**
  35164. * Defines wether maintaining the alt key down switch the movement mode from
  35165. * orientation to zoom.
  35166. */
  35167. useAltToZoom: boolean;
  35168. /**
  35169. * Rotation speed of the camera
  35170. */
  35171. angularSpeed: number;
  35172. private _keys;
  35173. private _ctrlPressed;
  35174. private _altPressed;
  35175. private _onCanvasBlurObserver;
  35176. private _onKeyboardObserver;
  35177. private _engine;
  35178. private _scene;
  35179. /**
  35180. * Attach the input controls to a specific dom element to get the input from.
  35181. * @param element Defines the element the controls should be listened from
  35182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35183. */
  35184. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35185. /**
  35186. * Detach the current controls from the specified dom element.
  35187. * @param element Defines the element to stop listening the inputs from
  35188. */
  35189. detachControl(element: Nullable<HTMLElement>): void;
  35190. /**
  35191. * Update the current camera state depending on the inputs that have been used this frame.
  35192. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35193. */
  35194. checkInputs(): void;
  35195. /**
  35196. * Gets the class name of the current intput.
  35197. * @returns the class name
  35198. */
  35199. getClassName(): string;
  35200. /**
  35201. * Get the friendly name associated with the input class.
  35202. * @returns the input friendly name
  35203. */
  35204. getSimpleName(): string;
  35205. }
  35206. }
  35207. declare module BABYLON {
  35208. /**
  35209. * Manage the mouse wheel inputs to control an arc rotate camera.
  35210. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35211. */
  35212. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35213. /**
  35214. * Defines the camera the input is attached to.
  35215. */
  35216. camera: ArcRotateCamera;
  35217. /**
  35218. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35219. */
  35220. wheelPrecision: number;
  35221. /**
  35222. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35223. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35224. */
  35225. wheelDeltaPercentage: number;
  35226. private _wheel;
  35227. private _observer;
  35228. private computeDeltaFromMouseWheelLegacyEvent;
  35229. /**
  35230. * Attach the input controls to a specific dom element to get the input from.
  35231. * @param element Defines the element the controls should be listened from
  35232. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35233. */
  35234. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35235. /**
  35236. * Detach the current controls from the specified dom element.
  35237. * @param element Defines the element to stop listening the inputs from
  35238. */
  35239. detachControl(element: Nullable<HTMLElement>): void;
  35240. /**
  35241. * Gets the class name of the current intput.
  35242. * @returns the class name
  35243. */
  35244. getClassName(): string;
  35245. /**
  35246. * Get the friendly name associated with the input class.
  35247. * @returns the input friendly name
  35248. */
  35249. getSimpleName(): string;
  35250. }
  35251. }
  35252. declare module BABYLON {
  35253. /**
  35254. * Default Inputs manager for the ArcRotateCamera.
  35255. * It groups all the default supported inputs for ease of use.
  35256. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35257. */
  35258. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35259. /**
  35260. * Instantiates a new ArcRotateCameraInputsManager.
  35261. * @param camera Defines the camera the inputs belong to
  35262. */
  35263. constructor(camera: ArcRotateCamera);
  35264. /**
  35265. * Add mouse wheel input support to the input manager.
  35266. * @returns the current input manager
  35267. */
  35268. addMouseWheel(): ArcRotateCameraInputsManager;
  35269. /**
  35270. * Add pointers input support to the input manager.
  35271. * @returns the current input manager
  35272. */
  35273. addPointers(): ArcRotateCameraInputsManager;
  35274. /**
  35275. * Add keyboard input support to the input manager.
  35276. * @returns the current input manager
  35277. */
  35278. addKeyboard(): ArcRotateCameraInputsManager;
  35279. }
  35280. }
  35281. declare module BABYLON {
  35282. /**
  35283. * This represents an orbital type of camera.
  35284. *
  35285. * This camera always points towards a given target position and can be rotated around that target with the target as the centre of rotation. It can be controlled with cursors and mouse, or with touch events.
  35286. * Think of this camera as one orbiting its target position, or more imaginatively as a spy satellite orbiting the earth. Its position relative to the target (earth) can be set by three parameters, alpha (radians) the longitudinal rotation, beta (radians) the latitudinal rotation and radius the distance from the target position.
  35287. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35288. */
  35289. export class ArcRotateCamera extends TargetCamera {
  35290. /**
  35291. * Defines the rotation angle of the camera along the longitudinal axis.
  35292. */
  35293. alpha: number;
  35294. /**
  35295. * Defines the rotation angle of the camera along the latitudinal axis.
  35296. */
  35297. beta: number;
  35298. /**
  35299. * Defines the radius of the camera from it s target point.
  35300. */
  35301. radius: number;
  35302. protected _target: Vector3;
  35303. protected _targetHost: Nullable<AbstractMesh>;
  35304. /**
  35305. * Defines the target point of the camera.
  35306. * The camera looks towards it form the radius distance.
  35307. */
  35308. target: Vector3;
  35309. /**
  35310. * Define the current local position of the camera in the scene
  35311. */
  35312. position: Vector3;
  35313. protected _upVector: Vector3;
  35314. protected _upToYMatrix: Matrix;
  35315. protected _YToUpMatrix: Matrix;
  35316. /**
  35317. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35318. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35319. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35320. */
  35321. upVector: Vector3;
  35322. /**
  35323. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35324. */
  35325. setMatUp(): void;
  35326. /**
  35327. * Current inertia value on the longitudinal axis.
  35328. * The bigger this number the longer it will take for the camera to stop.
  35329. */
  35330. inertialAlphaOffset: number;
  35331. /**
  35332. * Current inertia value on the latitudinal axis.
  35333. * The bigger this number the longer it will take for the camera to stop.
  35334. */
  35335. inertialBetaOffset: number;
  35336. /**
  35337. * Current inertia value on the radius axis.
  35338. * The bigger this number the longer it will take for the camera to stop.
  35339. */
  35340. inertialRadiusOffset: number;
  35341. /**
  35342. * Minimum allowed angle on the longitudinal axis.
  35343. * This can help limiting how the Camera is able to move in the scene.
  35344. */
  35345. lowerAlphaLimit: Nullable<number>;
  35346. /**
  35347. * Maximum allowed angle on the longitudinal axis.
  35348. * This can help limiting how the Camera is able to move in the scene.
  35349. */
  35350. upperAlphaLimit: Nullable<number>;
  35351. /**
  35352. * Minimum allowed angle on the latitudinal axis.
  35353. * This can help limiting how the Camera is able to move in the scene.
  35354. */
  35355. lowerBetaLimit: number;
  35356. /**
  35357. * Maximum allowed angle on the latitudinal axis.
  35358. * This can help limiting how the Camera is able to move in the scene.
  35359. */
  35360. upperBetaLimit: number;
  35361. /**
  35362. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35363. * This can help limiting how the Camera is able to move in the scene.
  35364. */
  35365. lowerRadiusLimit: Nullable<number>;
  35366. /**
  35367. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35368. * This can help limiting how the Camera is able to move in the scene.
  35369. */
  35370. upperRadiusLimit: Nullable<number>;
  35371. /**
  35372. * Defines the current inertia value used during panning of the camera along the X axis.
  35373. */
  35374. inertialPanningX: number;
  35375. /**
  35376. * Defines the current inertia value used during panning of the camera along the Y axis.
  35377. */
  35378. inertialPanningY: number;
  35379. /**
  35380. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  35381. * Basically if your fingers moves away from more than this distance you will be considered
  35382. * in pinch mode.
  35383. */
  35384. pinchToPanMaxDistance: number;
  35385. /**
  35386. * Defines the maximum distance the camera can pan.
  35387. * This could help keeping the cammera always in your scene.
  35388. */
  35389. panningDistanceLimit: Nullable<number>;
  35390. /**
  35391. * Defines the target of the camera before paning.
  35392. */
  35393. panningOriginTarget: Vector3;
  35394. /**
  35395. * Defines the value of the inertia used during panning.
  35396. * 0 would mean stop inertia and one would mean no decelleration at all.
  35397. */
  35398. panningInertia: number;
  35399. /**
  35400. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  35401. */
  35402. angularSensibilityX: number;
  35403. /**
  35404. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  35405. */
  35406. angularSensibilityY: number;
  35407. /**
  35408. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  35409. */
  35410. pinchPrecision: number;
  35411. /**
  35412. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  35413. * It will be used instead of pinchDeltaPrecision if different from 0.
  35414. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35415. */
  35416. pinchDeltaPercentage: number;
  35417. /**
  35418. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  35419. */
  35420. panningSensibility: number;
  35421. /**
  35422. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  35423. */
  35424. keysUp: number[];
  35425. /**
  35426. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  35427. */
  35428. keysDown: number[];
  35429. /**
  35430. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  35431. */
  35432. keysLeft: number[];
  35433. /**
  35434. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  35435. */
  35436. keysRight: number[];
  35437. /**
  35438. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35439. */
  35440. wheelPrecision: number;
  35441. /**
  35442. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  35443. * It will be used instead of pinchDeltaPrecision if different from 0.
  35444. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  35445. */
  35446. wheelDeltaPercentage: number;
  35447. /**
  35448. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  35449. */
  35450. zoomOnFactor: number;
  35451. /**
  35452. * Defines a screen offset for the camera position.
  35453. */
  35454. targetScreenOffset: Vector2;
  35455. /**
  35456. * Allows the camera to be completely reversed.
  35457. * If false the camera can not arrive upside down.
  35458. */
  35459. allowUpsideDown: boolean;
  35460. /**
  35461. * Define if double tap/click is used to restore the previously saved state of the camera.
  35462. */
  35463. useInputToRestoreState: boolean;
  35464. /** @hidden */ private _viewMatrix: Matrix;
  35465. /** @hidden */ private _useCtrlForPanning: boolean;
  35466. /** @hidden */ private _panningMouseButton: number;
  35467. /**
  35468. * Defines the input associated to the camera.
  35469. */
  35470. inputs: ArcRotateCameraInputsManager;
  35471. /** @hidden */ private _reset: () => void;
  35472. /**
  35473. * Defines the allowed panning axis.
  35474. */
  35475. panningAxis: Vector3;
  35476. protected _localDirection: Vector3;
  35477. protected _transformedDirection: Vector3;
  35478. private _bouncingBehavior;
  35479. /**
  35480. * Gets the bouncing behavior of the camera if it has been enabled.
  35481. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35482. */
  35483. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  35484. /**
  35485. * Defines if the bouncing behavior of the camera is enabled on the camera.
  35486. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35487. */
  35488. useBouncingBehavior: boolean;
  35489. private _framingBehavior;
  35490. /**
  35491. * Gets the framing behavior of the camera if it has been enabled.
  35492. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35493. */
  35494. readonly framingBehavior: Nullable<FramingBehavior>;
  35495. /**
  35496. * Defines if the framing behavior of the camera is enabled on the camera.
  35497. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35498. */
  35499. useFramingBehavior: boolean;
  35500. private _autoRotationBehavior;
  35501. /**
  35502. * Gets the auto rotation behavior of the camera if it has been enabled.
  35503. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35504. */
  35505. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  35506. /**
  35507. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  35508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35509. */
  35510. useAutoRotationBehavior: boolean;
  35511. /**
  35512. * Observable triggered when the mesh target has been changed on the camera.
  35513. */
  35514. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  35515. /**
  35516. * Event raised when the camera is colliding with a mesh.
  35517. */
  35518. onCollide: (collidedMesh: AbstractMesh) => void;
  35519. /**
  35520. * Defines whether the camera should check collision with the objects oh the scene.
  35521. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  35522. */
  35523. checkCollisions: boolean;
  35524. /**
  35525. * Defines the collision radius of the camera.
  35526. * This simulates a sphere around the camera.
  35527. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  35528. */
  35529. collisionRadius: Vector3;
  35530. protected _collider: Collider;
  35531. protected _previousPosition: Vector3;
  35532. protected _collisionVelocity: Vector3;
  35533. protected _newPosition: Vector3;
  35534. protected _previousAlpha: number;
  35535. protected _previousBeta: number;
  35536. protected _previousRadius: number;
  35537. protected _collisionTriggered: boolean;
  35538. protected _targetBoundingCenter: Nullable<Vector3>;
  35539. private _computationVector;
  35540. /**
  35541. * Instantiates a new ArcRotateCamera in a given scene
  35542. * @param name Defines the name of the camera
  35543. * @param alpha Defines the camera rotation along the logitudinal axis
  35544. * @param beta Defines the camera rotation along the latitudinal axis
  35545. * @param radius Defines the camera distance from its target
  35546. * @param target Defines the camera target
  35547. * @param scene Defines the scene the camera belongs to
  35548. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  35549. */
  35550. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  35551. /** @hidden */ private _initCache(): void;
  35552. /** @hidden */ private _updateCache(ignoreParentClass?: boolean): void;
  35553. protected _getTargetPosition(): Vector3;
  35554. private _storedAlpha;
  35555. private _storedBeta;
  35556. private _storedRadius;
  35557. private _storedTarget;
  35558. /**
  35559. * Stores the current state of the camera (alpha, beta, radius and target)
  35560. * @returns the camera itself
  35561. */
  35562. storeState(): Camera;
  35563. /**
  35564. * @hidden
  35565. * Restored camera state. You must call storeState() first
  35566. */ private _restoreStateValues(): boolean;
  35567. /** @hidden */ private _isSynchronizedViewMatrix(): boolean;
  35568. /**
  35569. * Attached controls to the current camera.
  35570. * @param element Defines the element the controls should be listened from
  35571. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35572. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  35573. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  35574. */
  35575. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  35576. /**
  35577. * Detach the current controls from the camera.
  35578. * The camera will stop reacting to inputs.
  35579. * @param element Defines the element to stop listening the inputs from
  35580. */
  35581. detachControl(element: HTMLElement): void;
  35582. /** @hidden */ private _checkInputs(): void;
  35583. protected _checkLimits(): void;
  35584. /**
  35585. * Rebuilds angles (alpha, beta) and radius from the give position and target
  35586. */
  35587. rebuildAnglesAndRadius(): void;
  35588. /**
  35589. * Use a position to define the current camera related information like aplha, beta and radius
  35590. * @param position Defines the position to set the camera at
  35591. */
  35592. setPosition(position: Vector3): void;
  35593. /**
  35594. * Defines the target the camera should look at.
  35595. * This will automatically adapt alpha beta and radius to fit within the new target.
  35596. * @param target Defines the new target as a Vector or a mesh
  35597. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  35598. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  35599. */
  35600. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  35601. /** @hidden */ private _getViewMatrix(): Matrix;
  35602. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  35603. /**
  35604. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  35605. * @param meshes Defines the mesh to zoom on
  35606. * @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)
  35607. */
  35608. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  35609. /**
  35610. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  35611. * The target will be changed but the radius
  35612. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  35613. * @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)
  35614. */
  35615. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  35616. min: Vector3;
  35617. max: Vector3;
  35618. distance: number;
  35619. }, doNotUpdateMaxZ?: boolean): void;
  35620. /**
  35621. * @override
  35622. * Override Camera.createRigCamera
  35623. */
  35624. createRigCamera(name: string, cameraIndex: number): Camera;
  35625. /**
  35626. * @hidden
  35627. * @override
  35628. * Override Camera._updateRigCameras
  35629. */ private _updateRigCameras(): void;
  35630. /**
  35631. * Destroy the camera and release the current resources hold by it.
  35632. */
  35633. dispose(): void;
  35634. /**
  35635. * Gets the current object class name.
  35636. * @return the class name
  35637. */
  35638. getClassName(): string;
  35639. }
  35640. }
  35641. declare module BABYLON {
  35642. /**
  35643. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  35644. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  35645. */
  35646. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  35647. /**
  35648. * Gets the name of the behavior.
  35649. */
  35650. readonly name: string;
  35651. private _zoomStopsAnimation;
  35652. private _idleRotationSpeed;
  35653. private _idleRotationWaitTime;
  35654. private _idleRotationSpinupTime;
  35655. /**
  35656. * Sets the flag that indicates if user zooming should stop animation.
  35657. */
  35658. /**
  35659. * Gets the flag that indicates if user zooming should stop animation.
  35660. */
  35661. zoomStopsAnimation: boolean;
  35662. /**
  35663. * Sets the default speed at which the camera rotates around the model.
  35664. */
  35665. /**
  35666. * Gets the default speed at which the camera rotates around the model.
  35667. */
  35668. idleRotationSpeed: number;
  35669. /**
  35670. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  35671. */
  35672. /**
  35673. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  35674. */
  35675. idleRotationWaitTime: number;
  35676. /**
  35677. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35678. */
  35679. /**
  35680. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  35681. */
  35682. idleRotationSpinupTime: number;
  35683. /**
  35684. * Gets a value indicating if the camera is currently rotating because of this behavior
  35685. */
  35686. readonly rotationInProgress: boolean;
  35687. private _onPrePointerObservableObserver;
  35688. private _onAfterCheckInputsObserver;
  35689. private _attachedCamera;
  35690. private _isPointerDown;
  35691. private _lastFrameTime;
  35692. private _lastInteractionTime;
  35693. private _cameraRotationSpeed;
  35694. /**
  35695. * Initializes the behavior.
  35696. */
  35697. init(): void;
  35698. /**
  35699. * Attaches the behavior to its arc rotate camera.
  35700. * @param camera Defines the camera to attach the behavior to
  35701. */
  35702. attach(camera: ArcRotateCamera): void;
  35703. /**
  35704. * Detaches the behavior from its current arc rotate camera.
  35705. */
  35706. detach(): void;
  35707. /**
  35708. * Returns true if user is scrolling.
  35709. * @return true if user is scrolling.
  35710. */
  35711. private _userIsZooming;
  35712. private _lastFrameRadius;
  35713. private _shouldAnimationStopForInteraction;
  35714. /**
  35715. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35716. */
  35717. private _applyUserInteraction;
  35718. private _userIsMoving;
  35719. }
  35720. }
  35721. declare module BABYLON {
  35722. /**
  35723. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  35724. */
  35725. export class AttachToBoxBehavior implements Behavior<Mesh> {
  35726. private ui;
  35727. /**
  35728. * The name of the behavior
  35729. */
  35730. name: string;
  35731. /**
  35732. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  35733. */
  35734. distanceAwayFromFace: number;
  35735. /**
  35736. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  35737. */
  35738. distanceAwayFromBottomOfFace: number;
  35739. private _faceVectors;
  35740. private _target;
  35741. private _scene;
  35742. private _onRenderObserver;
  35743. private _tmpMatrix;
  35744. private _tmpVector;
  35745. /**
  35746. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  35747. * @param ui The transform node that should be attched to the mesh
  35748. */
  35749. constructor(ui: TransformNode);
  35750. /**
  35751. * Initializes the behavior
  35752. */
  35753. init(): void;
  35754. private _closestFace;
  35755. private _zeroVector;
  35756. private _lookAtTmpMatrix;
  35757. private _lookAtToRef;
  35758. /**
  35759. * Attaches the AttachToBoxBehavior to the passed in mesh
  35760. * @param target The mesh that the specified node will be attached to
  35761. */
  35762. attach(target: Mesh): void;
  35763. /**
  35764. * Detaches the behavior from the mesh
  35765. */
  35766. detach(): void;
  35767. }
  35768. }
  35769. declare module BABYLON {
  35770. /**
  35771. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  35772. */
  35773. export class FadeInOutBehavior implements Behavior<Mesh> {
  35774. /**
  35775. * Time in milliseconds to delay before fading in (Default: 0)
  35776. */
  35777. delay: number;
  35778. /**
  35779. * Time in milliseconds for the mesh to fade in (Default: 300)
  35780. */
  35781. fadeInTime: number;
  35782. private _millisecondsPerFrame;
  35783. private _hovered;
  35784. private _hoverValue;
  35785. private _ownerNode;
  35786. /**
  35787. * Instatiates the FadeInOutBehavior
  35788. */
  35789. constructor();
  35790. /**
  35791. * The name of the behavior
  35792. */
  35793. readonly name: string;
  35794. /**
  35795. * Initializes the behavior
  35796. */
  35797. init(): void;
  35798. /**
  35799. * Attaches the fade behavior on the passed in mesh
  35800. * @param ownerNode The mesh that will be faded in/out once attached
  35801. */
  35802. attach(ownerNode: Mesh): void;
  35803. /**
  35804. * Detaches the behavior from the mesh
  35805. */
  35806. detach(): void;
  35807. /**
  35808. * Triggers the mesh to begin fading in or out
  35809. * @param value if the object should fade in or out (true to fade in)
  35810. */
  35811. fadeIn(value: boolean): void;
  35812. private _update;
  35813. private _setAllVisibility;
  35814. }
  35815. }
  35816. declare module BABYLON {
  35817. /**
  35818. * Class containing a set of static utilities functions for managing Pivots
  35819. * @hidden
  35820. */
  35821. export class PivotTools {
  35822. private static _PivotCached;
  35823. private static _OldPivotPoint;
  35824. private static _PivotTranslation;
  35825. private static _PivotTmpVector;
  35826. /** @hidden */ private static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  35827. /** @hidden */ private static _RestorePivotPoint(mesh: AbstractMesh): void;
  35828. }
  35829. }
  35830. declare module BABYLON {
  35831. /**
  35832. * Class containing static functions to help procedurally build meshes
  35833. */
  35834. export class PlaneBuilder {
  35835. /**
  35836. * Creates a plane mesh
  35837. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  35838. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  35839. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  35840. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  35841. * * 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
  35842. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  35843. * @param name defines the name of the mesh
  35844. * @param options defines the options used to create the mesh
  35845. * @param scene defines the hosting scene
  35846. * @returns the plane mesh
  35847. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  35848. */
  35849. static CreatePlane(name: string, options: {
  35850. size?: number;
  35851. width?: number;
  35852. height?: number;
  35853. sideOrientation?: number;
  35854. frontUVs?: Vector4;
  35855. backUVs?: Vector4;
  35856. updatable?: boolean;
  35857. sourcePlane?: Plane;
  35858. }, scene?: Nullable<Scene>): Mesh;
  35859. }
  35860. }
  35861. declare module BABYLON {
  35862. /**
  35863. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  35864. */
  35865. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  35866. private static _AnyMouseID;
  35867. /**
  35868. * Abstract mesh the behavior is set on
  35869. */
  35870. attachedNode: AbstractMesh;
  35871. private _dragPlane;
  35872. private _scene;
  35873. private _pointerObserver;
  35874. private _beforeRenderObserver;
  35875. private static _planeScene;
  35876. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  35877. /**
  35878. * 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)
  35879. */
  35880. maxDragAngle: number;
  35881. /**
  35882. * @hidden
  35883. */ private _useAlternatePickedPointAboveMaxDragAngle: boolean;
  35884. /**
  35885. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  35886. */
  35887. currentDraggingPointerID: number;
  35888. /**
  35889. * The last position where the pointer hit the drag plane in world space
  35890. */
  35891. lastDragPosition: Vector3;
  35892. /**
  35893. * If the behavior is currently in a dragging state
  35894. */
  35895. dragging: boolean;
  35896. /**
  35897. * 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)
  35898. */
  35899. dragDeltaRatio: number;
  35900. /**
  35901. * If the drag plane orientation should be updated during the dragging (Default: true)
  35902. */
  35903. updateDragPlane: boolean;
  35904. private _debugMode;
  35905. private _moving;
  35906. /**
  35907. * Fires each time the attached mesh is dragged with the pointer
  35908. * * delta between last drag position and current drag position in world space
  35909. * * dragDistance along the drag axis
  35910. * * dragPlaneNormal normal of the current drag plane used during the drag
  35911. * * dragPlanePoint in world space where the drag intersects the drag plane
  35912. */
  35913. onDragObservable: Observable<{
  35914. delta: Vector3;
  35915. dragPlanePoint: Vector3;
  35916. dragPlaneNormal: Vector3;
  35917. dragDistance: number;
  35918. pointerId: number;
  35919. }>;
  35920. /**
  35921. * Fires each time a drag begins (eg. mouse down on mesh)
  35922. */
  35923. onDragStartObservable: Observable<{
  35924. dragPlanePoint: Vector3;
  35925. pointerId: number;
  35926. }>;
  35927. /**
  35928. * Fires each time a drag ends (eg. mouse release after drag)
  35929. */
  35930. onDragEndObservable: Observable<{
  35931. dragPlanePoint: Vector3;
  35932. pointerId: number;
  35933. }>;
  35934. /**
  35935. * If the attached mesh should be moved when dragged
  35936. */
  35937. moveAttached: boolean;
  35938. /**
  35939. * If the drag behavior will react to drag events (Default: true)
  35940. */
  35941. enabled: boolean;
  35942. /**
  35943. * If pointer events should start and release the drag (Default: true)
  35944. */
  35945. startAndReleaseDragOnPointerEvents: boolean;
  35946. /**
  35947. * If camera controls should be detached during the drag
  35948. */
  35949. detachCameraControls: boolean;
  35950. /**
  35951. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  35952. */
  35953. useObjectOrienationForDragging: boolean;
  35954. private _options;
  35955. /**
  35956. * Creates a pointer drag behavior that can be attached to a mesh
  35957. * @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)
  35958. */
  35959. constructor(options?: {
  35960. dragAxis?: Vector3;
  35961. dragPlaneNormal?: Vector3;
  35962. });
  35963. /**
  35964. * Predicate to determine if it is valid to move the object to a new position when it is moved
  35965. */
  35966. validateDrag: (targetPosition: Vector3) => boolean;
  35967. /**
  35968. * The name of the behavior
  35969. */
  35970. readonly name: string;
  35971. /**
  35972. * Initializes the behavior
  35973. */
  35974. init(): void;
  35975. private _tmpVector;
  35976. private _alternatePickedPoint;
  35977. private _worldDragAxis;
  35978. private _targetPosition;
  35979. private _attachedElement;
  35980. /**
  35981. * Attaches the drag behavior the passed in mesh
  35982. * @param ownerNode The mesh that will be dragged around once attached
  35983. */
  35984. attach(ownerNode: AbstractMesh): void;
  35985. /**
  35986. * Force relase the drag action by code.
  35987. */
  35988. releaseDrag(): void;
  35989. private _startDragRay;
  35990. private _lastPointerRay;
  35991. /**
  35992. * Simulates the start of a pointer drag event on the behavior
  35993. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  35994. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  35995. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  35996. */
  35997. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  35998. private _startDrag;
  35999. private _dragDelta;
  36000. private _moveDrag;
  36001. private _pickWithRayOnDragPlane;
  36002. private _pointA;
  36003. private _pointB;
  36004. private _pointC;
  36005. private _lineA;
  36006. private _lineB;
  36007. private _localAxis;
  36008. private _lookAt;
  36009. private _updateDragPlanePosition;
  36010. /**
  36011. * Detaches the behavior from the mesh
  36012. */
  36013. detach(): void;
  36014. }
  36015. }
  36016. declare module BABYLON {
  36017. /**
  36018. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36019. */
  36020. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36021. private _dragBehaviorA;
  36022. private _dragBehaviorB;
  36023. private _startDistance;
  36024. private _initialScale;
  36025. private _targetScale;
  36026. private _ownerNode;
  36027. private _sceneRenderObserver;
  36028. /**
  36029. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36030. */
  36031. constructor();
  36032. /**
  36033. * The name of the behavior
  36034. */
  36035. readonly name: string;
  36036. /**
  36037. * Initializes the behavior
  36038. */
  36039. init(): void;
  36040. private _getCurrentDistance;
  36041. /**
  36042. * Attaches the scale behavior the passed in mesh
  36043. * @param ownerNode The mesh that will be scaled around once attached
  36044. */
  36045. attach(ownerNode: Mesh): void;
  36046. /**
  36047. * Detaches the behavior from the mesh
  36048. */
  36049. detach(): void;
  36050. }
  36051. }
  36052. declare module BABYLON {
  36053. /**
  36054. * 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
  36055. */
  36056. export class SixDofDragBehavior implements Behavior<Mesh> {
  36057. private static _virtualScene;
  36058. private _ownerNode;
  36059. private _sceneRenderObserver;
  36060. private _scene;
  36061. private _targetPosition;
  36062. private _virtualOriginMesh;
  36063. private _virtualDragMesh;
  36064. private _pointerObserver;
  36065. private _moving;
  36066. private _startingOrientation;
  36067. /**
  36068. * 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)
  36069. */
  36070. private zDragFactor;
  36071. /**
  36072. * If the object should rotate to face the drag origin
  36073. */
  36074. rotateDraggedObject: boolean;
  36075. /**
  36076. * If the behavior is currently in a dragging state
  36077. */
  36078. dragging: boolean;
  36079. /**
  36080. * 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)
  36081. */
  36082. dragDeltaRatio: number;
  36083. /**
  36084. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36085. */
  36086. currentDraggingPointerID: number;
  36087. /**
  36088. * If camera controls should be detached during the drag
  36089. */
  36090. detachCameraControls: boolean;
  36091. /**
  36092. * Fires each time a drag starts
  36093. */
  36094. onDragStartObservable: Observable<{}>;
  36095. /**
  36096. * Fires each time a drag ends (eg. mouse release after drag)
  36097. */
  36098. onDragEndObservable: Observable<{}>;
  36099. /**
  36100. * 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
  36101. */
  36102. constructor();
  36103. /**
  36104. * The name of the behavior
  36105. */
  36106. readonly name: string;
  36107. /**
  36108. * Initializes the behavior
  36109. */
  36110. init(): void;
  36111. /**
  36112. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  36113. */
  36114. private readonly _pointerCamera;
  36115. /**
  36116. * Attaches the scale behavior the passed in mesh
  36117. * @param ownerNode The mesh that will be scaled around once attached
  36118. */
  36119. attach(ownerNode: Mesh): void;
  36120. /**
  36121. * Detaches the behavior from the mesh
  36122. */
  36123. detach(): void;
  36124. }
  36125. }
  36126. declare module BABYLON {
  36127. /**
  36128. * Class used to apply inverse kinematics to bones
  36129. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36130. */
  36131. export class BoneIKController {
  36132. private static _tmpVecs;
  36133. private static _tmpQuat;
  36134. private static _tmpMats;
  36135. /**
  36136. * Gets or sets the target mesh
  36137. */
  36138. targetMesh: AbstractMesh;
  36139. /** Gets or sets the mesh used as pole */
  36140. poleTargetMesh: AbstractMesh;
  36141. /**
  36142. * Gets or sets the bone used as pole
  36143. */
  36144. poleTargetBone: Nullable<Bone>;
  36145. /**
  36146. * Gets or sets the target position
  36147. */
  36148. targetPosition: Vector3;
  36149. /**
  36150. * Gets or sets the pole target position
  36151. */
  36152. poleTargetPosition: Vector3;
  36153. /**
  36154. * Gets or sets the pole target local offset
  36155. */
  36156. poleTargetLocalOffset: Vector3;
  36157. /**
  36158. * Gets or sets the pole angle
  36159. */
  36160. poleAngle: number;
  36161. /**
  36162. * Gets or sets the mesh associated with the controller
  36163. */
  36164. mesh: AbstractMesh;
  36165. /**
  36166. * 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)
  36167. */
  36168. slerpAmount: number;
  36169. private _bone1Quat;
  36170. private _bone1Mat;
  36171. private _bone2Ang;
  36172. private _bone1;
  36173. private _bone2;
  36174. private _bone1Length;
  36175. private _bone2Length;
  36176. private _maxAngle;
  36177. private _maxReach;
  36178. private _rightHandedSystem;
  36179. private _bendAxis;
  36180. private _slerping;
  36181. private _adjustRoll;
  36182. /**
  36183. * Gets or sets maximum allowed angle
  36184. */
  36185. maxAngle: number;
  36186. /**
  36187. * Creates a new BoneIKController
  36188. * @param mesh defines the mesh to control
  36189. * @param bone defines the bone to control
  36190. * @param options defines options to set up the controller
  36191. */
  36192. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36193. targetMesh?: AbstractMesh;
  36194. poleTargetMesh?: AbstractMesh;
  36195. poleTargetBone?: Bone;
  36196. poleTargetLocalOffset?: Vector3;
  36197. poleAngle?: number;
  36198. bendAxis?: Vector3;
  36199. maxAngle?: number;
  36200. slerpAmount?: number;
  36201. });
  36202. private _setMaxAngle;
  36203. /**
  36204. * Force the controller to update the bones
  36205. */
  36206. update(): void;
  36207. }
  36208. }
  36209. declare module BABYLON {
  36210. /**
  36211. * Class used to make a bone look toward a point in space
  36212. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36213. */
  36214. export class BoneLookController {
  36215. private static _tmpVecs;
  36216. private static _tmpQuat;
  36217. private static _tmpMats;
  36218. /**
  36219. * The target Vector3 that the bone will look at
  36220. */
  36221. target: Vector3;
  36222. /**
  36223. * The mesh that the bone is attached to
  36224. */
  36225. mesh: AbstractMesh;
  36226. /**
  36227. * The bone that will be looking to the target
  36228. */
  36229. bone: Bone;
  36230. /**
  36231. * The up axis of the coordinate system that is used when the bone is rotated
  36232. */
  36233. upAxis: Vector3;
  36234. /**
  36235. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36236. */
  36237. upAxisSpace: Space;
  36238. /**
  36239. * Used to make an adjustment to the yaw of the bone
  36240. */
  36241. adjustYaw: number;
  36242. /**
  36243. * Used to make an adjustment to the pitch of the bone
  36244. */
  36245. adjustPitch: number;
  36246. /**
  36247. * Used to make an adjustment to the roll of the bone
  36248. */
  36249. adjustRoll: number;
  36250. /**
  36251. * 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)
  36252. */
  36253. slerpAmount: number;
  36254. private _minYaw;
  36255. private _maxYaw;
  36256. private _minPitch;
  36257. private _maxPitch;
  36258. private _minYawSin;
  36259. private _minYawCos;
  36260. private _maxYawSin;
  36261. private _maxYawCos;
  36262. private _midYawConstraint;
  36263. private _minPitchTan;
  36264. private _maxPitchTan;
  36265. private _boneQuat;
  36266. private _slerping;
  36267. private _transformYawPitch;
  36268. private _transformYawPitchInv;
  36269. private _firstFrameSkipped;
  36270. private _yawRange;
  36271. private _fowardAxis;
  36272. /**
  36273. * Gets or sets the minimum yaw angle that the bone can look to
  36274. */
  36275. minYaw: number;
  36276. /**
  36277. * Gets or sets the maximum yaw angle that the bone can look to
  36278. */
  36279. maxYaw: number;
  36280. /**
  36281. * Gets or sets the minimum pitch angle that the bone can look to
  36282. */
  36283. minPitch: number;
  36284. /**
  36285. * Gets or sets the maximum pitch angle that the bone can look to
  36286. */
  36287. maxPitch: number;
  36288. /**
  36289. * Create a BoneLookController
  36290. * @param mesh the mesh that the bone belongs to
  36291. * @param bone the bone that will be looking to the target
  36292. * @param target the target Vector3 to look at
  36293. * @param options optional settings:
  36294. * * maxYaw: the maximum angle the bone will yaw to
  36295. * * minYaw: the minimum angle the bone will yaw to
  36296. * * maxPitch: the maximum angle the bone will pitch to
  36297. * * minPitch: the minimum angle the bone will yaw to
  36298. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36299. * * upAxis: the up axis of the coordinate system
  36300. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36301. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36302. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36303. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36304. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36305. * * adjustRoll: used to make an adjustment to the roll of the bone
  36306. **/
  36307. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36308. maxYaw?: number;
  36309. minYaw?: number;
  36310. maxPitch?: number;
  36311. minPitch?: number;
  36312. slerpAmount?: number;
  36313. upAxis?: Vector3;
  36314. upAxisSpace?: Space;
  36315. yawAxis?: Vector3;
  36316. pitchAxis?: Vector3;
  36317. adjustYaw?: number;
  36318. adjustPitch?: number;
  36319. adjustRoll?: number;
  36320. });
  36321. /**
  36322. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36323. */
  36324. update(): void;
  36325. private _getAngleDiff;
  36326. private _getAngleBetween;
  36327. private _isAngleBetween;
  36328. }
  36329. }
  36330. declare module BABYLON {
  36331. /**
  36332. * Manage the gamepad inputs to control an arc rotate camera.
  36333. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36334. */
  36335. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  36336. /**
  36337. * Defines the camera the input is attached to.
  36338. */
  36339. camera: ArcRotateCamera;
  36340. /**
  36341. * Defines the gamepad the input is gathering event from.
  36342. */
  36343. gamepad: Nullable<Gamepad>;
  36344. /**
  36345. * Defines the gamepad rotation sensiblity.
  36346. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  36347. */
  36348. gamepadRotationSensibility: number;
  36349. /**
  36350. * Defines the gamepad move sensiblity.
  36351. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  36352. */
  36353. gamepadMoveSensibility: number;
  36354. private _onGamepadConnectedObserver;
  36355. private _onGamepadDisconnectedObserver;
  36356. /**
  36357. * Attach the input controls to a specific dom element to get the input from.
  36358. * @param element Defines the element the controls should be listened from
  36359. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36360. */
  36361. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36362. /**
  36363. * Detach the current controls from the specified dom element.
  36364. * @param element Defines the element to stop listening the inputs from
  36365. */
  36366. detachControl(element: Nullable<HTMLElement>): void;
  36367. /**
  36368. * Update the current camera state depending on the inputs that have been used this frame.
  36369. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36370. */
  36371. checkInputs(): void;
  36372. /**
  36373. * Gets the class name of the current intput.
  36374. * @returns the class name
  36375. */
  36376. getClassName(): string;
  36377. /**
  36378. * Get the friendly name associated with the input class.
  36379. * @returns the input friendly name
  36380. */
  36381. getSimpleName(): string;
  36382. }
  36383. }
  36384. declare module BABYLON {
  36385. interface ArcRotateCameraInputsManager {
  36386. /**
  36387. * Add orientation input support to the input manager.
  36388. * @returns the current input manager
  36389. */
  36390. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  36391. }
  36392. /**
  36393. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  36394. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36395. */
  36396. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  36397. /**
  36398. * Defines the camera the input is attached to.
  36399. */
  36400. camera: ArcRotateCamera;
  36401. /**
  36402. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  36403. */
  36404. alphaCorrection: number;
  36405. /**
  36406. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  36407. */
  36408. gammaCorrection: number;
  36409. private _alpha;
  36410. private _gamma;
  36411. private _dirty;
  36412. private _deviceOrientationHandler;
  36413. /**
  36414. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  36415. */
  36416. constructor();
  36417. /**
  36418. * Attach the input controls to a specific dom element to get the input from.
  36419. * @param element Defines the element the controls should be listened from
  36420. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36421. */
  36422. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36423. /** @hidden */ private _onOrientationEvent(evt: DeviceOrientationEvent): void;
  36424. /**
  36425. * Update the current camera state depending on the inputs that have been used this frame.
  36426. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36427. */
  36428. checkInputs(): void;
  36429. /**
  36430. * Detach the current controls from the specified dom element.
  36431. * @param element Defines the element to stop listening the inputs from
  36432. */
  36433. detachControl(element: Nullable<HTMLElement>): void;
  36434. /**
  36435. * Gets the class name of the current intput.
  36436. * @returns the class name
  36437. */
  36438. getClassName(): string;
  36439. /**
  36440. * Get the friendly name associated with the input class.
  36441. * @returns the input friendly name
  36442. */
  36443. getSimpleName(): string;
  36444. }
  36445. }
  36446. declare module BABYLON {
  36447. /**
  36448. * Listen to mouse events to control the camera.
  36449. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36450. */
  36451. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  36452. /**
  36453. * Defines the camera the input is attached to.
  36454. */
  36455. camera: FlyCamera;
  36456. /**
  36457. * Defines if touch is enabled. (Default is true.)
  36458. */
  36459. touchEnabled: boolean;
  36460. /**
  36461. * Defines the buttons associated with the input to handle camera rotation.
  36462. */
  36463. buttons: number[];
  36464. /**
  36465. * Assign buttons for Yaw control.
  36466. */
  36467. buttonsYaw: number[];
  36468. /**
  36469. * Assign buttons for Pitch control.
  36470. */
  36471. buttonsPitch: number[];
  36472. /**
  36473. * Assign buttons for Roll control.
  36474. */
  36475. buttonsRoll: number[];
  36476. /**
  36477. * Detect if any button is being pressed while mouse is moved.
  36478. * -1 = Mouse locked.
  36479. * 0 = Left button.
  36480. * 1 = Middle Button.
  36481. * 2 = Right Button.
  36482. */
  36483. activeButton: number;
  36484. /**
  36485. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  36486. * Higher values reduce its sensitivity.
  36487. */
  36488. angularSensibility: number;
  36489. private _mousemoveCallback;
  36490. private _observer;
  36491. private _rollObserver;
  36492. private previousPosition;
  36493. private noPreventDefault;
  36494. private element;
  36495. /**
  36496. * Listen to mouse events to control the camera.
  36497. * @param touchEnabled Define if touch is enabled. (Default is true.)
  36498. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36499. */
  36500. constructor(touchEnabled?: boolean);
  36501. /**
  36502. * Attach the mouse control to the HTML DOM element.
  36503. * @param element Defines the element that listens to the input events.
  36504. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  36505. */
  36506. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36507. /**
  36508. * Detach the current controls from the specified dom element.
  36509. * @param element Defines the element to stop listening the inputs from
  36510. */
  36511. detachControl(element: Nullable<HTMLElement>): void;
  36512. /**
  36513. * Gets the class name of the current input.
  36514. * @returns the class name.
  36515. */
  36516. getClassName(): string;
  36517. /**
  36518. * Get the friendly name associated with the input class.
  36519. * @returns the input's friendly name.
  36520. */
  36521. getSimpleName(): string;
  36522. private _pointerInput;
  36523. private _onMouseMove;
  36524. /**
  36525. * Rotate camera by mouse offset.
  36526. */
  36527. private rotateCamera;
  36528. }
  36529. }
  36530. declare module BABYLON {
  36531. /**
  36532. * Default Inputs manager for the FlyCamera.
  36533. * It groups all the default supported inputs for ease of use.
  36534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36535. */
  36536. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  36537. /**
  36538. * Instantiates a new FlyCameraInputsManager.
  36539. * @param camera Defines the camera the inputs belong to.
  36540. */
  36541. constructor(camera: FlyCamera);
  36542. /**
  36543. * Add keyboard input support to the input manager.
  36544. * @returns the new FlyCameraKeyboardMoveInput().
  36545. */
  36546. addKeyboard(): FlyCameraInputsManager;
  36547. /**
  36548. * Add mouse input support to the input manager.
  36549. * @param touchEnabled Enable touch screen support.
  36550. * @returns the new FlyCameraMouseInput().
  36551. */
  36552. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  36553. }
  36554. }
  36555. declare module BABYLON {
  36556. /**
  36557. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36558. * such as in a 3D Space Shooter or a Flight Simulator.
  36559. */
  36560. export class FlyCamera extends TargetCamera {
  36561. /**
  36562. * Define the collision ellipsoid of the camera.
  36563. * This is helpful for simulating a camera body, like a player's body.
  36564. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36565. */
  36566. ellipsoid: Vector3;
  36567. /**
  36568. * Define an offset for the position of the ellipsoid around the camera.
  36569. * This can be helpful if the camera is attached away from the player's body center,
  36570. * such as at its head.
  36571. */
  36572. ellipsoidOffset: Vector3;
  36573. /**
  36574. * Enable or disable collisions of the camera with the rest of the scene objects.
  36575. */
  36576. checkCollisions: boolean;
  36577. /**
  36578. * Enable or disable gravity on the camera.
  36579. */
  36580. applyGravity: boolean;
  36581. /**
  36582. * Define the current direction the camera is moving to.
  36583. */
  36584. cameraDirection: Vector3;
  36585. /**
  36586. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  36587. * This overrides and empties cameraRotation.
  36588. */
  36589. rotationQuaternion: Quaternion;
  36590. /**
  36591. * Track Roll to maintain the wanted Rolling when looking around.
  36592. */ private _trackRoll: number;
  36593. /**
  36594. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  36595. */
  36596. rollCorrect: number;
  36597. /**
  36598. * Mimic a banked turn, Rolling the camera when Yawing.
  36599. * It's recommended to use rollCorrect = 10 for faster banking correction.
  36600. */
  36601. bankedTurn: boolean;
  36602. /**
  36603. * Limit in radians for how much Roll banking will add. (Default: 90°)
  36604. */
  36605. bankedTurnLimit: number;
  36606. /**
  36607. * Value of 0 disables the banked Roll.
  36608. * Value of 1 is equal to the Yaw angle in radians.
  36609. */
  36610. bankedTurnMultiplier: number;
  36611. /**
  36612. * The inputs manager loads all the input sources, such as keyboard and mouse.
  36613. */
  36614. inputs: FlyCameraInputsManager;
  36615. /**
  36616. * Gets the input sensibility for mouse input.
  36617. * Higher values reduce sensitivity.
  36618. */
  36619. /**
  36620. * Sets the input sensibility for a mouse input.
  36621. * Higher values reduce sensitivity.
  36622. */
  36623. angularSensibility: number;
  36624. /**
  36625. * Get the keys for camera movement forward.
  36626. */
  36627. /**
  36628. * Set the keys for camera movement forward.
  36629. */
  36630. keysForward: number[];
  36631. /**
  36632. * Get the keys for camera movement backward.
  36633. */
  36634. keysBackward: number[];
  36635. /**
  36636. * Get the keys for camera movement up.
  36637. */
  36638. /**
  36639. * Set the keys for camera movement up.
  36640. */
  36641. keysUp: number[];
  36642. /**
  36643. * Get the keys for camera movement down.
  36644. */
  36645. /**
  36646. * Set the keys for camera movement down.
  36647. */
  36648. keysDown: number[];
  36649. /**
  36650. * Get the keys for camera movement left.
  36651. */
  36652. /**
  36653. * Set the keys for camera movement left.
  36654. */
  36655. keysLeft: number[];
  36656. /**
  36657. * Set the keys for camera movement right.
  36658. */
  36659. /**
  36660. * Set the keys for camera movement right.
  36661. */
  36662. keysRight: number[];
  36663. /**
  36664. * Event raised when the camera collides with a mesh in the scene.
  36665. */
  36666. onCollide: (collidedMesh: AbstractMesh) => void;
  36667. private _collider;
  36668. private _needMoveForGravity;
  36669. private _oldPosition;
  36670. private _diffPosition;
  36671. private _newPosition;
  36672. /** @hidden */ private _localDirection: Vector3;
  36673. /** @hidden */ private _transformedDirection: Vector3;
  36674. /**
  36675. * Instantiates a FlyCamera.
  36676. * This is a flying camera, designed for 3D movement and rotation in all directions,
  36677. * such as in a 3D Space Shooter or a Flight Simulator.
  36678. * @param name Define the name of the camera in the scene.
  36679. * @param position Define the starting position of the camera in the scene.
  36680. * @param scene Define the scene the camera belongs to.
  36681. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  36682. */
  36683. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36684. /**
  36685. * Attach a control to the HTML DOM element.
  36686. * @param element Defines the element that listens to the input events.
  36687. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  36688. */
  36689. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36690. /**
  36691. * Detach a control from the HTML DOM element.
  36692. * The camera will stop reacting to that input.
  36693. * @param element Defines the element that listens to the input events.
  36694. */
  36695. detachControl(element: HTMLElement): void;
  36696. private _collisionMask;
  36697. /**
  36698. * Get the mask that the camera ignores in collision events.
  36699. */
  36700. /**
  36701. * Set the mask that the camera ignores in collision events.
  36702. */
  36703. collisionMask: number;
  36704. /** @hidden */ private _collideWithWorld(displacement: Vector3): void;
  36705. /** @hidden */
  36706. private _onCollisionPositionChange;
  36707. /** @hidden */ private _checkInputs(): void;
  36708. /** @hidden */ private _decideIfNeedsToMove(): boolean;
  36709. /** @hidden */ private _updatePosition(): void;
  36710. /**
  36711. * Restore the Roll to its target value at the rate specified.
  36712. * @param rate - Higher means slower restoring.
  36713. * @hidden
  36714. */
  36715. restoreRoll(rate: number): void;
  36716. /**
  36717. * Destroy the camera and release the current resources held by it.
  36718. */
  36719. dispose(): void;
  36720. /**
  36721. * Get the current object class name.
  36722. * @returns the class name.
  36723. */
  36724. getClassName(): string;
  36725. }
  36726. }
  36727. declare module BABYLON {
  36728. /**
  36729. * Listen to keyboard events to control the camera.
  36730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36731. */
  36732. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  36733. /**
  36734. * Defines the camera the input is attached to.
  36735. */
  36736. camera: FlyCamera;
  36737. /**
  36738. * The list of keyboard keys used to control the forward move of the camera.
  36739. */
  36740. keysForward: number[];
  36741. /**
  36742. * The list of keyboard keys used to control the backward move of the camera.
  36743. */
  36744. keysBackward: number[];
  36745. /**
  36746. * The list of keyboard keys used to control the forward move of the camera.
  36747. */
  36748. keysUp: number[];
  36749. /**
  36750. * The list of keyboard keys used to control the backward move of the camera.
  36751. */
  36752. keysDown: number[];
  36753. /**
  36754. * The list of keyboard keys used to control the right strafe move of the camera.
  36755. */
  36756. keysRight: number[];
  36757. /**
  36758. * The list of keyboard keys used to control the left strafe move of the camera.
  36759. */
  36760. keysLeft: number[];
  36761. private _keys;
  36762. private _onCanvasBlurObserver;
  36763. private _onKeyboardObserver;
  36764. private _engine;
  36765. private _scene;
  36766. /**
  36767. * Attach the input controls to a specific dom element to get the input from.
  36768. * @param element Defines the element the controls should be listened from
  36769. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36770. */
  36771. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36772. /**
  36773. * Detach the current controls from the specified dom element.
  36774. * @param element Defines the element to stop listening the inputs from
  36775. */
  36776. detachControl(element: Nullable<HTMLElement>): void;
  36777. /**
  36778. * Gets the class name of the current intput.
  36779. * @returns the class name
  36780. */
  36781. getClassName(): string;
  36782. /** @hidden */ private _onLostFocus(e: FocusEvent): void;
  36783. /**
  36784. * Get the friendly name associated with the input class.
  36785. * @returns the input friendly name
  36786. */
  36787. getSimpleName(): string;
  36788. /**
  36789. * Update the current camera state depending on the inputs that have been used this frame.
  36790. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  36791. */
  36792. checkInputs(): void;
  36793. }
  36794. }
  36795. declare module BABYLON {
  36796. /**
  36797. * Manage the mouse wheel inputs to control a follow camera.
  36798. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36799. */
  36800. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  36801. /**
  36802. * Defines the camera the input is attached to.
  36803. */
  36804. camera: FollowCamera;
  36805. /**
  36806. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  36807. */
  36808. axisControlRadius: boolean;
  36809. /**
  36810. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  36811. */
  36812. axisControlHeight: boolean;
  36813. /**
  36814. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  36815. */
  36816. axisControlRotation: boolean;
  36817. /**
  36818. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  36819. * relation to mouseWheel events.
  36820. */
  36821. wheelPrecision: number;
  36822. /**
  36823. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  36824. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  36825. */
  36826. wheelDeltaPercentage: number;
  36827. private _wheel;
  36828. private _observer;
  36829. /**
  36830. * Attach the input controls to a specific dom element to get the input from.
  36831. * @param element Defines the element the controls should be listened from
  36832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36833. */
  36834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  36835. /**
  36836. * Detach the current controls from the specified dom element.
  36837. * @param element Defines the element to stop listening the inputs from
  36838. */
  36839. detachControl(element: Nullable<HTMLElement>): void;
  36840. /**
  36841. * Gets the class name of the current intput.
  36842. * @returns the class name
  36843. */
  36844. getClassName(): string;
  36845. /**
  36846. * Get the friendly name associated with the input class.
  36847. * @returns the input friendly name
  36848. */
  36849. getSimpleName(): string;
  36850. }
  36851. }
  36852. declare module BABYLON {
  36853. /**
  36854. * Manage the pointers inputs to control an follow camera.
  36855. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36856. */
  36857. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  36858. /**
  36859. * Defines the camera the input is attached to.
  36860. */
  36861. camera: FollowCamera;
  36862. /**
  36863. * Gets the class name of the current input.
  36864. * @returns the class name
  36865. */
  36866. getClassName(): string;
  36867. /**
  36868. * Defines the pointer angular sensibility along the X axis or how fast is
  36869. * the camera rotating.
  36870. * A negative number will reverse the axis direction.
  36871. */
  36872. angularSensibilityX: number;
  36873. /**
  36874. * Defines the pointer angular sensibility along the Y axis or how fast is
  36875. * the camera rotating.
  36876. * A negative number will reverse the axis direction.
  36877. */
  36878. angularSensibilityY: number;
  36879. /**
  36880. * Defines the pointer pinch precision or how fast is the camera zooming.
  36881. * A negative number will reverse the axis direction.
  36882. */
  36883. pinchPrecision: number;
  36884. /**
  36885. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  36886. * from 0.
  36887. * It defines the percentage of current camera.radius to use as delta when
  36888. * pinch zoom is used.
  36889. */
  36890. pinchDeltaPercentage: number;
  36891. /**
  36892. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  36893. */
  36894. axisXControlRadius: boolean;
  36895. /**
  36896. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  36897. */
  36898. axisXControlHeight: boolean;
  36899. /**
  36900. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  36901. */
  36902. axisXControlRotation: boolean;
  36903. /**
  36904. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  36905. */
  36906. axisYControlRadius: boolean;
  36907. /**
  36908. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  36909. */
  36910. axisYControlHeight: boolean;
  36911. /**
  36912. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  36913. */
  36914. axisYControlRotation: boolean;
  36915. /**
  36916. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  36917. */
  36918. axisPinchControlRadius: boolean;
  36919. /**
  36920. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  36921. */
  36922. axisPinchControlHeight: boolean;
  36923. /**
  36924. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  36925. */
  36926. axisPinchControlRotation: boolean;
  36927. /**
  36928. * Log error messages if basic misconfiguration has occurred.
  36929. */
  36930. warningEnable: boolean;
  36931. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  36932. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  36933. private _warningCounter;
  36934. private _warning;
  36935. }
  36936. }
  36937. declare module BABYLON {
  36938. /**
  36939. * Default Inputs manager for the FollowCamera.
  36940. * It groups all the default supported inputs for ease of use.
  36941. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  36942. */
  36943. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  36944. /**
  36945. * Instantiates a new FollowCameraInputsManager.
  36946. * @param camera Defines the camera the inputs belong to
  36947. */
  36948. constructor(camera: FollowCamera);
  36949. /**
  36950. * Add keyboard input support to the input manager.
  36951. * @returns the current input manager
  36952. */
  36953. addKeyboard(): FollowCameraInputsManager;
  36954. /**
  36955. * Add mouse wheel input support to the input manager.
  36956. * @returns the current input manager
  36957. */
  36958. addMouseWheel(): FollowCameraInputsManager;
  36959. /**
  36960. * Add pointers input support to the input manager.
  36961. * @returns the current input manager
  36962. */
  36963. addPointers(): FollowCameraInputsManager;
  36964. /**
  36965. * Add orientation input support to the input manager.
  36966. * @returns the current input manager
  36967. */
  36968. addVRDeviceOrientation(): FollowCameraInputsManager;
  36969. }
  36970. }
  36971. declare module BABYLON {
  36972. /**
  36973. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  36974. * an arc rotate version arcFollowCamera are available.
  36975. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  36976. */
  36977. export class FollowCamera extends TargetCamera {
  36978. /**
  36979. * Distance the follow camera should follow an object at
  36980. */
  36981. radius: number;
  36982. /**
  36983. * Minimum allowed distance of the camera to the axis of rotation
  36984. * (The camera can not get closer).
  36985. * This can help limiting how the Camera is able to move in the scene.
  36986. */
  36987. lowerRadiusLimit: Nullable<number>;
  36988. /**
  36989. * Maximum allowed distance of the camera to the axis of rotation
  36990. * (The camera can not get further).
  36991. * This can help limiting how the Camera is able to move in the scene.
  36992. */
  36993. upperRadiusLimit: Nullable<number>;
  36994. /**
  36995. * Define a rotation offset between the camera and the object it follows
  36996. */
  36997. rotationOffset: number;
  36998. /**
  36999. * Minimum allowed angle to camera position relative to target object.
  37000. * This can help limiting how the Camera is able to move in the scene.
  37001. */
  37002. lowerRotationOffsetLimit: Nullable<number>;
  37003. /**
  37004. * Maximum allowed angle to camera position relative to target object.
  37005. * This can help limiting how the Camera is able to move in the scene.
  37006. */
  37007. upperRotationOffsetLimit: Nullable<number>;
  37008. /**
  37009. * Define a height offset between the camera and the object it follows.
  37010. * It can help following an object from the top (like a car chaing a plane)
  37011. */
  37012. heightOffset: number;
  37013. /**
  37014. * Minimum allowed height of camera position relative to target object.
  37015. * This can help limiting how the Camera is able to move in the scene.
  37016. */
  37017. lowerHeightOffsetLimit: Nullable<number>;
  37018. /**
  37019. * Maximum allowed height of camera position relative to target object.
  37020. * This can help limiting how the Camera is able to move in the scene.
  37021. */
  37022. upperHeightOffsetLimit: Nullable<number>;
  37023. /**
  37024. * Define how fast the camera can accelerate to follow it s target.
  37025. */
  37026. cameraAcceleration: number;
  37027. /**
  37028. * Define the speed limit of the camera following an object.
  37029. */
  37030. maxCameraSpeed: number;
  37031. /**
  37032. * Define the target of the camera.
  37033. */
  37034. lockedTarget: Nullable<AbstractMesh>;
  37035. /**
  37036. * Defines the input associated with the camera.
  37037. */
  37038. inputs: FollowCameraInputsManager;
  37039. /**
  37040. * Instantiates the follow camera.
  37041. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37042. * @param name Define the name of the camera in the scene
  37043. * @param position Define the position of the camera
  37044. * @param scene Define the scene the camera belong to
  37045. * @param lockedTarget Define the target of the camera
  37046. */
  37047. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37048. private _follow;
  37049. /**
  37050. * Attached controls to the current camera.
  37051. * @param element Defines the element the controls should be listened from
  37052. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37053. */
  37054. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37055. /**
  37056. * Detach the current controls from the camera.
  37057. * The camera will stop reacting to inputs.
  37058. * @param element Defines the element to stop listening the inputs from
  37059. */
  37060. detachControl(element: HTMLElement): void;
  37061. /** @hidden */ private _checkInputs(): void;
  37062. private _checkLimits;
  37063. /**
  37064. * Gets the camera class name.
  37065. * @returns the class name
  37066. */
  37067. getClassName(): string;
  37068. }
  37069. /**
  37070. * Arc Rotate version of the follow camera.
  37071. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37072. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37073. */
  37074. export class ArcFollowCamera extends TargetCamera {
  37075. /** The longitudinal angle of the camera */
  37076. alpha: number;
  37077. /** The latitudinal angle of the camera */
  37078. beta: number;
  37079. /** The radius of the camera from its target */
  37080. radius: number;
  37081. /** Define the camera target (the messh it should follow) */
  37082. target: Nullable<AbstractMesh>;
  37083. private _cartesianCoordinates;
  37084. /**
  37085. * Instantiates a new ArcFollowCamera
  37086. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37087. * @param name Define the name of the camera
  37088. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37089. * @param beta Define the rotation angle of the camera around the elevation axis
  37090. * @param radius Define the radius of the camera from its target point
  37091. * @param target Define the target of the camera
  37092. * @param scene Define the scene the camera belongs to
  37093. */
  37094. constructor(name: string,
  37095. /** The longitudinal angle of the camera */
  37096. alpha: number,
  37097. /** The latitudinal angle of the camera */
  37098. beta: number,
  37099. /** The radius of the camera from its target */
  37100. radius: number,
  37101. /** Define the camera target (the messh it should follow) */
  37102. target: Nullable<AbstractMesh>, scene: Scene);
  37103. private _follow;
  37104. /** @hidden */ private _checkInputs(): void;
  37105. /**
  37106. * Returns the class name of the object.
  37107. * It is mostly used internally for serialization purposes.
  37108. */
  37109. getClassName(): string;
  37110. }
  37111. }
  37112. declare module BABYLON {
  37113. /**
  37114. * Manage the keyboard inputs to control the movement of a follow camera.
  37115. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37116. */
  37117. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37118. /**
  37119. * Defines the camera the input is attached to.
  37120. */
  37121. camera: FollowCamera;
  37122. /**
  37123. * Defines the list of key codes associated with the up action (increase heightOffset)
  37124. */
  37125. keysHeightOffsetIncr: number[];
  37126. /**
  37127. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37128. */
  37129. keysHeightOffsetDecr: number[];
  37130. /**
  37131. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37132. */
  37133. keysHeightOffsetModifierAlt: boolean;
  37134. /**
  37135. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37136. */
  37137. keysHeightOffsetModifierCtrl: boolean;
  37138. /**
  37139. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37140. */
  37141. keysHeightOffsetModifierShift: boolean;
  37142. /**
  37143. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37144. */
  37145. keysRotationOffsetIncr: number[];
  37146. /**
  37147. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37148. */
  37149. keysRotationOffsetDecr: number[];
  37150. /**
  37151. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37152. */
  37153. keysRotationOffsetModifierAlt: boolean;
  37154. /**
  37155. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37156. */
  37157. keysRotationOffsetModifierCtrl: boolean;
  37158. /**
  37159. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37160. */
  37161. keysRotationOffsetModifierShift: boolean;
  37162. /**
  37163. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37164. */
  37165. keysRadiusIncr: number[];
  37166. /**
  37167. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37168. */
  37169. keysRadiusDecr: number[];
  37170. /**
  37171. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37172. */
  37173. keysRadiusModifierAlt: boolean;
  37174. /**
  37175. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37176. */
  37177. keysRadiusModifierCtrl: boolean;
  37178. /**
  37179. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37180. */
  37181. keysRadiusModifierShift: boolean;
  37182. /**
  37183. * Defines the rate of change of heightOffset.
  37184. */
  37185. heightSensibility: number;
  37186. /**
  37187. * Defines the rate of change of rotationOffset.
  37188. */
  37189. rotationSensibility: number;
  37190. /**
  37191. * Defines the rate of change of radius.
  37192. */
  37193. radiusSensibility: number;
  37194. private _keys;
  37195. private _ctrlPressed;
  37196. private _altPressed;
  37197. private _shiftPressed;
  37198. private _onCanvasBlurObserver;
  37199. private _onKeyboardObserver;
  37200. private _engine;
  37201. private _scene;
  37202. /**
  37203. * Attach the input controls to a specific dom element to get the input from.
  37204. * @param element Defines the element the controls should be listened from
  37205. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37206. */
  37207. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37208. /**
  37209. * Detach the current controls from the specified dom element.
  37210. * @param element Defines the element to stop listening the inputs from
  37211. */
  37212. detachControl(element: Nullable<HTMLElement>): void;
  37213. /**
  37214. * Update the current camera state depending on the inputs that have been used this frame.
  37215. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37216. */
  37217. checkInputs(): void;
  37218. /**
  37219. * Gets the class name of the current input.
  37220. * @returns the class name
  37221. */
  37222. getClassName(): string;
  37223. /**
  37224. * Get the friendly name associated with the input class.
  37225. * @returns the input friendly name
  37226. */
  37227. getSimpleName(): string;
  37228. /**
  37229. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37230. * allow modification of the heightOffset value.
  37231. */
  37232. private _modifierHeightOffset;
  37233. /**
  37234. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37235. * allow modification of the rotationOffset value.
  37236. */
  37237. private _modifierRotationOffset;
  37238. /**
  37239. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37240. * allow modification of the radius value.
  37241. */
  37242. private _modifierRadius;
  37243. }
  37244. }
  37245. declare module BABYLON {
  37246. interface FreeCameraInputsManager {
  37247. /**
  37248. * @hidden
  37249. */ private _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37250. /**
  37251. * Add orientation input support to the input manager.
  37252. * @returns the current input manager
  37253. */
  37254. addDeviceOrientation(): FreeCameraInputsManager;
  37255. }
  37256. /**
  37257. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37258. * Screen rotation is taken into account.
  37259. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37260. */
  37261. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37262. private _camera;
  37263. private _screenOrientationAngle;
  37264. private _constantTranform;
  37265. private _screenQuaternion;
  37266. private _alpha;
  37267. private _beta;
  37268. private _gamma;
  37269. /**
  37270. * Can be used to detect if a device orientation sensor is availible on a device
  37271. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  37272. * @returns a promise that will resolve on orientation change
  37273. */
  37274. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  37275. /**
  37276. * @hidden
  37277. */ private _onDeviceOrientationChangedObservable: Observable<void>;
  37278. /**
  37279. * Instantiates a new input
  37280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37281. */
  37282. constructor();
  37283. /**
  37284. * Define the camera controlled by the input.
  37285. */
  37286. camera: FreeCamera;
  37287. /**
  37288. * Attach the input controls to a specific dom element to get the input from.
  37289. * @param element Defines the element the controls should be listened from
  37290. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37291. */
  37292. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37293. private _orientationChanged;
  37294. private _deviceOrientation;
  37295. /**
  37296. * Detach the current controls from the specified dom element.
  37297. * @param element Defines the element to stop listening the inputs from
  37298. */
  37299. detachControl(element: Nullable<HTMLElement>): void;
  37300. /**
  37301. * Update the current camera state depending on the inputs that have been used this frame.
  37302. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37303. */
  37304. checkInputs(): void;
  37305. /**
  37306. * Gets the class name of the current intput.
  37307. * @returns the class name
  37308. */
  37309. getClassName(): string;
  37310. /**
  37311. * Get the friendly name associated with the input class.
  37312. * @returns the input friendly name
  37313. */
  37314. getSimpleName(): string;
  37315. }
  37316. }
  37317. declare module BABYLON {
  37318. /**
  37319. * Manage the gamepad inputs to control a free camera.
  37320. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37321. */
  37322. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  37323. /**
  37324. * Define the camera the input is attached to.
  37325. */
  37326. camera: FreeCamera;
  37327. /**
  37328. * Define the Gamepad controlling the input
  37329. */
  37330. gamepad: Nullable<Gamepad>;
  37331. /**
  37332. * Defines the gamepad rotation sensiblity.
  37333. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37334. */
  37335. gamepadAngularSensibility: number;
  37336. /**
  37337. * Defines the gamepad move sensiblity.
  37338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37339. */
  37340. gamepadMoveSensibility: number;
  37341. private _onGamepadConnectedObserver;
  37342. private _onGamepadDisconnectedObserver;
  37343. private _cameraTransform;
  37344. private _deltaTransform;
  37345. private _vector3;
  37346. private _vector2;
  37347. /**
  37348. * Attach the input controls to a specific dom element to get the input from.
  37349. * @param element Defines the element the controls should be listened from
  37350. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37351. */
  37352. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37353. /**
  37354. * Detach the current controls from the specified dom element.
  37355. * @param element Defines the element to stop listening the inputs from
  37356. */
  37357. detachControl(element: Nullable<HTMLElement>): void;
  37358. /**
  37359. * Update the current camera state depending on the inputs that have been used this frame.
  37360. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37361. */
  37362. checkInputs(): void;
  37363. /**
  37364. * Gets the class name of the current intput.
  37365. * @returns the class name
  37366. */
  37367. getClassName(): string;
  37368. /**
  37369. * Get the friendly name associated with the input class.
  37370. * @returns the input friendly name
  37371. */
  37372. getSimpleName(): string;
  37373. }
  37374. }
  37375. declare module BABYLON {
  37376. /**
  37377. * Defines the potential axis of a Joystick
  37378. */
  37379. export enum JoystickAxis {
  37380. /** X axis */
  37381. X = 0,
  37382. /** Y axis */
  37383. Y = 1,
  37384. /** Z axis */
  37385. Z = 2
  37386. }
  37387. /**
  37388. * Class used to define virtual joystick (used in touch mode)
  37389. */
  37390. export class VirtualJoystick {
  37391. /**
  37392. * Gets or sets a boolean indicating that left and right values must be inverted
  37393. */
  37394. reverseLeftRight: boolean;
  37395. /**
  37396. * Gets or sets a boolean indicating that up and down values must be inverted
  37397. */
  37398. reverseUpDown: boolean;
  37399. /**
  37400. * Gets the offset value for the position (ie. the change of the position value)
  37401. */
  37402. deltaPosition: Vector3;
  37403. /**
  37404. * Gets a boolean indicating if the virtual joystick was pressed
  37405. */
  37406. pressed: boolean;
  37407. /**
  37408. * Canvas the virtual joystick will render onto, default z-index of this is 5
  37409. */
  37410. static Canvas: Nullable<HTMLCanvasElement>;
  37411. private static _globalJoystickIndex;
  37412. private static vjCanvasContext;
  37413. private static vjCanvasWidth;
  37414. private static vjCanvasHeight;
  37415. private static halfWidth;
  37416. private _action;
  37417. private _axisTargetedByLeftAndRight;
  37418. private _axisTargetedByUpAndDown;
  37419. private _joystickSensibility;
  37420. private _inversedSensibility;
  37421. private _joystickPointerID;
  37422. private _joystickColor;
  37423. private _joystickPointerPos;
  37424. private _joystickPreviousPointerPos;
  37425. private _joystickPointerStartPos;
  37426. private _deltaJoystickVector;
  37427. private _leftJoystick;
  37428. private _touches;
  37429. private _onPointerDownHandlerRef;
  37430. private _onPointerMoveHandlerRef;
  37431. private _onPointerUpHandlerRef;
  37432. private _onResize;
  37433. /**
  37434. * Creates a new virtual joystick
  37435. * @param leftJoystick defines that the joystick is for left hand (false by default)
  37436. */
  37437. constructor(leftJoystick?: boolean);
  37438. /**
  37439. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  37440. * @param newJoystickSensibility defines the new sensibility
  37441. */
  37442. setJoystickSensibility(newJoystickSensibility: number): void;
  37443. private _onPointerDown;
  37444. private _onPointerMove;
  37445. private _onPointerUp;
  37446. /**
  37447. * Change the color of the virtual joystick
  37448. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  37449. */
  37450. setJoystickColor(newColor: string): void;
  37451. /**
  37452. * Defines a callback to call when the joystick is touched
  37453. * @param action defines the callback
  37454. */
  37455. setActionOnTouch(action: () => any): void;
  37456. /**
  37457. * Defines which axis you'd like to control for left & right
  37458. * @param axis defines the axis to use
  37459. */
  37460. setAxisForLeftRight(axis: JoystickAxis): void;
  37461. /**
  37462. * Defines which axis you'd like to control for up & down
  37463. * @param axis defines the axis to use
  37464. */
  37465. setAxisForUpDown(axis: JoystickAxis): void;
  37466. private _drawVirtualJoystick;
  37467. /**
  37468. * Release internal HTML canvas
  37469. */
  37470. releaseCanvas(): void;
  37471. }
  37472. }
  37473. declare module BABYLON {
  37474. interface FreeCameraInputsManager {
  37475. /**
  37476. * Add virtual joystick input support to the input manager.
  37477. * @returns the current input manager
  37478. */
  37479. addVirtualJoystick(): FreeCameraInputsManager;
  37480. }
  37481. /**
  37482. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  37483. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37484. */
  37485. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  37486. /**
  37487. * Defines the camera the input is attached to.
  37488. */
  37489. camera: FreeCamera;
  37490. private _leftjoystick;
  37491. private _rightjoystick;
  37492. /**
  37493. * Gets the left stick of the virtual joystick.
  37494. * @returns The virtual Joystick
  37495. */
  37496. getLeftJoystick(): VirtualJoystick;
  37497. /**
  37498. * Gets the right stick of the virtual joystick.
  37499. * @returns The virtual Joystick
  37500. */
  37501. getRightJoystick(): VirtualJoystick;
  37502. /**
  37503. * Update the current camera state depending on the inputs that have been used this frame.
  37504. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37505. */
  37506. checkInputs(): void;
  37507. /**
  37508. * Attach the input controls to a specific dom element to get the input from.
  37509. * @param element Defines the element the controls should be listened from
  37510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37511. */
  37512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37513. /**
  37514. * Detach the current controls from the specified dom element.
  37515. * @param element Defines the element to stop listening the inputs from
  37516. */
  37517. detachControl(element: Nullable<HTMLElement>): void;
  37518. /**
  37519. * Gets the class name of the current intput.
  37520. * @returns the class name
  37521. */
  37522. getClassName(): string;
  37523. /**
  37524. * Get the friendly name associated with the input class.
  37525. * @returns the input friendly name
  37526. */
  37527. getSimpleName(): string;
  37528. }
  37529. }
  37530. declare module BABYLON {
  37531. /**
  37532. * This represents a FPS type of camera controlled by touch.
  37533. * This is like a universal camera minus the Gamepad controls.
  37534. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37535. */
  37536. export class TouchCamera extends FreeCamera {
  37537. /**
  37538. * Defines the touch sensibility for rotation.
  37539. * The higher the faster.
  37540. */
  37541. touchAngularSensibility: number;
  37542. /**
  37543. * Defines the touch sensibility for move.
  37544. * The higher the faster.
  37545. */
  37546. touchMoveSensibility: number;
  37547. /**
  37548. * Instantiates a new touch camera.
  37549. * This represents a FPS type of camera controlled by touch.
  37550. * This is like a universal camera minus the Gamepad controls.
  37551. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  37552. * @param name Define the name of the camera in the scene
  37553. * @param position Define the start position of the camera in the scene
  37554. * @param scene Define the scene the camera belongs to
  37555. */
  37556. constructor(name: string, position: Vector3, scene: Scene);
  37557. /**
  37558. * Gets the current object class name.
  37559. * @return the class name
  37560. */
  37561. getClassName(): string;
  37562. /** @hidden */ private _setupInputs(): void;
  37563. }
  37564. }
  37565. declare module BABYLON {
  37566. /**
  37567. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  37568. * being tilted forward or back and left or right.
  37569. */
  37570. export class DeviceOrientationCamera extends FreeCamera {
  37571. private _initialQuaternion;
  37572. private _quaternionCache;
  37573. private _tmpDragQuaternion;
  37574. private _disablePointerInputWhenUsingDeviceOrientation;
  37575. /**
  37576. * Creates a new device orientation camera
  37577. * @param name The name of the camera
  37578. * @param position The start position camera
  37579. * @param scene The scene the camera belongs to
  37580. */
  37581. constructor(name: string, position: Vector3, scene: Scene);
  37582. /**
  37583. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  37584. */
  37585. disablePointerInputWhenUsingDeviceOrientation: boolean;
  37586. private _dragFactor;
  37587. /**
  37588. * Enabled turning on the y axis when the orientation sensor is active
  37589. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  37590. */
  37591. enableHorizontalDragging(dragFactor?: number): void;
  37592. /**
  37593. * Gets the current instance class name ("DeviceOrientationCamera").
  37594. * This helps avoiding instanceof at run time.
  37595. * @returns the class name
  37596. */
  37597. getClassName(): string;
  37598. /**
  37599. * @hidden
  37600. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  37601. */ private _checkInputs(): void;
  37602. /**
  37603. * Reset the camera to its default orientation on the specified axis only.
  37604. * @param axis The axis to reset
  37605. */
  37606. resetToCurrentRotation(axis?: Axis): void;
  37607. }
  37608. }
  37609. declare module BABYLON {
  37610. /**
  37611. * Defines supported buttons for XBox360 compatible gamepads
  37612. */
  37613. export enum Xbox360Button {
  37614. /** A */
  37615. A = 0,
  37616. /** B */
  37617. B = 1,
  37618. /** X */
  37619. X = 2,
  37620. /** Y */
  37621. Y = 3,
  37622. /** Start */
  37623. Start = 4,
  37624. /** Back */
  37625. Back = 5,
  37626. /** Left button */
  37627. LB = 6,
  37628. /** Right button */
  37629. RB = 7,
  37630. /** Left stick */
  37631. LeftStick = 8,
  37632. /** Right stick */
  37633. RightStick = 9
  37634. }
  37635. /** Defines values for XBox360 DPad */
  37636. export enum Xbox360Dpad {
  37637. /** Up */
  37638. Up = 0,
  37639. /** Down */
  37640. Down = 1,
  37641. /** Left */
  37642. Left = 2,
  37643. /** Right */
  37644. Right = 3
  37645. }
  37646. /**
  37647. * Defines a XBox360 gamepad
  37648. */
  37649. export class Xbox360Pad extends Gamepad {
  37650. private _leftTrigger;
  37651. private _rightTrigger;
  37652. private _onlefttriggerchanged;
  37653. private _onrighttriggerchanged;
  37654. private _onbuttondown;
  37655. private _onbuttonup;
  37656. private _ondpaddown;
  37657. private _ondpadup;
  37658. /** Observable raised when a button is pressed */
  37659. onButtonDownObservable: Observable<Xbox360Button>;
  37660. /** Observable raised when a button is released */
  37661. onButtonUpObservable: Observable<Xbox360Button>;
  37662. /** Observable raised when a pad is pressed */
  37663. onPadDownObservable: Observable<Xbox360Dpad>;
  37664. /** Observable raised when a pad is released */
  37665. onPadUpObservable: Observable<Xbox360Dpad>;
  37666. private _buttonA;
  37667. private _buttonB;
  37668. private _buttonX;
  37669. private _buttonY;
  37670. private _buttonBack;
  37671. private _buttonStart;
  37672. private _buttonLB;
  37673. private _buttonRB;
  37674. private _buttonLeftStick;
  37675. private _buttonRightStick;
  37676. private _dPadUp;
  37677. private _dPadDown;
  37678. private _dPadLeft;
  37679. private _dPadRight;
  37680. private _isXboxOnePad;
  37681. /**
  37682. * Creates a new XBox360 gamepad object
  37683. * @param id defines the id of this gamepad
  37684. * @param index defines its index
  37685. * @param gamepad defines the internal HTML gamepad object
  37686. * @param xboxOne defines if it is a XBox One gamepad
  37687. */
  37688. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  37689. /**
  37690. * Defines the callback to call when left trigger is pressed
  37691. * @param callback defines the callback to use
  37692. */
  37693. onlefttriggerchanged(callback: (value: number) => void): void;
  37694. /**
  37695. * Defines the callback to call when right trigger is pressed
  37696. * @param callback defines the callback to use
  37697. */
  37698. onrighttriggerchanged(callback: (value: number) => void): void;
  37699. /**
  37700. * Gets the left trigger value
  37701. */
  37702. /**
  37703. * Sets the left trigger value
  37704. */
  37705. leftTrigger: number;
  37706. /**
  37707. * Gets the right trigger value
  37708. */
  37709. /**
  37710. * Sets the right trigger value
  37711. */
  37712. rightTrigger: number;
  37713. /**
  37714. * Defines the callback to call when a button is pressed
  37715. * @param callback defines the callback to use
  37716. */
  37717. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  37718. /**
  37719. * Defines the callback to call when a button is released
  37720. * @param callback defines the callback to use
  37721. */
  37722. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  37723. /**
  37724. * Defines the callback to call when a pad is pressed
  37725. * @param callback defines the callback to use
  37726. */
  37727. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  37728. /**
  37729. * Defines the callback to call when a pad is released
  37730. * @param callback defines the callback to use
  37731. */
  37732. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  37733. private _setButtonValue;
  37734. private _setDPadValue;
  37735. /**
  37736. * Gets the value of the `A` button
  37737. */
  37738. /**
  37739. * Sets the value of the `A` button
  37740. */
  37741. buttonA: number;
  37742. /**
  37743. * Gets the value of the `B` button
  37744. */
  37745. /**
  37746. * Sets the value of the `B` button
  37747. */
  37748. buttonB: number;
  37749. /**
  37750. * Gets the value of the `X` button
  37751. */
  37752. /**
  37753. * Sets the value of the `X` button
  37754. */
  37755. buttonX: number;
  37756. /**
  37757. * Gets the value of the `Y` button
  37758. */
  37759. /**
  37760. * Sets the value of the `Y` button
  37761. */
  37762. buttonY: number;
  37763. /**
  37764. * Gets the value of the `Start` button
  37765. */
  37766. /**
  37767. * Sets the value of the `Start` button
  37768. */
  37769. buttonStart: number;
  37770. /**
  37771. * Gets the value of the `Back` button
  37772. */
  37773. /**
  37774. * Sets the value of the `Back` button
  37775. */
  37776. buttonBack: number;
  37777. /**
  37778. * Gets the value of the `Left` button
  37779. */
  37780. /**
  37781. * Sets the value of the `Left` button
  37782. */
  37783. buttonLB: number;
  37784. /**
  37785. * Gets the value of the `Right` button
  37786. */
  37787. /**
  37788. * Sets the value of the `Right` button
  37789. */
  37790. buttonRB: number;
  37791. /**
  37792. * Gets the value of the Left joystick
  37793. */
  37794. /**
  37795. * Sets the value of the Left joystick
  37796. */
  37797. buttonLeftStick: number;
  37798. /**
  37799. * Gets the value of the Right joystick
  37800. */
  37801. /**
  37802. * Sets the value of the Right joystick
  37803. */
  37804. buttonRightStick: number;
  37805. /**
  37806. * Gets the value of D-pad up
  37807. */
  37808. /**
  37809. * Sets the value of D-pad up
  37810. */
  37811. dPadUp: number;
  37812. /**
  37813. * Gets the value of D-pad down
  37814. */
  37815. /**
  37816. * Sets the value of D-pad down
  37817. */
  37818. dPadDown: number;
  37819. /**
  37820. * Gets the value of D-pad left
  37821. */
  37822. /**
  37823. * Sets the value of D-pad left
  37824. */
  37825. dPadLeft: number;
  37826. /**
  37827. * Gets the value of D-pad right
  37828. */
  37829. /**
  37830. * Sets the value of D-pad right
  37831. */
  37832. dPadRight: number;
  37833. /**
  37834. * Force the gamepad to synchronize with device values
  37835. */
  37836. update(): void;
  37837. /**
  37838. * Disposes the gamepad
  37839. */
  37840. dispose(): void;
  37841. }
  37842. }
  37843. declare module BABYLON {
  37844. /**
  37845. * Defines supported buttons for DualShock compatible gamepads
  37846. */
  37847. export enum DualShockButton {
  37848. /** Cross */
  37849. Cross = 0,
  37850. /** Circle */
  37851. Circle = 1,
  37852. /** Square */
  37853. Square = 2,
  37854. /** Triangle */
  37855. Triangle = 3,
  37856. /** Options */
  37857. Options = 4,
  37858. /** Share */
  37859. Share = 5,
  37860. /** L1 */
  37861. L1 = 6,
  37862. /** R1 */
  37863. R1 = 7,
  37864. /** Left stick */
  37865. LeftStick = 8,
  37866. /** Right stick */
  37867. RightStick = 9
  37868. }
  37869. /** Defines values for DualShock DPad */
  37870. export enum DualShockDpad {
  37871. /** Up */
  37872. Up = 0,
  37873. /** Down */
  37874. Down = 1,
  37875. /** Left */
  37876. Left = 2,
  37877. /** Right */
  37878. Right = 3
  37879. }
  37880. /**
  37881. * Defines a DualShock gamepad
  37882. */
  37883. export class DualShockPad extends Gamepad {
  37884. private _leftTrigger;
  37885. private _rightTrigger;
  37886. private _onlefttriggerchanged;
  37887. private _onrighttriggerchanged;
  37888. private _onbuttondown;
  37889. private _onbuttonup;
  37890. private _ondpaddown;
  37891. private _ondpadup;
  37892. /** Observable raised when a button is pressed */
  37893. onButtonDownObservable: Observable<DualShockButton>;
  37894. /** Observable raised when a button is released */
  37895. onButtonUpObservable: Observable<DualShockButton>;
  37896. /** Observable raised when a pad is pressed */
  37897. onPadDownObservable: Observable<DualShockDpad>;
  37898. /** Observable raised when a pad is released */
  37899. onPadUpObservable: Observable<DualShockDpad>;
  37900. private _buttonCross;
  37901. private _buttonCircle;
  37902. private _buttonSquare;
  37903. private _buttonTriangle;
  37904. private _buttonShare;
  37905. private _buttonOptions;
  37906. private _buttonL1;
  37907. private _buttonR1;
  37908. private _buttonLeftStick;
  37909. private _buttonRightStick;
  37910. private _dPadUp;
  37911. private _dPadDown;
  37912. private _dPadLeft;
  37913. private _dPadRight;
  37914. /**
  37915. * Creates a new DualShock gamepad object
  37916. * @param id defines the id of this gamepad
  37917. * @param index defines its index
  37918. * @param gamepad defines the internal HTML gamepad object
  37919. */
  37920. constructor(id: string, index: number, gamepad: any);
  37921. /**
  37922. * Defines the callback to call when left trigger is pressed
  37923. * @param callback defines the callback to use
  37924. */
  37925. onlefttriggerchanged(callback: (value: number) => void): void;
  37926. /**
  37927. * Defines the callback to call when right trigger is pressed
  37928. * @param callback defines the callback to use
  37929. */
  37930. onrighttriggerchanged(callback: (value: number) => void): void;
  37931. /**
  37932. * Gets the left trigger value
  37933. */
  37934. /**
  37935. * Sets the left trigger value
  37936. */
  37937. leftTrigger: number;
  37938. /**
  37939. * Gets the right trigger value
  37940. */
  37941. /**
  37942. * Sets the right trigger value
  37943. */
  37944. rightTrigger: number;
  37945. /**
  37946. * Defines the callback to call when a button is pressed
  37947. * @param callback defines the callback to use
  37948. */
  37949. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  37950. /**
  37951. * Defines the callback to call when a button is released
  37952. * @param callback defines the callback to use
  37953. */
  37954. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  37955. /**
  37956. * Defines the callback to call when a pad is pressed
  37957. * @param callback defines the callback to use
  37958. */
  37959. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  37960. /**
  37961. * Defines the callback to call when a pad is released
  37962. * @param callback defines the callback to use
  37963. */
  37964. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  37965. private _setButtonValue;
  37966. private _setDPadValue;
  37967. /**
  37968. * Gets the value of the `Cross` button
  37969. */
  37970. /**
  37971. * Sets the value of the `Cross` button
  37972. */
  37973. buttonCross: number;
  37974. /**
  37975. * Gets the value of the `Circle` button
  37976. */
  37977. /**
  37978. * Sets the value of the `Circle` button
  37979. */
  37980. buttonCircle: number;
  37981. /**
  37982. * Gets the value of the `Square` button
  37983. */
  37984. /**
  37985. * Sets the value of the `Square` button
  37986. */
  37987. buttonSquare: number;
  37988. /**
  37989. * Gets the value of the `Triangle` button
  37990. */
  37991. /**
  37992. * Sets the value of the `Triangle` button
  37993. */
  37994. buttonTriangle: number;
  37995. /**
  37996. * Gets the value of the `Options` button
  37997. */
  37998. /**
  37999. * Sets the value of the `Options` button
  38000. */
  38001. buttonOptions: number;
  38002. /**
  38003. * Gets the value of the `Share` button
  38004. */
  38005. /**
  38006. * Sets the value of the `Share` button
  38007. */
  38008. buttonShare: number;
  38009. /**
  38010. * Gets the value of the `L1` button
  38011. */
  38012. /**
  38013. * Sets the value of the `L1` button
  38014. */
  38015. buttonL1: number;
  38016. /**
  38017. * Gets the value of the `R1` button
  38018. */
  38019. /**
  38020. * Sets the value of the `R1` button
  38021. */
  38022. buttonR1: number;
  38023. /**
  38024. * Gets the value of the Left joystick
  38025. */
  38026. /**
  38027. * Sets the value of the Left joystick
  38028. */
  38029. buttonLeftStick: number;
  38030. /**
  38031. * Gets the value of the Right joystick
  38032. */
  38033. /**
  38034. * Sets the value of the Right joystick
  38035. */
  38036. buttonRightStick: number;
  38037. /**
  38038. * Gets the value of D-pad up
  38039. */
  38040. /**
  38041. * Sets the value of D-pad up
  38042. */
  38043. dPadUp: number;
  38044. /**
  38045. * Gets the value of D-pad down
  38046. */
  38047. /**
  38048. * Sets the value of D-pad down
  38049. */
  38050. dPadDown: number;
  38051. /**
  38052. * Gets the value of D-pad left
  38053. */
  38054. /**
  38055. * Sets the value of D-pad left
  38056. */
  38057. dPadLeft: number;
  38058. /**
  38059. * Gets the value of D-pad right
  38060. */
  38061. /**
  38062. * Sets the value of D-pad right
  38063. */
  38064. dPadRight: number;
  38065. /**
  38066. * Force the gamepad to synchronize with device values
  38067. */
  38068. update(): void;
  38069. /**
  38070. * Disposes the gamepad
  38071. */
  38072. dispose(): void;
  38073. }
  38074. }
  38075. declare module BABYLON {
  38076. /**
  38077. * Manager for handling gamepads
  38078. */
  38079. export class GamepadManager {
  38080. private _scene?;
  38081. private _babylonGamepads;
  38082. private _oneGamepadConnected;
  38083. /** @hidden */ private _isMonitoring: boolean;
  38084. private _gamepadEventSupported;
  38085. private _gamepadSupport;
  38086. /**
  38087. * observable to be triggered when the gamepad controller has been connected
  38088. */
  38089. onGamepadConnectedObservable: Observable<Gamepad>;
  38090. /**
  38091. * observable to be triggered when the gamepad controller has been disconnected
  38092. */
  38093. onGamepadDisconnectedObservable: Observable<Gamepad>;
  38094. private _onGamepadConnectedEvent;
  38095. private _onGamepadDisconnectedEvent;
  38096. /**
  38097. * Initializes the gamepad manager
  38098. * @param _scene BabylonJS scene
  38099. */
  38100. constructor(_scene?: Scene | undefined);
  38101. /**
  38102. * The gamepads in the game pad manager
  38103. */
  38104. readonly gamepads: Gamepad[];
  38105. /**
  38106. * Get the gamepad controllers based on type
  38107. * @param type The type of gamepad controller
  38108. * @returns Nullable gamepad
  38109. */
  38110. getGamepadByType(type?: number): Nullable<Gamepad>;
  38111. /**
  38112. * Disposes the gamepad manager
  38113. */
  38114. dispose(): void;
  38115. private _addNewGamepad;
  38116. private _startMonitoringGamepads;
  38117. private _stopMonitoringGamepads;
  38118. /** @hidden */ private _checkGamepadsStatus(): void;
  38119. private _updateGamepadObjects;
  38120. }
  38121. }
  38122. declare module BABYLON {
  38123. interface Scene {
  38124. /** @hidden */ private _gamepadManager: Nullable<GamepadManager>;
  38125. /**
  38126. * Gets the gamepad manager associated with the scene
  38127. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  38128. */
  38129. gamepadManager: GamepadManager;
  38130. }
  38131. /**
  38132. * Interface representing a free camera inputs manager
  38133. */
  38134. interface FreeCameraInputsManager {
  38135. /**
  38136. * Adds gamepad input support to the FreeCameraInputsManager.
  38137. * @returns the FreeCameraInputsManager
  38138. */
  38139. addGamepad(): FreeCameraInputsManager;
  38140. }
  38141. /**
  38142. * Interface representing an arc rotate camera inputs manager
  38143. */
  38144. interface ArcRotateCameraInputsManager {
  38145. /**
  38146. * Adds gamepad input support to the ArcRotateCamera InputManager.
  38147. * @returns the camera inputs manager
  38148. */
  38149. addGamepad(): ArcRotateCameraInputsManager;
  38150. }
  38151. /**
  38152. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  38153. */
  38154. export class GamepadSystemSceneComponent implements ISceneComponent {
  38155. /**
  38156. * The component name helpfull to identify the component in the list of scene components.
  38157. */
  38158. readonly name: string;
  38159. /**
  38160. * The scene the component belongs to.
  38161. */
  38162. scene: Scene;
  38163. /**
  38164. * Creates a new instance of the component for the given scene
  38165. * @param scene Defines the scene to register the component in
  38166. */
  38167. constructor(scene: Scene);
  38168. /**
  38169. * Registers the component in a given scene
  38170. */
  38171. register(): void;
  38172. /**
  38173. * Rebuilds the elements related to this component in case of
  38174. * context lost for instance.
  38175. */
  38176. rebuild(): void;
  38177. /**
  38178. * Disposes the component and the associated ressources
  38179. */
  38180. dispose(): void;
  38181. private _beforeCameraUpdate;
  38182. }
  38183. }
  38184. declare module BABYLON {
  38185. /**
  38186. * 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,
  38187. * which still works and will still be found in many Playgrounds.
  38188. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38189. */
  38190. export class UniversalCamera extends TouchCamera {
  38191. /**
  38192. * Defines the gamepad rotation sensiblity.
  38193. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38194. */
  38195. gamepadAngularSensibility: number;
  38196. /**
  38197. * Defines the gamepad move sensiblity.
  38198. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38199. */
  38200. gamepadMoveSensibility: number;
  38201. /**
  38202. * 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,
  38203. * which still works and will still be found in many Playgrounds.
  38204. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38205. * @param name Define the name of the camera in the scene
  38206. * @param position Define the start position of the camera in the scene
  38207. * @param scene Define the scene the camera belongs to
  38208. */
  38209. constructor(name: string, position: Vector3, scene: Scene);
  38210. /**
  38211. * Gets the current object class name.
  38212. * @return the class name
  38213. */
  38214. getClassName(): string;
  38215. }
  38216. }
  38217. declare module BABYLON {
  38218. /**
  38219. * This represents a FPS type of camera. This is only here for back compat purpose.
  38220. * Please use the UniversalCamera instead as both are identical.
  38221. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38222. */
  38223. export class GamepadCamera extends UniversalCamera {
  38224. /**
  38225. * Instantiates a new Gamepad Camera
  38226. * This represents a FPS type of camera. This is only here for back compat purpose.
  38227. * Please use the UniversalCamera instead as both are identical.
  38228. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38229. * @param name Define the name of the camera in the scene
  38230. * @param position Define the start position of the camera in the scene
  38231. * @param scene Define the scene the camera belongs to
  38232. */
  38233. constructor(name: string, position: Vector3, scene: Scene);
  38234. /**
  38235. * Gets the current object class name.
  38236. * @return the class name
  38237. */
  38238. getClassName(): string;
  38239. }
  38240. }
  38241. declare module BABYLON {
  38242. /** @hidden */
  38243. export var passPixelShader: {
  38244. name: string;
  38245. shader: string;
  38246. };
  38247. }
  38248. declare module BABYLON {
  38249. /** @hidden */
  38250. export var passCubePixelShader: {
  38251. name: string;
  38252. shader: string;
  38253. };
  38254. }
  38255. declare module BABYLON {
  38256. /**
  38257. * PassPostProcess which produces an output the same as it's input
  38258. */
  38259. export class PassPostProcess extends PostProcess {
  38260. /**
  38261. * Creates the PassPostProcess
  38262. * @param name The name of the effect.
  38263. * @param options The required width/height ratio to downsize to before computing the render pass.
  38264. * @param camera The camera to apply the render pass to.
  38265. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38266. * @param engine The engine which the post process will be applied. (default: current engine)
  38267. * @param reusable If the post process can be reused on the same frame. (default: false)
  38268. * @param textureType The type of texture to be used when performing the post processing.
  38269. * @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)
  38270. */
  38271. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38272. }
  38273. /**
  38274. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38275. */
  38276. export class PassCubePostProcess extends PostProcess {
  38277. private _face;
  38278. /**
  38279. * Gets or sets the cube face to display.
  38280. * * 0 is +X
  38281. * * 1 is -X
  38282. * * 2 is +Y
  38283. * * 3 is -Y
  38284. * * 4 is +Z
  38285. * * 5 is -Z
  38286. */
  38287. face: number;
  38288. /**
  38289. * Creates the PassCubePostProcess
  38290. * @param name The name of the effect.
  38291. * @param options The required width/height ratio to downsize to before computing the render pass.
  38292. * @param camera The camera to apply the render pass to.
  38293. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38294. * @param engine The engine which the post process will be applied. (default: current engine)
  38295. * @param reusable If the post process can be reused on the same frame. (default: false)
  38296. * @param textureType The type of texture to be used when performing the post processing.
  38297. * @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)
  38298. */
  38299. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38300. }
  38301. }
  38302. declare module BABYLON {
  38303. /** @hidden */
  38304. export var anaglyphPixelShader: {
  38305. name: string;
  38306. shader: string;
  38307. };
  38308. }
  38309. declare module BABYLON {
  38310. /**
  38311. * Postprocess used to generate anaglyphic rendering
  38312. */
  38313. export class AnaglyphPostProcess extends PostProcess {
  38314. private _passedProcess;
  38315. /**
  38316. * Creates a new AnaglyphPostProcess
  38317. * @param name defines postprocess name
  38318. * @param options defines creation options or target ratio scale
  38319. * @param rigCameras defines cameras using this postprocess
  38320. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38321. * @param engine defines hosting engine
  38322. * @param reusable defines if the postprocess will be reused multiple times per frame
  38323. */
  38324. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38325. }
  38326. }
  38327. declare module BABYLON {
  38328. /**
  38329. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38330. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38331. */
  38332. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38333. /**
  38334. * Creates a new AnaglyphArcRotateCamera
  38335. * @param name defines camera name
  38336. * @param alpha defines alpha angle (in radians)
  38337. * @param beta defines beta angle (in radians)
  38338. * @param radius defines radius
  38339. * @param target defines camera target
  38340. * @param interaxialDistance defines distance between each color axis
  38341. * @param scene defines the hosting scene
  38342. */
  38343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38344. /**
  38345. * Gets camera class name
  38346. * @returns AnaglyphArcRotateCamera
  38347. */
  38348. getClassName(): string;
  38349. }
  38350. }
  38351. declare module BABYLON {
  38352. /**
  38353. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38354. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38355. */
  38356. export class AnaglyphFreeCamera extends FreeCamera {
  38357. /**
  38358. * Creates a new AnaglyphFreeCamera
  38359. * @param name defines camera name
  38360. * @param position defines initial position
  38361. * @param interaxialDistance defines distance between each color axis
  38362. * @param scene defines the hosting scene
  38363. */
  38364. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38365. /**
  38366. * Gets camera class name
  38367. * @returns AnaglyphFreeCamera
  38368. */
  38369. getClassName(): string;
  38370. }
  38371. }
  38372. declare module BABYLON {
  38373. /**
  38374. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38375. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38376. */
  38377. export class AnaglyphGamepadCamera extends GamepadCamera {
  38378. /**
  38379. * Creates a new AnaglyphGamepadCamera
  38380. * @param name defines camera name
  38381. * @param position defines initial position
  38382. * @param interaxialDistance defines distance between each color axis
  38383. * @param scene defines the hosting scene
  38384. */
  38385. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38386. /**
  38387. * Gets camera class name
  38388. * @returns AnaglyphGamepadCamera
  38389. */
  38390. getClassName(): string;
  38391. }
  38392. }
  38393. declare module BABYLON {
  38394. /**
  38395. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38396. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38397. */
  38398. export class AnaglyphUniversalCamera extends UniversalCamera {
  38399. /**
  38400. * Creates a new AnaglyphUniversalCamera
  38401. * @param name defines camera name
  38402. * @param position defines initial position
  38403. * @param interaxialDistance defines distance between each color axis
  38404. * @param scene defines the hosting scene
  38405. */
  38406. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38407. /**
  38408. * Gets camera class name
  38409. * @returns AnaglyphUniversalCamera
  38410. */
  38411. getClassName(): string;
  38412. }
  38413. }
  38414. declare module BABYLON {
  38415. /** @hidden */
  38416. export var stereoscopicInterlacePixelShader: {
  38417. name: string;
  38418. shader: string;
  38419. };
  38420. }
  38421. declare module BABYLON {
  38422. /**
  38423. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38424. */
  38425. export class StereoscopicInterlacePostProcess extends PostProcess {
  38426. private _stepSize;
  38427. private _passedProcess;
  38428. /**
  38429. * Initializes a StereoscopicInterlacePostProcess
  38430. * @param name The name of the effect.
  38431. * @param rigCameras The rig cameras to be appled to the post process
  38432. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38433. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38434. * @param engine The engine which the post process will be applied. (default: current engine)
  38435. * @param reusable If the post process can be reused on the same frame. (default: false)
  38436. */
  38437. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38438. }
  38439. }
  38440. declare module BABYLON {
  38441. /**
  38442. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38443. * @see http://doc.babylonjs.com/features/cameras
  38444. */
  38445. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38446. /**
  38447. * Creates a new StereoscopicArcRotateCamera
  38448. * @param name defines camera name
  38449. * @param alpha defines alpha angle (in radians)
  38450. * @param beta defines beta angle (in radians)
  38451. * @param radius defines radius
  38452. * @param target defines camera target
  38453. * @param interaxialDistance defines distance between each color axis
  38454. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38455. * @param scene defines the hosting scene
  38456. */
  38457. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38458. /**
  38459. * Gets camera class name
  38460. * @returns StereoscopicArcRotateCamera
  38461. */
  38462. getClassName(): string;
  38463. }
  38464. }
  38465. declare module BABYLON {
  38466. /**
  38467. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38468. * @see http://doc.babylonjs.com/features/cameras
  38469. */
  38470. export class StereoscopicFreeCamera extends FreeCamera {
  38471. /**
  38472. * Creates a new StereoscopicFreeCamera
  38473. * @param name defines camera name
  38474. * @param position defines initial position
  38475. * @param interaxialDistance defines distance between each color axis
  38476. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38477. * @param scene defines the hosting scene
  38478. */
  38479. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38480. /**
  38481. * Gets camera class name
  38482. * @returns StereoscopicFreeCamera
  38483. */
  38484. getClassName(): string;
  38485. }
  38486. }
  38487. declare module BABYLON {
  38488. /**
  38489. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38490. * @see http://doc.babylonjs.com/features/cameras
  38491. */
  38492. export class StereoscopicGamepadCamera extends GamepadCamera {
  38493. /**
  38494. * Creates a new StereoscopicGamepadCamera
  38495. * @param name defines camera name
  38496. * @param position defines initial position
  38497. * @param interaxialDistance defines distance between each color axis
  38498. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38499. * @param scene defines the hosting scene
  38500. */
  38501. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38502. /**
  38503. * Gets camera class name
  38504. * @returns StereoscopicGamepadCamera
  38505. */
  38506. getClassName(): string;
  38507. }
  38508. }
  38509. declare module BABYLON {
  38510. /**
  38511. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38512. * @see http://doc.babylonjs.com/features/cameras
  38513. */
  38514. export class StereoscopicUniversalCamera extends UniversalCamera {
  38515. /**
  38516. * Creates a new StereoscopicUniversalCamera
  38517. * @param name defines camera name
  38518. * @param position defines initial position
  38519. * @param interaxialDistance defines distance between each color axis
  38520. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38521. * @param scene defines the hosting scene
  38522. */
  38523. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38524. /**
  38525. * Gets camera class name
  38526. * @returns StereoscopicUniversalCamera
  38527. */
  38528. getClassName(): string;
  38529. }
  38530. }
  38531. declare module BABYLON {
  38532. /**
  38533. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38534. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38535. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38536. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38537. */
  38538. export class VirtualJoysticksCamera extends FreeCamera {
  38539. /**
  38540. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38541. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38542. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38543. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38544. * @param name Define the name of the camera in the scene
  38545. * @param position Define the start position of the camera in the scene
  38546. * @param scene Define the scene the camera belongs to
  38547. */
  38548. constructor(name: string, position: Vector3, scene: Scene);
  38549. /**
  38550. * Gets the current object class name.
  38551. * @return the class name
  38552. */
  38553. getClassName(): string;
  38554. }
  38555. }
  38556. declare module BABYLON {
  38557. /**
  38558. * This represents all the required metrics to create a VR camera.
  38559. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38560. */
  38561. export class VRCameraMetrics {
  38562. /**
  38563. * Define the horizontal resolution off the screen.
  38564. */
  38565. hResolution: number;
  38566. /**
  38567. * Define the vertical resolution off the screen.
  38568. */
  38569. vResolution: number;
  38570. /**
  38571. * Define the horizontal screen size.
  38572. */
  38573. hScreenSize: number;
  38574. /**
  38575. * Define the vertical screen size.
  38576. */
  38577. vScreenSize: number;
  38578. /**
  38579. * Define the vertical screen center position.
  38580. */
  38581. vScreenCenter: number;
  38582. /**
  38583. * Define the distance of the eyes to the screen.
  38584. */
  38585. eyeToScreenDistance: number;
  38586. /**
  38587. * Define the distance between both lenses
  38588. */
  38589. lensSeparationDistance: number;
  38590. /**
  38591. * Define the distance between both viewer's eyes.
  38592. */
  38593. interpupillaryDistance: number;
  38594. /**
  38595. * Define the distortion factor of the VR postprocess.
  38596. * Please, touch with care.
  38597. */
  38598. distortionK: number[];
  38599. /**
  38600. * Define the chromatic aberration correction factors for the VR post process.
  38601. */
  38602. chromaAbCorrection: number[];
  38603. /**
  38604. * Define the scale factor of the post process.
  38605. * The smaller the better but the slower.
  38606. */
  38607. postProcessScaleFactor: number;
  38608. /**
  38609. * Define an offset for the lens center.
  38610. */
  38611. lensCenterOffset: number;
  38612. /**
  38613. * Define if the current vr camera should compensate the distortion of the lense or not.
  38614. */
  38615. compensateDistortion: boolean;
  38616. /**
  38617. * Defines if multiview should be enabled when rendering (Default: false)
  38618. */
  38619. multiviewEnabled: boolean;
  38620. /**
  38621. * Gets the rendering aspect ratio based on the provided resolutions.
  38622. */
  38623. readonly aspectRatio: number;
  38624. /**
  38625. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38626. */
  38627. readonly aspectRatioFov: number;
  38628. /**
  38629. * @hidden
  38630. */
  38631. readonly leftHMatrix: Matrix;
  38632. /**
  38633. * @hidden
  38634. */
  38635. readonly rightHMatrix: Matrix;
  38636. /**
  38637. * @hidden
  38638. */
  38639. readonly leftPreViewMatrix: Matrix;
  38640. /**
  38641. * @hidden
  38642. */
  38643. readonly rightPreViewMatrix: Matrix;
  38644. /**
  38645. * Get the default VRMetrics based on the most generic setup.
  38646. * @returns the default vr metrics
  38647. */
  38648. static GetDefault(): VRCameraMetrics;
  38649. }
  38650. }
  38651. declare module BABYLON {
  38652. /** @hidden */
  38653. export var vrDistortionCorrectionPixelShader: {
  38654. name: string;
  38655. shader: string;
  38656. };
  38657. }
  38658. declare module BABYLON {
  38659. /**
  38660. * VRDistortionCorrectionPostProcess used for mobile VR
  38661. */
  38662. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38663. private _isRightEye;
  38664. private _distortionFactors;
  38665. private _postProcessScaleFactor;
  38666. private _lensCenterOffset;
  38667. private _scaleIn;
  38668. private _scaleFactor;
  38669. private _lensCenter;
  38670. /**
  38671. * Initializes the VRDistortionCorrectionPostProcess
  38672. * @param name The name of the effect.
  38673. * @param camera The camera to apply the render pass to.
  38674. * @param isRightEye If this is for the right eye distortion
  38675. * @param vrMetrics All the required metrics for the VR camera
  38676. */
  38677. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38678. }
  38679. }
  38680. declare module BABYLON {
  38681. /**
  38682. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38683. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38684. */
  38685. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38686. /**
  38687. * Creates a new VRDeviceOrientationArcRotateCamera
  38688. * @param name defines camera name
  38689. * @param alpha defines the camera rotation along the logitudinal axis
  38690. * @param beta defines the camera rotation along the latitudinal axis
  38691. * @param radius defines the camera distance from its target
  38692. * @param target defines the camera target
  38693. * @param scene defines the scene the camera belongs to
  38694. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38695. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38696. */
  38697. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38698. /**
  38699. * Gets camera class name
  38700. * @returns VRDeviceOrientationArcRotateCamera
  38701. */
  38702. getClassName(): string;
  38703. }
  38704. }
  38705. declare module BABYLON {
  38706. /**
  38707. * Camera used to simulate VR rendering (based on FreeCamera)
  38708. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38709. */
  38710. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38711. /**
  38712. * Creates a new VRDeviceOrientationFreeCamera
  38713. * @param name defines camera name
  38714. * @param position defines the start position of the camera
  38715. * @param scene defines the scene the camera belongs to
  38716. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38717. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38718. */
  38719. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38720. /**
  38721. * Gets camera class name
  38722. * @returns VRDeviceOrientationFreeCamera
  38723. */
  38724. getClassName(): string;
  38725. }
  38726. }
  38727. declare module BABYLON {
  38728. /**
  38729. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  38730. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38731. */
  38732. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  38733. /**
  38734. * Creates a new VRDeviceOrientationGamepadCamera
  38735. * @param name defines camera name
  38736. * @param position defines the start position of the camera
  38737. * @param scene defines the scene the camera belongs to
  38738. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38739. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38740. */
  38741. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38742. /**
  38743. * Gets camera class name
  38744. * @returns VRDeviceOrientationGamepadCamera
  38745. */
  38746. getClassName(): string;
  38747. }
  38748. }
  38749. declare module BABYLON {
  38750. /**
  38751. * Base class of materials working in push mode in babylon JS
  38752. * @hidden
  38753. */
  38754. export class PushMaterial extends Material {
  38755. protected _activeEffect: Effect;
  38756. protected _normalMatrix: Matrix;
  38757. /**
  38758. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  38759. * This means that the material can keep using a previous shader while a new one is being compiled.
  38760. * This is mostly used when shader parallel compilation is supported (true by default)
  38761. */
  38762. allowShaderHotSwapping: boolean;
  38763. constructor(name: string, scene: Scene);
  38764. getEffect(): Effect;
  38765. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  38766. /**
  38767. * Binds the given world matrix to the active effect
  38768. *
  38769. * @param world the matrix to bind
  38770. */
  38771. bindOnlyWorldMatrix(world: Matrix): void;
  38772. /**
  38773. * Binds the given normal matrix to the active effect
  38774. *
  38775. * @param normalMatrix the matrix to bind
  38776. */
  38777. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  38778. bind(world: Matrix, mesh?: Mesh): void;
  38779. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  38780. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  38781. }
  38782. }
  38783. declare module BABYLON {
  38784. /**
  38785. * This groups all the flags used to control the materials channel.
  38786. */
  38787. export class MaterialFlags {
  38788. private static _DiffuseTextureEnabled;
  38789. /**
  38790. * Are diffuse textures enabled in the application.
  38791. */
  38792. static DiffuseTextureEnabled: boolean;
  38793. private static _AmbientTextureEnabled;
  38794. /**
  38795. * Are ambient textures enabled in the application.
  38796. */
  38797. static AmbientTextureEnabled: boolean;
  38798. private static _OpacityTextureEnabled;
  38799. /**
  38800. * Are opacity textures enabled in the application.
  38801. */
  38802. static OpacityTextureEnabled: boolean;
  38803. private static _ReflectionTextureEnabled;
  38804. /**
  38805. * Are reflection textures enabled in the application.
  38806. */
  38807. static ReflectionTextureEnabled: boolean;
  38808. private static _EmissiveTextureEnabled;
  38809. /**
  38810. * Are emissive textures enabled in the application.
  38811. */
  38812. static EmissiveTextureEnabled: boolean;
  38813. private static _SpecularTextureEnabled;
  38814. /**
  38815. * Are specular textures enabled in the application.
  38816. */
  38817. static SpecularTextureEnabled: boolean;
  38818. private static _BumpTextureEnabled;
  38819. /**
  38820. * Are bump textures enabled in the application.
  38821. */
  38822. static BumpTextureEnabled: boolean;
  38823. private static _LightmapTextureEnabled;
  38824. /**
  38825. * Are lightmap textures enabled in the application.
  38826. */
  38827. static LightmapTextureEnabled: boolean;
  38828. private static _RefractionTextureEnabled;
  38829. /**
  38830. * Are refraction textures enabled in the application.
  38831. */
  38832. static RefractionTextureEnabled: boolean;
  38833. private static _ColorGradingTextureEnabled;
  38834. /**
  38835. * Are color grading textures enabled in the application.
  38836. */
  38837. static ColorGradingTextureEnabled: boolean;
  38838. private static _FresnelEnabled;
  38839. /**
  38840. * Are fresnels enabled in the application.
  38841. */
  38842. static FresnelEnabled: boolean;
  38843. private static _ClearCoatTextureEnabled;
  38844. /**
  38845. * Are clear coat textures enabled in the application.
  38846. */
  38847. static ClearCoatTextureEnabled: boolean;
  38848. private static _ClearCoatBumpTextureEnabled;
  38849. /**
  38850. * Are clear coat bump textures enabled in the application.
  38851. */
  38852. static ClearCoatBumpTextureEnabled: boolean;
  38853. private static _ClearCoatTintTextureEnabled;
  38854. /**
  38855. * Are clear coat tint textures enabled in the application.
  38856. */
  38857. static ClearCoatTintTextureEnabled: boolean;
  38858. private static _SheenTextureEnabled;
  38859. /**
  38860. * Are sheen textures enabled in the application.
  38861. */
  38862. static SheenTextureEnabled: boolean;
  38863. private static _AnisotropicTextureEnabled;
  38864. /**
  38865. * Are anisotropic textures enabled in the application.
  38866. */
  38867. static AnisotropicTextureEnabled: boolean;
  38868. private static _ThicknessTextureEnabled;
  38869. /**
  38870. * Are thickness textures enabled in the application.
  38871. */
  38872. static ThicknessTextureEnabled: boolean;
  38873. }
  38874. }
  38875. declare module BABYLON {
  38876. /** @hidden */
  38877. export var defaultFragmentDeclaration: {
  38878. name: string;
  38879. shader: string;
  38880. };
  38881. }
  38882. declare module BABYLON {
  38883. /** @hidden */
  38884. export var defaultUboDeclaration: {
  38885. name: string;
  38886. shader: string;
  38887. };
  38888. }
  38889. declare module BABYLON {
  38890. /** @hidden */
  38891. export var lightFragmentDeclaration: {
  38892. name: string;
  38893. shader: string;
  38894. };
  38895. }
  38896. declare module BABYLON {
  38897. /** @hidden */
  38898. export var lightUboDeclaration: {
  38899. name: string;
  38900. shader: string;
  38901. };
  38902. }
  38903. declare module BABYLON {
  38904. /** @hidden */
  38905. export var lightsFragmentFunctions: {
  38906. name: string;
  38907. shader: string;
  38908. };
  38909. }
  38910. declare module BABYLON {
  38911. /** @hidden */
  38912. export var shadowsFragmentFunctions: {
  38913. name: string;
  38914. shader: string;
  38915. };
  38916. }
  38917. declare module BABYLON {
  38918. /** @hidden */
  38919. export var fresnelFunction: {
  38920. name: string;
  38921. shader: string;
  38922. };
  38923. }
  38924. declare module BABYLON {
  38925. /** @hidden */
  38926. export var reflectionFunction: {
  38927. name: string;
  38928. shader: string;
  38929. };
  38930. }
  38931. declare module BABYLON {
  38932. /** @hidden */
  38933. export var bumpFragmentFunctions: {
  38934. name: string;
  38935. shader: string;
  38936. };
  38937. }
  38938. declare module BABYLON {
  38939. /** @hidden */
  38940. export var logDepthDeclaration: {
  38941. name: string;
  38942. shader: string;
  38943. };
  38944. }
  38945. declare module BABYLON {
  38946. /** @hidden */
  38947. export var bumpFragment: {
  38948. name: string;
  38949. shader: string;
  38950. };
  38951. }
  38952. declare module BABYLON {
  38953. /** @hidden */
  38954. export var depthPrePass: {
  38955. name: string;
  38956. shader: string;
  38957. };
  38958. }
  38959. declare module BABYLON {
  38960. /** @hidden */
  38961. export var lightFragment: {
  38962. name: string;
  38963. shader: string;
  38964. };
  38965. }
  38966. declare module BABYLON {
  38967. /** @hidden */
  38968. export var logDepthFragment: {
  38969. name: string;
  38970. shader: string;
  38971. };
  38972. }
  38973. declare module BABYLON {
  38974. /** @hidden */
  38975. export var defaultPixelShader: {
  38976. name: string;
  38977. shader: string;
  38978. };
  38979. }
  38980. declare module BABYLON {
  38981. /** @hidden */
  38982. export var defaultVertexDeclaration: {
  38983. name: string;
  38984. shader: string;
  38985. };
  38986. }
  38987. declare module BABYLON {
  38988. /** @hidden */
  38989. export var bumpVertexDeclaration: {
  38990. name: string;
  38991. shader: string;
  38992. };
  38993. }
  38994. declare module BABYLON {
  38995. /** @hidden */
  38996. export var bumpVertex: {
  38997. name: string;
  38998. shader: string;
  38999. };
  39000. }
  39001. declare module BABYLON {
  39002. /** @hidden */
  39003. export var fogVertex: {
  39004. name: string;
  39005. shader: string;
  39006. };
  39007. }
  39008. declare module BABYLON {
  39009. /** @hidden */
  39010. export var shadowsVertex: {
  39011. name: string;
  39012. shader: string;
  39013. };
  39014. }
  39015. declare module BABYLON {
  39016. /** @hidden */
  39017. export var pointCloudVertex: {
  39018. name: string;
  39019. shader: string;
  39020. };
  39021. }
  39022. declare module BABYLON {
  39023. /** @hidden */
  39024. export var logDepthVertex: {
  39025. name: string;
  39026. shader: string;
  39027. };
  39028. }
  39029. declare module BABYLON {
  39030. /** @hidden */
  39031. export var defaultVertexShader: {
  39032. name: string;
  39033. shader: string;
  39034. };
  39035. }
  39036. declare module BABYLON {
  39037. /** @hidden */
  39038. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39039. MAINUV1: boolean;
  39040. MAINUV2: boolean;
  39041. DIFFUSE: boolean;
  39042. DIFFUSEDIRECTUV: number;
  39043. AMBIENT: boolean;
  39044. AMBIENTDIRECTUV: number;
  39045. OPACITY: boolean;
  39046. OPACITYDIRECTUV: number;
  39047. OPACITYRGB: boolean;
  39048. REFLECTION: boolean;
  39049. EMISSIVE: boolean;
  39050. EMISSIVEDIRECTUV: number;
  39051. SPECULAR: boolean;
  39052. SPECULARDIRECTUV: number;
  39053. BUMP: boolean;
  39054. BUMPDIRECTUV: number;
  39055. PARALLAX: boolean;
  39056. PARALLAXOCCLUSION: boolean;
  39057. SPECULAROVERALPHA: boolean;
  39058. CLIPPLANE: boolean;
  39059. CLIPPLANE2: boolean;
  39060. CLIPPLANE3: boolean;
  39061. CLIPPLANE4: boolean;
  39062. ALPHATEST: boolean;
  39063. DEPTHPREPASS: boolean;
  39064. ALPHAFROMDIFFUSE: boolean;
  39065. POINTSIZE: boolean;
  39066. FOG: boolean;
  39067. SPECULARTERM: boolean;
  39068. DIFFUSEFRESNEL: boolean;
  39069. OPACITYFRESNEL: boolean;
  39070. REFLECTIONFRESNEL: boolean;
  39071. REFRACTIONFRESNEL: boolean;
  39072. EMISSIVEFRESNEL: boolean;
  39073. FRESNEL: boolean;
  39074. NORMAL: boolean;
  39075. UV1: boolean;
  39076. UV2: boolean;
  39077. VERTEXCOLOR: boolean;
  39078. VERTEXALPHA: boolean;
  39079. NUM_BONE_INFLUENCERS: number;
  39080. BonesPerMesh: number;
  39081. BONETEXTURE: boolean;
  39082. INSTANCES: boolean;
  39083. GLOSSINESS: boolean;
  39084. ROUGHNESS: boolean;
  39085. EMISSIVEASILLUMINATION: boolean;
  39086. LINKEMISSIVEWITHDIFFUSE: boolean;
  39087. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39088. LIGHTMAP: boolean;
  39089. LIGHTMAPDIRECTUV: number;
  39090. OBJECTSPACE_NORMALMAP: boolean;
  39091. USELIGHTMAPASSHADOWMAP: boolean;
  39092. REFLECTIONMAP_3D: boolean;
  39093. REFLECTIONMAP_SPHERICAL: boolean;
  39094. REFLECTIONMAP_PLANAR: boolean;
  39095. REFLECTIONMAP_CUBIC: boolean;
  39096. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39097. REFLECTIONMAP_PROJECTION: boolean;
  39098. REFLECTIONMAP_SKYBOX: boolean;
  39099. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39100. REFLECTIONMAP_EXPLICIT: boolean;
  39101. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39102. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39103. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39104. INVERTCUBICMAP: boolean;
  39105. LOGARITHMICDEPTH: boolean;
  39106. REFRACTION: boolean;
  39107. REFRACTIONMAP_3D: boolean;
  39108. REFLECTIONOVERALPHA: boolean;
  39109. TWOSIDEDLIGHTING: boolean;
  39110. SHADOWFLOAT: boolean;
  39111. MORPHTARGETS: boolean;
  39112. MORPHTARGETS_NORMAL: boolean;
  39113. MORPHTARGETS_TANGENT: boolean;
  39114. MORPHTARGETS_UV: boolean;
  39115. NUM_MORPH_INFLUENCERS: number;
  39116. NONUNIFORMSCALING: boolean;
  39117. PREMULTIPLYALPHA: boolean;
  39118. IMAGEPROCESSING: boolean;
  39119. VIGNETTE: boolean;
  39120. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39121. VIGNETTEBLENDMODEOPAQUE: boolean;
  39122. TONEMAPPING: boolean;
  39123. TONEMAPPING_ACES: boolean;
  39124. CONTRAST: boolean;
  39125. COLORCURVES: boolean;
  39126. COLORGRADING: boolean;
  39127. COLORGRADING3D: boolean;
  39128. SAMPLER3DGREENDEPTH: boolean;
  39129. SAMPLER3DBGRMAP: boolean;
  39130. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39131. MULTIVIEW: boolean;
  39132. /**
  39133. * If the reflection texture on this material is in linear color space
  39134. * @hidden
  39135. */
  39136. IS_REFLECTION_LINEAR: boolean;
  39137. /**
  39138. * If the refraction texture on this material is in linear color space
  39139. * @hidden
  39140. */
  39141. IS_REFRACTION_LINEAR: boolean;
  39142. EXPOSURE: boolean;
  39143. constructor();
  39144. setReflectionMode(modeToEnable: string): void;
  39145. }
  39146. /**
  39147. * This is the default material used in Babylon. It is the best trade off between quality
  39148. * and performances.
  39149. * @see http://doc.babylonjs.com/babylon101/materials
  39150. */
  39151. export class StandardMaterial extends PushMaterial {
  39152. private _diffuseTexture;
  39153. /**
  39154. * The basic texture of the material as viewed under a light.
  39155. */
  39156. diffuseTexture: Nullable<BaseTexture>;
  39157. private _ambientTexture;
  39158. /**
  39159. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39160. */
  39161. ambientTexture: Nullable<BaseTexture>;
  39162. private _opacityTexture;
  39163. /**
  39164. * Define the transparency of the material from a texture.
  39165. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39166. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39167. */
  39168. opacityTexture: Nullable<BaseTexture>;
  39169. private _reflectionTexture;
  39170. /**
  39171. * Define the texture used to display the reflection.
  39172. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39173. */
  39174. reflectionTexture: Nullable<BaseTexture>;
  39175. private _emissiveTexture;
  39176. /**
  39177. * Define texture of the material as if self lit.
  39178. * This will be mixed in the final result even in the absence of light.
  39179. */
  39180. emissiveTexture: Nullable<BaseTexture>;
  39181. private _specularTexture;
  39182. /**
  39183. * Define how the color and intensity of the highlight given by the light in the material.
  39184. */
  39185. specularTexture: Nullable<BaseTexture>;
  39186. private _bumpTexture;
  39187. /**
  39188. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39189. * 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.
  39190. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39191. */
  39192. bumpTexture: Nullable<BaseTexture>;
  39193. private _lightmapTexture;
  39194. /**
  39195. * Complex lighting can be computationally expensive to compute at runtime.
  39196. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39197. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39198. */
  39199. lightmapTexture: Nullable<BaseTexture>;
  39200. private _refractionTexture;
  39201. /**
  39202. * Define the texture used to display the refraction.
  39203. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39204. */
  39205. refractionTexture: Nullable<BaseTexture>;
  39206. /**
  39207. * The color of the material lit by the environmental background lighting.
  39208. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39209. */
  39210. ambientColor: Color3;
  39211. /**
  39212. * The basic color of the material as viewed under a light.
  39213. */
  39214. diffuseColor: Color3;
  39215. /**
  39216. * Define how the color and intensity of the highlight given by the light in the material.
  39217. */
  39218. specularColor: Color3;
  39219. /**
  39220. * Define the color of the material as if self lit.
  39221. * This will be mixed in the final result even in the absence of light.
  39222. */
  39223. emissiveColor: Color3;
  39224. /**
  39225. * Defines how sharp are the highlights in the material.
  39226. * The bigger the value the sharper giving a more glossy feeling to the result.
  39227. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39228. */
  39229. specularPower: number;
  39230. private _useAlphaFromDiffuseTexture;
  39231. /**
  39232. * Does the transparency come from the diffuse texture alpha channel.
  39233. */
  39234. useAlphaFromDiffuseTexture: boolean;
  39235. private _useEmissiveAsIllumination;
  39236. /**
  39237. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39238. */
  39239. useEmissiveAsIllumination: boolean;
  39240. private _linkEmissiveWithDiffuse;
  39241. /**
  39242. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39243. * the emissive level when the final color is close to one.
  39244. */
  39245. linkEmissiveWithDiffuse: boolean;
  39246. private _useSpecularOverAlpha;
  39247. /**
  39248. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39249. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39250. */
  39251. useSpecularOverAlpha: boolean;
  39252. private _useReflectionOverAlpha;
  39253. /**
  39254. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39255. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39256. */
  39257. useReflectionOverAlpha: boolean;
  39258. private _disableLighting;
  39259. /**
  39260. * Does lights from the scene impacts this material.
  39261. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39262. */
  39263. disableLighting: boolean;
  39264. private _useObjectSpaceNormalMap;
  39265. /**
  39266. * Allows using an object space normal map (instead of tangent space).
  39267. */
  39268. useObjectSpaceNormalMap: boolean;
  39269. private _useParallax;
  39270. /**
  39271. * Is parallax enabled or not.
  39272. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39273. */
  39274. useParallax: boolean;
  39275. private _useParallaxOcclusion;
  39276. /**
  39277. * Is parallax occlusion enabled or not.
  39278. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39279. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39280. */
  39281. useParallaxOcclusion: boolean;
  39282. /**
  39283. * 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.
  39284. */
  39285. parallaxScaleBias: number;
  39286. private _roughness;
  39287. /**
  39288. * Helps to define how blurry the reflections should appears in the material.
  39289. */
  39290. roughness: number;
  39291. /**
  39292. * In case of refraction, define the value of the index of refraction.
  39293. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39294. */
  39295. indexOfRefraction: number;
  39296. /**
  39297. * Invert the refraction texture alongside the y axis.
  39298. * It can be useful with procedural textures or probe for instance.
  39299. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39300. */
  39301. invertRefractionY: boolean;
  39302. /**
  39303. * Defines the alpha limits in alpha test mode.
  39304. */
  39305. alphaCutOff: number;
  39306. private _useLightmapAsShadowmap;
  39307. /**
  39308. * In case of light mapping, define whether the map contains light or shadow informations.
  39309. */
  39310. useLightmapAsShadowmap: boolean;
  39311. private _diffuseFresnelParameters;
  39312. /**
  39313. * Define the diffuse fresnel parameters of the material.
  39314. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39315. */
  39316. diffuseFresnelParameters: FresnelParameters;
  39317. private _opacityFresnelParameters;
  39318. /**
  39319. * Define the opacity fresnel parameters of the material.
  39320. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39321. */
  39322. opacityFresnelParameters: FresnelParameters;
  39323. private _reflectionFresnelParameters;
  39324. /**
  39325. * Define the reflection fresnel parameters of the material.
  39326. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39327. */
  39328. reflectionFresnelParameters: FresnelParameters;
  39329. private _refractionFresnelParameters;
  39330. /**
  39331. * Define the refraction fresnel parameters of the material.
  39332. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39333. */
  39334. refractionFresnelParameters: FresnelParameters;
  39335. private _emissiveFresnelParameters;
  39336. /**
  39337. * Define the emissive fresnel parameters of the material.
  39338. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39339. */
  39340. emissiveFresnelParameters: FresnelParameters;
  39341. private _useReflectionFresnelFromSpecular;
  39342. /**
  39343. * If true automatically deducts the fresnels values from the material specularity.
  39344. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39345. */
  39346. useReflectionFresnelFromSpecular: boolean;
  39347. private _useGlossinessFromSpecularMapAlpha;
  39348. /**
  39349. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39350. */
  39351. useGlossinessFromSpecularMapAlpha: boolean;
  39352. private _maxSimultaneousLights;
  39353. /**
  39354. * Defines the maximum number of lights that can be used in the material
  39355. */
  39356. maxSimultaneousLights: number;
  39357. private _invertNormalMapX;
  39358. /**
  39359. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39360. */
  39361. invertNormalMapX: boolean;
  39362. private _invertNormalMapY;
  39363. /**
  39364. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39365. */
  39366. invertNormalMapY: boolean;
  39367. private _twoSidedLighting;
  39368. /**
  39369. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39370. */
  39371. twoSidedLighting: boolean;
  39372. /**
  39373. * Default configuration related to image processing available in the standard Material.
  39374. */
  39375. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39376. /**
  39377. * Gets the image processing configuration used either in this material.
  39378. */
  39379. /**
  39380. * Sets the Default image processing configuration used either in the this material.
  39381. *
  39382. * If sets to null, the scene one is in use.
  39383. */
  39384. imageProcessingConfiguration: ImageProcessingConfiguration;
  39385. /**
  39386. * Keep track of the image processing observer to allow dispose and replace.
  39387. */
  39388. private _imageProcessingObserver;
  39389. /**
  39390. * Attaches a new image processing configuration to the Standard Material.
  39391. * @param configuration
  39392. */
  39393. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39394. /**
  39395. * Gets wether the color curves effect is enabled.
  39396. */
  39397. /**
  39398. * Sets wether the color curves effect is enabled.
  39399. */
  39400. cameraColorCurvesEnabled: boolean;
  39401. /**
  39402. * Gets wether the color grading effect is enabled.
  39403. */
  39404. /**
  39405. * Gets wether the color grading effect is enabled.
  39406. */
  39407. cameraColorGradingEnabled: boolean;
  39408. /**
  39409. * Gets wether tonemapping is enabled or not.
  39410. */
  39411. /**
  39412. * Sets wether tonemapping is enabled or not
  39413. */
  39414. cameraToneMappingEnabled: boolean;
  39415. /**
  39416. * The camera exposure used on this material.
  39417. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39418. * This corresponds to a photographic exposure.
  39419. */
  39420. /**
  39421. * The camera exposure used on this material.
  39422. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  39423. * This corresponds to a photographic exposure.
  39424. */
  39425. cameraExposure: number;
  39426. /**
  39427. * Gets The camera contrast used on this material.
  39428. */
  39429. /**
  39430. * Sets The camera contrast used on this material.
  39431. */
  39432. cameraContrast: number;
  39433. /**
  39434. * Gets the Color Grading 2D Lookup Texture.
  39435. */
  39436. /**
  39437. * Sets the Color Grading 2D Lookup Texture.
  39438. */
  39439. cameraColorGradingTexture: Nullable<BaseTexture>;
  39440. /**
  39441. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39442. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39443. * 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;
  39444. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39445. */
  39446. /**
  39447. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  39448. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  39449. * 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;
  39450. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  39451. */
  39452. cameraColorCurves: Nullable<ColorCurves>;
  39453. /**
  39454. * Custom callback helping to override the default shader used in the material.
  39455. */
  39456. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  39457. protected _renderTargets: SmartArray<RenderTargetTexture>;
  39458. protected _worldViewProjectionMatrix: Matrix;
  39459. protected _globalAmbientColor: Color3;
  39460. protected _useLogarithmicDepth: boolean;
  39461. /**
  39462. * Instantiates a new standard material.
  39463. * This is the default material used in Babylon. It is the best trade off between quality
  39464. * and performances.
  39465. * @see http://doc.babylonjs.com/babylon101/materials
  39466. * @param name Define the name of the material in the scene
  39467. * @param scene Define the scene the material belong to
  39468. */
  39469. constructor(name: string, scene: Scene);
  39470. /**
  39471. * Gets a boolean indicating that current material needs to register RTT
  39472. */
  39473. readonly hasRenderTargetTextures: boolean;
  39474. /**
  39475. * Gets the current class name of the material e.g. "StandardMaterial"
  39476. * Mainly use in serialization.
  39477. * @returns the class name
  39478. */
  39479. getClassName(): string;
  39480. /**
  39481. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  39482. * You can try switching to logarithmic depth.
  39483. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  39484. */
  39485. useLogarithmicDepth: boolean;
  39486. /**
  39487. * Specifies if the material will require alpha blending
  39488. * @returns a boolean specifying if alpha blending is needed
  39489. */
  39490. needAlphaBlending(): boolean;
  39491. /**
  39492. * Specifies if this material should be rendered in alpha test mode
  39493. * @returns a boolean specifying if an alpha test is needed.
  39494. */
  39495. needAlphaTesting(): boolean;
  39496. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  39497. /**
  39498. * Get the texture used for alpha test purpose.
  39499. * @returns the diffuse texture in case of the standard material.
  39500. */
  39501. getAlphaTestTexture(): Nullable<BaseTexture>;
  39502. /**
  39503. * Get if the submesh is ready to be used and all its information available.
  39504. * Child classes can use it to update shaders
  39505. * @param mesh defines the mesh to check
  39506. * @param subMesh defines which submesh to check
  39507. * @param useInstances specifies that instances should be used
  39508. * @returns a boolean indicating that the submesh is ready or not
  39509. */
  39510. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  39511. /**
  39512. * Builds the material UBO layouts.
  39513. * Used internally during the effect preparation.
  39514. */
  39515. buildUniformLayout(): void;
  39516. /**
  39517. * Unbinds the material from the mesh
  39518. */
  39519. unbind(): void;
  39520. /**
  39521. * Binds the submesh to this material by preparing the effect and shader to draw
  39522. * @param world defines the world transformation matrix
  39523. * @param mesh defines the mesh containing the submesh
  39524. * @param subMesh defines the submesh to bind the material to
  39525. */
  39526. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  39527. /**
  39528. * Get the list of animatables in the material.
  39529. * @returns the list of animatables object used in the material
  39530. */
  39531. getAnimatables(): IAnimatable[];
  39532. /**
  39533. * Gets the active textures from the material
  39534. * @returns an array of textures
  39535. */
  39536. getActiveTextures(): BaseTexture[];
  39537. /**
  39538. * Specifies if the material uses a texture
  39539. * @param texture defines the texture to check against the material
  39540. * @returns a boolean specifying if the material uses the texture
  39541. */
  39542. hasTexture(texture: BaseTexture): boolean;
  39543. /**
  39544. * Disposes the material
  39545. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  39546. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  39547. */
  39548. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  39549. /**
  39550. * Makes a duplicate of the material, and gives it a new name
  39551. * @param name defines the new name for the duplicated material
  39552. * @returns the cloned material
  39553. */
  39554. clone(name: string): StandardMaterial;
  39555. /**
  39556. * Serializes this material in a JSON representation
  39557. * @returns the serialized material object
  39558. */
  39559. serialize(): any;
  39560. /**
  39561. * Creates a standard material from parsed material data
  39562. * @param source defines the JSON representation of the material
  39563. * @param scene defines the hosting scene
  39564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  39565. * @returns a new standard material
  39566. */
  39567. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  39568. /**
  39569. * Are diffuse textures enabled in the application.
  39570. */
  39571. static DiffuseTextureEnabled: boolean;
  39572. /**
  39573. * Are ambient textures enabled in the application.
  39574. */
  39575. static AmbientTextureEnabled: boolean;
  39576. /**
  39577. * Are opacity textures enabled in the application.
  39578. */
  39579. static OpacityTextureEnabled: boolean;
  39580. /**
  39581. * Are reflection textures enabled in the application.
  39582. */
  39583. static ReflectionTextureEnabled: boolean;
  39584. /**
  39585. * Are emissive textures enabled in the application.
  39586. */
  39587. static EmissiveTextureEnabled: boolean;
  39588. /**
  39589. * Are specular textures enabled in the application.
  39590. */
  39591. static SpecularTextureEnabled: boolean;
  39592. /**
  39593. * Are bump textures enabled in the application.
  39594. */
  39595. static BumpTextureEnabled: boolean;
  39596. /**
  39597. * Are lightmap textures enabled in the application.
  39598. */
  39599. static LightmapTextureEnabled: boolean;
  39600. /**
  39601. * Are refraction textures enabled in the application.
  39602. */
  39603. static RefractionTextureEnabled: boolean;
  39604. /**
  39605. * Are color grading textures enabled in the application.
  39606. */
  39607. static ColorGradingTextureEnabled: boolean;
  39608. /**
  39609. * Are fresnels enabled in the application.
  39610. */
  39611. static FresnelEnabled: boolean;
  39612. }
  39613. }
  39614. declare module BABYLON {
  39615. /**
  39616. * A class extending Texture allowing drawing on a texture
  39617. * @see http://doc.babylonjs.com/how_to/dynamictexture
  39618. */
  39619. export class DynamicTexture extends Texture {
  39620. private _generateMipMaps;
  39621. private _canvas;
  39622. private _context;
  39623. private _engine;
  39624. /**
  39625. * Creates a DynamicTexture
  39626. * @param name defines the name of the texture
  39627. * @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
  39628. * @param scene defines the scene where you want the texture
  39629. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  39630. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  39631. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  39632. */
  39633. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  39634. /**
  39635. * Get the current class name of the texture useful for serialization or dynamic coding.
  39636. * @returns "DynamicTexture"
  39637. */
  39638. getClassName(): string;
  39639. /**
  39640. * Gets the current state of canRescale
  39641. */
  39642. readonly canRescale: boolean;
  39643. private _recreate;
  39644. /**
  39645. * Scales the texture
  39646. * @param ratio the scale factor to apply to both width and height
  39647. */
  39648. scale(ratio: number): void;
  39649. /**
  39650. * Resizes the texture
  39651. * @param width the new width
  39652. * @param height the new height
  39653. */
  39654. scaleTo(width: number, height: number): void;
  39655. /**
  39656. * Gets the context of the canvas used by the texture
  39657. * @returns the canvas context of the dynamic texture
  39658. */
  39659. getContext(): CanvasRenderingContext2D;
  39660. /**
  39661. * Clears the texture
  39662. */
  39663. clear(): void;
  39664. /**
  39665. * Updates the texture
  39666. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39667. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  39668. */
  39669. update(invertY?: boolean, premulAlpha?: boolean): void;
  39670. /**
  39671. * Draws text onto the texture
  39672. * @param text defines the text to be drawn
  39673. * @param x defines the placement of the text from the left
  39674. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  39675. * @param font defines the font to be used with font-style, font-size, font-name
  39676. * @param color defines the color used for the text
  39677. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  39678. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  39679. * @param update defines whether texture is immediately update (default is true)
  39680. */
  39681. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  39682. /**
  39683. * Clones the texture
  39684. * @returns the clone of the texture.
  39685. */
  39686. clone(): DynamicTexture;
  39687. /**
  39688. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  39689. * @returns a serialized dynamic texture object
  39690. */
  39691. serialize(): any;
  39692. /** @hidden */ private _rebuild(): void;
  39693. }
  39694. }
  39695. declare module BABYLON {
  39696. /** @hidden */
  39697. export var imageProcessingPixelShader: {
  39698. name: string;
  39699. shader: string;
  39700. };
  39701. }
  39702. declare module BABYLON {
  39703. /**
  39704. * ImageProcessingPostProcess
  39705. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  39706. */
  39707. export class ImageProcessingPostProcess extends PostProcess {
  39708. /**
  39709. * Default configuration related to image processing available in the PBR Material.
  39710. */
  39711. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39712. /**
  39713. * Gets the image processing configuration used either in this material.
  39714. */
  39715. /**
  39716. * Sets the Default image processing configuration used either in the this material.
  39717. *
  39718. * If sets to null, the scene one is in use.
  39719. */
  39720. imageProcessingConfiguration: ImageProcessingConfiguration;
  39721. /**
  39722. * Keep track of the image processing observer to allow dispose and replace.
  39723. */
  39724. private _imageProcessingObserver;
  39725. /**
  39726. * Attaches a new image processing configuration to the PBR Material.
  39727. * @param configuration
  39728. */
  39729. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  39730. /**
  39731. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39732. */
  39733. /**
  39734. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  39735. */
  39736. colorCurves: Nullable<ColorCurves>;
  39737. /**
  39738. * Gets wether the color curves effect is enabled.
  39739. */
  39740. /**
  39741. * Sets wether the color curves effect is enabled.
  39742. */
  39743. colorCurvesEnabled: boolean;
  39744. /**
  39745. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39746. */
  39747. /**
  39748. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  39749. */
  39750. colorGradingTexture: Nullable<BaseTexture>;
  39751. /**
  39752. * Gets wether the color grading effect is enabled.
  39753. */
  39754. /**
  39755. * Gets wether the color grading effect is enabled.
  39756. */
  39757. colorGradingEnabled: boolean;
  39758. /**
  39759. * Gets exposure used in the effect.
  39760. */
  39761. /**
  39762. * Sets exposure used in the effect.
  39763. */
  39764. exposure: number;
  39765. /**
  39766. * Gets wether tonemapping is enabled or not.
  39767. */
  39768. /**
  39769. * Sets wether tonemapping is enabled or not
  39770. */
  39771. toneMappingEnabled: boolean;
  39772. /**
  39773. * Gets the type of tone mapping effect.
  39774. */
  39775. /**
  39776. * Sets the type of tone mapping effect.
  39777. */
  39778. toneMappingType: number;
  39779. /**
  39780. * Gets contrast used in the effect.
  39781. */
  39782. /**
  39783. * Sets contrast used in the effect.
  39784. */
  39785. contrast: number;
  39786. /**
  39787. * Gets Vignette stretch size.
  39788. */
  39789. /**
  39790. * Sets Vignette stretch size.
  39791. */
  39792. vignetteStretch: number;
  39793. /**
  39794. * Gets Vignette centre X Offset.
  39795. */
  39796. /**
  39797. * Sets Vignette centre X Offset.
  39798. */
  39799. vignetteCentreX: number;
  39800. /**
  39801. * Gets Vignette centre Y Offset.
  39802. */
  39803. /**
  39804. * Sets Vignette centre Y Offset.
  39805. */
  39806. vignetteCentreY: number;
  39807. /**
  39808. * Gets Vignette weight or intensity of the vignette effect.
  39809. */
  39810. /**
  39811. * Sets Vignette weight or intensity of the vignette effect.
  39812. */
  39813. vignetteWeight: number;
  39814. /**
  39815. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39816. * if vignetteEnabled is set to true.
  39817. */
  39818. /**
  39819. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  39820. * if vignetteEnabled is set to true.
  39821. */
  39822. vignetteColor: Color4;
  39823. /**
  39824. * Gets Camera field of view used by the Vignette effect.
  39825. */
  39826. /**
  39827. * Sets Camera field of view used by the Vignette effect.
  39828. */
  39829. vignetteCameraFov: number;
  39830. /**
  39831. * Gets the vignette blend mode allowing different kind of effect.
  39832. */
  39833. /**
  39834. * Sets the vignette blend mode allowing different kind of effect.
  39835. */
  39836. vignetteBlendMode: number;
  39837. /**
  39838. * Gets wether the vignette effect is enabled.
  39839. */
  39840. /**
  39841. * Sets wether the vignette effect is enabled.
  39842. */
  39843. vignetteEnabled: boolean;
  39844. private _fromLinearSpace;
  39845. /**
  39846. * Gets wether the input of the processing is in Gamma or Linear Space.
  39847. */
  39848. /**
  39849. * Sets wether the input of the processing is in Gamma or Linear Space.
  39850. */
  39851. fromLinearSpace: boolean;
  39852. /**
  39853. * Defines cache preventing GC.
  39854. */
  39855. private _defines;
  39856. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  39857. /**
  39858. * "ImageProcessingPostProcess"
  39859. * @returns "ImageProcessingPostProcess"
  39860. */
  39861. getClassName(): string;
  39862. protected _updateParameters(): void;
  39863. dispose(camera?: Camera): void;
  39864. }
  39865. }
  39866. declare module BABYLON {
  39867. /**
  39868. * Class containing static functions to help procedurally build meshes
  39869. */
  39870. export class GroundBuilder {
  39871. /**
  39872. * Creates a ground mesh
  39873. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  39874. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  39875. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  39876. * @param name defines the name of the mesh
  39877. * @param options defines the options used to create the mesh
  39878. * @param scene defines the hosting scene
  39879. * @returns the ground mesh
  39880. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  39881. */
  39882. static CreateGround(name: string, options: {
  39883. width?: number;
  39884. height?: number;
  39885. subdivisions?: number;
  39886. subdivisionsX?: number;
  39887. subdivisionsY?: number;
  39888. updatable?: boolean;
  39889. }, scene: any): Mesh;
  39890. /**
  39891. * Creates a tiled ground mesh
  39892. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  39893. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  39894. * * 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
  39895. * * 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
  39896. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39897. * @param name defines the name of the mesh
  39898. * @param options defines the options used to create the mesh
  39899. * @param scene defines the hosting scene
  39900. * @returns the tiled ground mesh
  39901. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  39902. */
  39903. static CreateTiledGround(name: string, options: {
  39904. xmin: number;
  39905. zmin: number;
  39906. xmax: number;
  39907. zmax: number;
  39908. subdivisions?: {
  39909. w: number;
  39910. h: number;
  39911. };
  39912. precision?: {
  39913. w: number;
  39914. h: number;
  39915. };
  39916. updatable?: boolean;
  39917. }, scene?: Nullable<Scene>): Mesh;
  39918. /**
  39919. * Creates a ground mesh from a height map
  39920. * * The parameter `url` sets the URL of the height map image resource.
  39921. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  39922. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  39923. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  39924. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  39925. * * 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.
  39926. * * 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).
  39927. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  39928. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39929. * @param name defines the name of the mesh
  39930. * @param url defines the url to the height map
  39931. * @param options defines the options used to create the mesh
  39932. * @param scene defines the hosting scene
  39933. * @returns the ground mesh
  39934. * @see https://doc.babylonjs.com/babylon101/height_map
  39935. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  39936. */
  39937. static CreateGroundFromHeightMap(name: string, url: string, options: {
  39938. width?: number;
  39939. height?: number;
  39940. subdivisions?: number;
  39941. minHeight?: number;
  39942. maxHeight?: number;
  39943. colorFilter?: Color3;
  39944. alphaFilter?: number;
  39945. updatable?: boolean;
  39946. onReady?: (mesh: GroundMesh) => void;
  39947. }, scene?: Nullable<Scene>): GroundMesh;
  39948. }
  39949. }
  39950. declare module BABYLON {
  39951. /**
  39952. * Class containing static functions to help procedurally build meshes
  39953. */
  39954. export class TorusBuilder {
  39955. /**
  39956. * Creates a torus mesh
  39957. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  39958. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  39959. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  39960. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  39961. * * 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
  39962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  39963. * @param name defines the name of the mesh
  39964. * @param options defines the options used to create the mesh
  39965. * @param scene defines the hosting scene
  39966. * @returns the torus mesh
  39967. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  39968. */
  39969. static CreateTorus(name: string, options: {
  39970. diameter?: number;
  39971. thickness?: number;
  39972. tessellation?: number;
  39973. updatable?: boolean;
  39974. sideOrientation?: number;
  39975. frontUVs?: Vector4;
  39976. backUVs?: Vector4;
  39977. }, scene: any): Mesh;
  39978. }
  39979. }
  39980. declare module BABYLON {
  39981. /**
  39982. * Class containing static functions to help procedurally build meshes
  39983. */
  39984. export class CylinderBuilder {
  39985. /**
  39986. * Creates a cylinder or a cone mesh
  39987. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  39988. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  39989. * * 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.
  39990. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  39991. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  39992. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  39993. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  39994. * * 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).
  39995. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  39996. * * 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).
  39997. * * 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
  39998. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  39999. * * 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
  40000. * * 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.
  40001. * * If `enclose` is false, a ring surface is one element.
  40002. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40003. * * 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
  40004. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40005. * * 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
  40006. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40007. * @param name defines the name of the mesh
  40008. * @param options defines the options used to create the mesh
  40009. * @param scene defines the hosting scene
  40010. * @returns the cylinder mesh
  40011. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40012. */
  40013. static CreateCylinder(name: string, options: {
  40014. height?: number;
  40015. diameterTop?: number;
  40016. diameterBottom?: number;
  40017. diameter?: number;
  40018. tessellation?: number;
  40019. subdivisions?: number;
  40020. arc?: number;
  40021. faceColors?: Color4[];
  40022. faceUV?: Vector4[];
  40023. updatable?: boolean;
  40024. hasRings?: boolean;
  40025. enclose?: boolean;
  40026. cap?: number;
  40027. sideOrientation?: number;
  40028. frontUVs?: Vector4;
  40029. backUVs?: Vector4;
  40030. }, scene: any): Mesh;
  40031. }
  40032. }
  40033. declare module BABYLON {
  40034. /**
  40035. * Options to modify the vr teleportation behavior.
  40036. */
  40037. export interface VRTeleportationOptions {
  40038. /**
  40039. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40040. */
  40041. floorMeshName?: string;
  40042. /**
  40043. * A list of meshes to be used as the teleportation floor. (default: empty)
  40044. */
  40045. floorMeshes?: Mesh[];
  40046. }
  40047. /**
  40048. * Options to modify the vr experience helper's behavior.
  40049. */
  40050. export interface VRExperienceHelperOptions extends WebVROptions {
  40051. /**
  40052. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40053. */
  40054. createDeviceOrientationCamera?: boolean;
  40055. /**
  40056. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40057. */
  40058. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40059. /**
  40060. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40061. */
  40062. laserToggle?: boolean;
  40063. /**
  40064. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40065. */
  40066. floorMeshes?: Mesh[];
  40067. /**
  40068. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40069. */
  40070. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40071. }
  40072. /**
  40073. * Event containing information after VR has been entered
  40074. */
  40075. export class OnAfterEnteringVRObservableEvent {
  40076. /**
  40077. * If entering vr was successful
  40078. */
  40079. success: boolean;
  40080. }
  40081. /**
  40082. * Helps to quickly add VR support to an existing scene.
  40083. * See http://doc.babylonjs.com/how_to/webvr_helper
  40084. */
  40085. export class VRExperienceHelper {
  40086. /** Options to modify the vr experience helper's behavior. */
  40087. webVROptions: VRExperienceHelperOptions;
  40088. private _scene;
  40089. private _position;
  40090. private _btnVR;
  40091. private _btnVRDisplayed;
  40092. private _webVRsupported;
  40093. private _webVRready;
  40094. private _webVRrequesting;
  40095. private _webVRpresenting;
  40096. private _hasEnteredVR;
  40097. private _fullscreenVRpresenting;
  40098. private _canvas;
  40099. private _webVRCamera;
  40100. private _vrDeviceOrientationCamera;
  40101. private _deviceOrientationCamera;
  40102. private _existingCamera;
  40103. private _onKeyDown;
  40104. private _onVrDisplayPresentChange;
  40105. private _onVRDisplayChanged;
  40106. private _onVRRequestPresentStart;
  40107. private _onVRRequestPresentComplete;
  40108. /**
  40109. * 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)
  40110. */
  40111. enableGazeEvenWhenNoPointerLock: boolean;
  40112. /**
  40113. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  40114. */
  40115. exitVROnDoubleTap: boolean;
  40116. /**
  40117. * Observable raised right before entering VR.
  40118. */
  40119. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40120. /**
  40121. * Observable raised when entering VR has completed.
  40122. */
  40123. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40124. /**
  40125. * Observable raised when exiting VR.
  40126. */
  40127. onExitingVRObservable: Observable<VRExperienceHelper>;
  40128. /**
  40129. * Observable raised when controller mesh is loaded.
  40130. */
  40131. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40132. /** Return this.onEnteringVRObservable
  40133. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40134. */
  40135. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40136. /** Return this.onExitingVRObservable
  40137. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40138. */
  40139. readonly onExitingVR: Observable<VRExperienceHelper>;
  40140. /** Return this.onControllerMeshLoadedObservable
  40141. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40142. */
  40143. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40144. private _rayLength;
  40145. private _useCustomVRButton;
  40146. private _teleportationRequested;
  40147. private _teleportActive;
  40148. private _floorMeshName;
  40149. private _floorMeshesCollection;
  40150. private _rotationAllowed;
  40151. private _teleportBackwardsVector;
  40152. private _teleportationTarget;
  40153. private _isDefaultTeleportationTarget;
  40154. private _postProcessMove;
  40155. private _teleportationFillColor;
  40156. private _teleportationBorderColor;
  40157. private _rotationAngle;
  40158. private _haloCenter;
  40159. private _cameraGazer;
  40160. private _padSensibilityUp;
  40161. private _padSensibilityDown;
  40162. private _leftController;
  40163. private _rightController;
  40164. /**
  40165. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40166. */
  40167. onNewMeshSelected: Observable<AbstractMesh>;
  40168. /**
  40169. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40170. */
  40171. onNewMeshPicked: Observable<PickingInfo>;
  40172. private _circleEase;
  40173. /**
  40174. * Observable raised before camera teleportation
  40175. */
  40176. onBeforeCameraTeleport: Observable<Vector3>;
  40177. /**
  40178. * Observable raised after camera teleportation
  40179. */
  40180. onAfterCameraTeleport: Observable<Vector3>;
  40181. /**
  40182. * Observable raised when current selected mesh gets unselected
  40183. */
  40184. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40185. private _raySelectionPredicate;
  40186. /**
  40187. * To be optionaly changed by user to define custom ray selection
  40188. */
  40189. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40190. /**
  40191. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40192. */
  40193. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40194. /**
  40195. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40196. */
  40197. teleportationEnabled: boolean;
  40198. private _defaultHeight;
  40199. private _teleportationInitialized;
  40200. private _interactionsEnabled;
  40201. private _interactionsRequested;
  40202. private _displayGaze;
  40203. private _displayLaserPointer;
  40204. /**
  40205. * The mesh used to display where the user is going to teleport.
  40206. */
  40207. /**
  40208. * Sets the mesh to be used to display where the user is going to teleport.
  40209. */
  40210. teleportationTarget: Mesh;
  40211. /**
  40212. * 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
  40213. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40214. * See http://doc.babylonjs.com/resources/baking_transformations
  40215. */
  40216. gazeTrackerMesh: Mesh;
  40217. /**
  40218. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40219. */
  40220. updateGazeTrackerScale: boolean;
  40221. /**
  40222. * If the gaze trackers color should be updated when selecting meshes
  40223. */
  40224. updateGazeTrackerColor: boolean;
  40225. /**
  40226. * The gaze tracking mesh corresponding to the left controller
  40227. */
  40228. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40229. /**
  40230. * The gaze tracking mesh corresponding to the right controller
  40231. */
  40232. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40233. /**
  40234. * If the ray of the gaze should be displayed.
  40235. */
  40236. /**
  40237. * Sets if the ray of the gaze should be displayed.
  40238. */
  40239. displayGaze: boolean;
  40240. /**
  40241. * If the ray of the LaserPointer should be displayed.
  40242. */
  40243. /**
  40244. * Sets if the ray of the LaserPointer should be displayed.
  40245. */
  40246. displayLaserPointer: boolean;
  40247. /**
  40248. * The deviceOrientationCamera used as the camera when not in VR.
  40249. */
  40250. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40251. /**
  40252. * Based on the current WebVR support, returns the current VR camera used.
  40253. */
  40254. readonly currentVRCamera: Nullable<Camera>;
  40255. /**
  40256. * The webVRCamera which is used when in VR.
  40257. */
  40258. readonly webVRCamera: WebVRFreeCamera;
  40259. /**
  40260. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  40261. */
  40262. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  40263. /**
  40264. * The html button that is used to trigger entering into VR.
  40265. */
  40266. readonly vrButton: Nullable<HTMLButtonElement>;
  40267. private readonly _teleportationRequestInitiated;
  40268. /**
  40269. * Defines wether or not Pointer lock should be requested when switching to
  40270. * full screen.
  40271. */
  40272. requestPointerLockOnFullScreen: boolean;
  40273. /**
  40274. * Instantiates a VRExperienceHelper.
  40275. * Helps to quickly add VR support to an existing scene.
  40276. * @param scene The scene the VRExperienceHelper belongs to.
  40277. * @param webVROptions Options to modify the vr experience helper's behavior.
  40278. */
  40279. constructor(scene: Scene,
  40280. /** Options to modify the vr experience helper's behavior. */
  40281. webVROptions?: VRExperienceHelperOptions);
  40282. private _onDefaultMeshLoaded;
  40283. private _onResize;
  40284. private _onFullscreenChange;
  40285. /**
  40286. * Gets a value indicating if we are currently in VR mode.
  40287. */
  40288. readonly isInVRMode: boolean;
  40289. private onVrDisplayPresentChange;
  40290. private onVRDisplayChanged;
  40291. private moveButtonToBottomRight;
  40292. private displayVRButton;
  40293. private updateButtonVisibility;
  40294. private _cachedAngularSensibility;
  40295. /**
  40296. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  40297. * Otherwise, will use the fullscreen API.
  40298. */
  40299. enterVR(): void;
  40300. /**
  40301. * Attempt to exit VR, or fullscreen.
  40302. */
  40303. exitVR(): void;
  40304. /**
  40305. * The position of the vr experience helper.
  40306. */
  40307. /**
  40308. * Sets the position of the vr experience helper.
  40309. */
  40310. position: Vector3;
  40311. /**
  40312. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  40313. */
  40314. enableInteractions(): void;
  40315. private readonly _noControllerIsActive;
  40316. private beforeRender;
  40317. private _isTeleportationFloor;
  40318. /**
  40319. * Adds a floor mesh to be used for teleportation.
  40320. * @param floorMesh the mesh to be used for teleportation.
  40321. */
  40322. addFloorMesh(floorMesh: Mesh): void;
  40323. /**
  40324. * Removes a floor mesh from being used for teleportation.
  40325. * @param floorMesh the mesh to be removed.
  40326. */
  40327. removeFloorMesh(floorMesh: Mesh): void;
  40328. /**
  40329. * Enables interactions and teleportation using the VR controllers and gaze.
  40330. * @param vrTeleportationOptions options to modify teleportation behavior.
  40331. */
  40332. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  40333. private _onNewGamepadConnected;
  40334. private _tryEnableInteractionOnController;
  40335. private _onNewGamepadDisconnected;
  40336. private _enableInteractionOnController;
  40337. private _checkTeleportWithRay;
  40338. private _checkRotate;
  40339. private _checkTeleportBackwards;
  40340. private _enableTeleportationOnController;
  40341. private _createTeleportationCircles;
  40342. private _displayTeleportationTarget;
  40343. private _hideTeleportationTarget;
  40344. private _rotateCamera;
  40345. private _moveTeleportationSelectorTo;
  40346. private _workingVector;
  40347. private _workingQuaternion;
  40348. private _workingMatrix;
  40349. /**
  40350. * Teleports the users feet to the desired location
  40351. * @param location The location where the user's feet should be placed
  40352. */
  40353. teleportCamera(location: Vector3): void;
  40354. private _convertNormalToDirectionOfRay;
  40355. private _castRayAndSelectObject;
  40356. private _notifySelectedMeshUnselected;
  40357. /**
  40358. * Sets the color of the laser ray from the vr controllers.
  40359. * @param color new color for the ray.
  40360. */
  40361. changeLaserColor(color: Color3): void;
  40362. /**
  40363. * Sets the color of the ray from the vr headsets gaze.
  40364. * @param color new color for the ray.
  40365. */
  40366. changeGazeColor(color: Color3): void;
  40367. /**
  40368. * Exits VR and disposes of the vr experience helper
  40369. */
  40370. dispose(): void;
  40371. /**
  40372. * Gets the name of the VRExperienceHelper class
  40373. * @returns "VRExperienceHelper"
  40374. */
  40375. getClassName(): string;
  40376. }
  40377. }
  40378. declare module BABYLON {
  40379. /**
  40380. * Manages an XRSession to work with Babylon's engine
  40381. * @see https://doc.babylonjs.com/how_to/webxr
  40382. */
  40383. export class WebXRSessionManager implements IDisposable {
  40384. private scene;
  40385. /**
  40386. * Fires every time a new xrFrame arrives which can be used to update the camera
  40387. */
  40388. onXRFrameObservable: Observable<any>;
  40389. /**
  40390. * Fires when the xr session is ended either by the device or manually done
  40391. */
  40392. onXRSessionEnded: Observable<any>;
  40393. /**
  40394. * Underlying xr session
  40395. */
  40396. session: XRSession;
  40397. /**
  40398. * Type of reference space used when creating the session
  40399. */
  40400. referenceSpace: XRReferenceSpace;
  40401. /** @hidden */ private _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  40402. /**
  40403. * Current XR frame
  40404. */
  40405. currentFrame: Nullable<XRFrame>;
  40406. private _xrNavigator;
  40407. private baseLayer;
  40408. /**
  40409. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  40410. * @param scene The scene which the session should be created for
  40411. */
  40412. constructor(scene: Scene);
  40413. /**
  40414. * Initializes the manager
  40415. * After initialization enterXR can be called to start an XR session
  40416. * @returns Promise which resolves after it is initialized
  40417. */
  40418. initializeAsync(): Promise<void>;
  40419. /**
  40420. * Initializes an xr session
  40421. * @param xrSessionMode mode to initialize
  40422. * @returns a promise which will resolve once the session has been initialized
  40423. */
  40424. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  40425. /**
  40426. * Sets the reference space on the xr session
  40427. * @param referenceSpace space to set
  40428. * @returns a promise that will resolve once the reference space has been set
  40429. */
  40430. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  40431. /**
  40432. * Updates the render state of the session
  40433. * @param state state to set
  40434. * @returns a promise that resolves once the render state has been updated
  40435. */
  40436. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  40437. /**
  40438. * Starts rendering to the xr layer
  40439. * @returns a promise that will resolve once rendering has started
  40440. */
  40441. startRenderingToXRAsync(): Promise<void>;
  40442. /**
  40443. * Stops the xrSession and restores the renderloop
  40444. * @returns Promise which resolves after it exits XR
  40445. */
  40446. exitXRAsync(): Promise<unknown>;
  40447. /**
  40448. * Checks if a session would be supported for the creation options specified
  40449. * @param sessionMode session mode to check if supported eg. immersive-vr
  40450. * @returns true if supported
  40451. */
  40452. supportsSessionAsync(sessionMode: XRSessionMode): any;
  40453. /**
  40454. * @hidden
  40455. * Converts the render layer of xrSession to a render target
  40456. * @param session session to create render target for
  40457. * @param scene scene the new render target should be created for
  40458. */ private static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  40459. /**
  40460. * Disposes of the session manager
  40461. */
  40462. dispose(): void;
  40463. }
  40464. }
  40465. declare module BABYLON {
  40466. /**
  40467. * WebXR Camera which holds the views for the xrSession
  40468. * @see https://doc.babylonjs.com/how_to/webxr
  40469. */
  40470. export class WebXRCamera extends FreeCamera {
  40471. private static _TmpMatrix;
  40472. /**
  40473. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  40474. * @param name the name of the camera
  40475. * @param scene the scene to add the camera to
  40476. */
  40477. constructor(name: string, scene: Scene);
  40478. private _updateNumberOfRigCameras;
  40479. /** @hidden */ private _updateForDualEyeDebugging(pupilDistance?: number): void;
  40480. /**
  40481. * Updates the cameras position from the current pose information of the XR session
  40482. * @param xrSessionManager the session containing pose information
  40483. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  40484. */
  40485. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  40486. }
  40487. }
  40488. declare module BABYLON {
  40489. /**
  40490. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  40491. */
  40492. export class WebXRManagedOutputCanvas implements IDisposable {
  40493. private helper;
  40494. private _canvas;
  40495. /**
  40496. * xrpresent context of the canvas which can be used to display/mirror xr content
  40497. */
  40498. canvasContext: WebGLRenderingContext;
  40499. /**
  40500. * xr layer for the canvas
  40501. */
  40502. xrLayer: Nullable<XRWebGLLayer>;
  40503. /**
  40504. * Initializes the xr layer for the session
  40505. * @param xrSession xr session
  40506. * @returns a promise that will resolve once the XR Layer has been created
  40507. */
  40508. initializeXRLayerAsync(xrSession: any): any;
  40509. /**
  40510. * Initializes the canvas to be added/removed upon entering/exiting xr
  40511. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  40512. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  40513. */
  40514. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  40515. /**
  40516. * Disposes of the object
  40517. */
  40518. dispose(): void;
  40519. private _setManagedOutputCanvas;
  40520. private _addCanvas;
  40521. private _removeCanvas;
  40522. }
  40523. }
  40524. declare module BABYLON {
  40525. /**
  40526. * States of the webXR experience
  40527. */
  40528. export enum WebXRState {
  40529. /**
  40530. * Transitioning to being in XR mode
  40531. */
  40532. ENTERING_XR = 0,
  40533. /**
  40534. * Transitioning to non XR mode
  40535. */
  40536. EXITING_XR = 1,
  40537. /**
  40538. * In XR mode and presenting
  40539. */
  40540. IN_XR = 2,
  40541. /**
  40542. * Not entered XR mode
  40543. */
  40544. NOT_IN_XR = 3
  40545. }
  40546. /**
  40547. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  40548. * @see https://doc.babylonjs.com/how_to/webxr
  40549. */
  40550. export class WebXRExperienceHelper implements IDisposable {
  40551. private scene;
  40552. /**
  40553. * 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
  40554. */
  40555. container: AbstractMesh;
  40556. /**
  40557. * Camera used to render xr content
  40558. */
  40559. camera: WebXRCamera;
  40560. /**
  40561. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  40562. */
  40563. state: WebXRState;
  40564. private _setState;
  40565. private static _TmpVector;
  40566. /**
  40567. * Fires when the state of the experience helper has changed
  40568. */
  40569. onStateChangedObservable: Observable<WebXRState>;
  40570. /** Session manager used to keep track of xr session */
  40571. sessionManager: WebXRSessionManager;
  40572. private _nonVRCamera;
  40573. private _originalSceneAutoClear;
  40574. private _supported;
  40575. /**
  40576. * Creates the experience helper
  40577. * @param scene the scene to attach the experience helper to
  40578. * @returns a promise for the experience helper
  40579. */
  40580. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  40581. /**
  40582. * Creates a WebXRExperienceHelper
  40583. * @param scene The scene the helper should be created in
  40584. */
  40585. private constructor();
  40586. /**
  40587. * Exits XR mode and returns the scene to its original state
  40588. * @returns promise that resolves after xr mode has exited
  40589. */
  40590. exitXRAsync(): Promise<unknown>;
  40591. /**
  40592. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  40593. * @param sessionCreationOptions options for the XR session
  40594. * @param referenceSpaceType frame of reference of the XR session
  40595. * @param outputCanvas the output canvas that will be used to enter XR mode
  40596. * @returns promise that resolves after xr mode has entered
  40597. */
  40598. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  40599. /**
  40600. * Updates the global position of the camera by moving the camera's container
  40601. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  40602. * @param position The desired global position of the camera
  40603. */
  40604. setPositionOfCameraUsingContainer(position: Vector3): void;
  40605. /**
  40606. * Rotates the xr camera by rotating the camera's container around the camera's position
  40607. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  40608. * @param rotation the desired quaternion rotation to apply to the camera
  40609. */
  40610. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  40611. /**
  40612. * Disposes of the experience helper
  40613. */
  40614. dispose(): void;
  40615. }
  40616. }
  40617. declare module BABYLON {
  40618. /**
  40619. * Button which can be used to enter a different mode of XR
  40620. */
  40621. export class WebXREnterExitUIButton {
  40622. /** button element */
  40623. element: HTMLElement;
  40624. /** XR initialization options for the button */
  40625. sessionMode: XRSessionMode;
  40626. /** Reference space type */
  40627. referenceSpaceType: XRReferenceSpaceType;
  40628. /**
  40629. * Creates a WebXREnterExitUIButton
  40630. * @param element button element
  40631. * @param sessionMode XR initialization session mode
  40632. * @param referenceSpaceType the type of reference space to be used
  40633. */
  40634. constructor(
  40635. /** button element */
  40636. element: HTMLElement,
  40637. /** XR initialization options for the button */
  40638. sessionMode: XRSessionMode,
  40639. /** Reference space type */
  40640. referenceSpaceType: XRReferenceSpaceType);
  40641. /**
  40642. * Overwritable function which can be used to update the button's visuals when the state changes
  40643. * @param activeButton the current active button in the UI
  40644. */
  40645. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  40646. }
  40647. /**
  40648. * Options to create the webXR UI
  40649. */
  40650. export class WebXREnterExitUIOptions {
  40651. /**
  40652. * Context to enter xr with
  40653. */
  40654. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  40655. /**
  40656. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  40657. */
  40658. customButtons?: Array<WebXREnterExitUIButton>;
  40659. }
  40660. /**
  40661. * UI to allow the user to enter/exit XR mode
  40662. */
  40663. export class WebXREnterExitUI implements IDisposable {
  40664. private scene;
  40665. private _overlay;
  40666. private _buttons;
  40667. private _activeButton;
  40668. /**
  40669. * Fired every time the active button is changed.
  40670. *
  40671. * When xr is entered via a button that launches xr that button will be the callback parameter
  40672. *
  40673. * When exiting xr the callback parameter will be null)
  40674. */
  40675. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  40676. /**
  40677. * Creates UI to allow the user to enter/exit XR mode
  40678. * @param scene the scene to add the ui to
  40679. * @param helper the xr experience helper to enter/exit xr with
  40680. * @param options options to configure the UI
  40681. * @returns the created ui
  40682. */
  40683. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  40684. private constructor();
  40685. private _updateButtons;
  40686. /**
  40687. * Disposes of the object
  40688. */
  40689. dispose(): void;
  40690. }
  40691. }
  40692. declare module BABYLON {
  40693. /**
  40694. * Represents an XR input
  40695. */
  40696. export class WebXRController {
  40697. private scene;
  40698. /** The underlying input source for the controller */
  40699. inputSource: XRInputSource;
  40700. private parentContainer;
  40701. /**
  40702. * 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
  40703. */
  40704. grip?: AbstractMesh;
  40705. /**
  40706. * Pointer which can be used to select objects or attach a visible laser to
  40707. */
  40708. pointer: AbstractMesh;
  40709. /**
  40710. * Event that fires when the controller is removed/disposed
  40711. */
  40712. onDisposeObservable: Observable<{}>;
  40713. private _tmpMatrix;
  40714. private _tmpQuaternion;
  40715. private _tmpVector;
  40716. /**
  40717. * Creates the controller
  40718. * @see https://doc.babylonjs.com/how_to/webxr
  40719. * @param scene the scene which the controller should be associated to
  40720. * @param inputSource the underlying input source for the controller
  40721. * @param parentContainer parent that the controller meshes should be children of
  40722. */
  40723. constructor(scene: Scene,
  40724. /** The underlying input source for the controller */
  40725. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  40726. /**
  40727. * Updates the controller pose based on the given XRFrame
  40728. * @param xrFrame xr frame to update the pose with
  40729. * @param referenceSpace reference space to use
  40730. */
  40731. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  40732. /**
  40733. * Gets a world space ray coming from the controller
  40734. * @param result the resulting ray
  40735. */
  40736. getWorldPointerRayToRef(result: Ray): void;
  40737. /**
  40738. * Disposes of the object
  40739. */
  40740. dispose(): void;
  40741. }
  40742. }
  40743. declare module BABYLON {
  40744. /**
  40745. * XR input used to track XR inputs such as controllers/rays
  40746. */
  40747. export class WebXRInput implements IDisposable {
  40748. /**
  40749. * Base experience the input listens to
  40750. */
  40751. baseExperience: WebXRExperienceHelper;
  40752. /**
  40753. * XR controllers being tracked
  40754. */
  40755. controllers: Array<WebXRController>;
  40756. private _frameObserver;
  40757. private _stateObserver;
  40758. /**
  40759. * Event when a controller has been connected/added
  40760. */
  40761. onControllerAddedObservable: Observable<WebXRController>;
  40762. /**
  40763. * Event when a controller has been removed/disconnected
  40764. */
  40765. onControllerRemovedObservable: Observable<WebXRController>;
  40766. /**
  40767. * Initializes the WebXRInput
  40768. * @param baseExperience experience helper which the input should be created for
  40769. */
  40770. constructor(
  40771. /**
  40772. * Base experience the input listens to
  40773. */
  40774. baseExperience: WebXRExperienceHelper);
  40775. private _onInputSourcesChange;
  40776. private _addAndRemoveControllers;
  40777. /**
  40778. * Disposes of the object
  40779. */
  40780. dispose(): void;
  40781. }
  40782. }
  40783. declare module BABYLON {
  40784. /**
  40785. * Enables teleportation
  40786. */
  40787. export class WebXRControllerTeleportation {
  40788. private _teleportationFillColor;
  40789. private _teleportationBorderColor;
  40790. private _tmpRay;
  40791. private _tmpVector;
  40792. /**
  40793. * Creates a WebXRControllerTeleportation
  40794. * @param input input manager to add teleportation to
  40795. * @param floorMeshes floormeshes which can be teleported to
  40796. */
  40797. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  40798. }
  40799. }
  40800. declare module BABYLON {
  40801. /**
  40802. * Handles pointer input automatically for the pointer of XR controllers
  40803. */
  40804. export class WebXRControllerPointerSelection {
  40805. private static _idCounter;
  40806. private _tmpRay;
  40807. /**
  40808. * Creates a WebXRControllerPointerSelection
  40809. * @param input input manager to setup pointer selection
  40810. */
  40811. constructor(input: WebXRInput);
  40812. private _convertNormalToDirectionOfRay;
  40813. private _updatePointerDistance;
  40814. }
  40815. }
  40816. declare module BABYLON {
  40817. /**
  40818. * Class used to represent data loading progression
  40819. */
  40820. export class SceneLoaderProgressEvent {
  40821. /** defines if data length to load can be evaluated */
  40822. readonly lengthComputable: boolean;
  40823. /** defines the loaded data length */
  40824. readonly loaded: number;
  40825. /** defines the data length to load */
  40826. readonly total: number;
  40827. /**
  40828. * Create a new progress event
  40829. * @param lengthComputable defines if data length to load can be evaluated
  40830. * @param loaded defines the loaded data length
  40831. * @param total defines the data length to load
  40832. */
  40833. constructor(
  40834. /** defines if data length to load can be evaluated */
  40835. lengthComputable: boolean,
  40836. /** defines the loaded data length */
  40837. loaded: number,
  40838. /** defines the data length to load */
  40839. total: number);
  40840. /**
  40841. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  40842. * @param event defines the source event
  40843. * @returns a new SceneLoaderProgressEvent
  40844. */
  40845. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  40846. }
  40847. /**
  40848. * Interface used by SceneLoader plugins to define supported file extensions
  40849. */
  40850. export interface ISceneLoaderPluginExtensions {
  40851. /**
  40852. * Defines the list of supported extensions
  40853. */
  40854. [extension: string]: {
  40855. isBinary: boolean;
  40856. };
  40857. }
  40858. /**
  40859. * Interface used by SceneLoader plugin factory
  40860. */
  40861. export interface ISceneLoaderPluginFactory {
  40862. /**
  40863. * Defines the name of the factory
  40864. */
  40865. name: string;
  40866. /**
  40867. * Function called to create a new plugin
  40868. * @return the new plugin
  40869. */
  40870. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  40871. /**
  40872. * Boolean indicating if the plugin can direct load specific data
  40873. */
  40874. canDirectLoad?: (data: string) => boolean;
  40875. }
  40876. /**
  40877. * Interface used to define a SceneLoader plugin
  40878. */
  40879. export interface ISceneLoaderPlugin {
  40880. /**
  40881. * The friendly name of this plugin.
  40882. */
  40883. name: string;
  40884. /**
  40885. * The file extensions supported by this plugin.
  40886. */
  40887. extensions: string | ISceneLoaderPluginExtensions;
  40888. /**
  40889. * Import meshes into a scene.
  40890. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40891. * @param scene The scene to import into
  40892. * @param data The data to import
  40893. * @param rootUrl The root url for scene and resources
  40894. * @param meshes The meshes array to import into
  40895. * @param particleSystems The particle systems array to import into
  40896. * @param skeletons The skeletons array to import into
  40897. * @param onError The callback when import fails
  40898. * @returns True if successful or false otherwise
  40899. */
  40900. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  40901. /**
  40902. * Load into a scene.
  40903. * @param scene The scene to load into
  40904. * @param data The data to import
  40905. * @param rootUrl The root url for scene and resources
  40906. * @param onError The callback when import fails
  40907. * @returns true if successful or false otherwise
  40908. */
  40909. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  40910. /**
  40911. * The callback that returns true if the data can be directly loaded.
  40912. */
  40913. canDirectLoad?: (data: string) => boolean;
  40914. /**
  40915. * The callback that allows custom handling of the root url based on the response url.
  40916. */
  40917. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40918. /**
  40919. * Load into an asset container.
  40920. * @param scene The scene to load into
  40921. * @param data The data to import
  40922. * @param rootUrl The root url for scene and resources
  40923. * @param onError The callback when import fails
  40924. * @returns The loaded asset container
  40925. */
  40926. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  40927. }
  40928. /**
  40929. * Interface used to define an async SceneLoader plugin
  40930. */
  40931. export interface ISceneLoaderPluginAsync {
  40932. /**
  40933. * The friendly name of this plugin.
  40934. */
  40935. name: string;
  40936. /**
  40937. * The file extensions supported by this plugin.
  40938. */
  40939. extensions: string | ISceneLoaderPluginExtensions;
  40940. /**
  40941. * Import meshes into a scene.
  40942. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  40943. * @param scene The scene to import into
  40944. * @param data The data to import
  40945. * @param rootUrl The root url for scene and resources
  40946. * @param onProgress The callback when the load progresses
  40947. * @param fileName Defines the name of the file to load
  40948. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  40949. */
  40950. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  40951. meshes: AbstractMesh[];
  40952. particleSystems: IParticleSystem[];
  40953. skeletons: Skeleton[];
  40954. animationGroups: AnimationGroup[];
  40955. }>;
  40956. /**
  40957. * Load into a scene.
  40958. * @param scene The scene to load into
  40959. * @param data The data to import
  40960. * @param rootUrl The root url for scene and resources
  40961. * @param onProgress The callback when the load progresses
  40962. * @param fileName Defines the name of the file to load
  40963. * @returns Nothing
  40964. */
  40965. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  40966. /**
  40967. * The callback that returns true if the data can be directly loaded.
  40968. */
  40969. canDirectLoad?: (data: string) => boolean;
  40970. /**
  40971. * The callback that allows custom handling of the root url based on the response url.
  40972. */
  40973. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  40974. /**
  40975. * Load into an asset container.
  40976. * @param scene The scene to load into
  40977. * @param data The data to import
  40978. * @param rootUrl The root url for scene and resources
  40979. * @param onProgress The callback when the load progresses
  40980. * @param fileName Defines the name of the file to load
  40981. * @returns The loaded asset container
  40982. */
  40983. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  40984. }
  40985. /**
  40986. * Class used to load scene from various file formats using registered plugins
  40987. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  40988. */
  40989. export class SceneLoader {
  40990. /**
  40991. * No logging while loading
  40992. */
  40993. static readonly NO_LOGGING: number;
  40994. /**
  40995. * Minimal logging while loading
  40996. */
  40997. static readonly MINIMAL_LOGGING: number;
  40998. /**
  40999. * Summary logging while loading
  41000. */
  41001. static readonly SUMMARY_LOGGING: number;
  41002. /**
  41003. * Detailled logging while loading
  41004. */
  41005. static readonly DETAILED_LOGGING: number;
  41006. /**
  41007. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  41008. */
  41009. static ForceFullSceneLoadingForIncremental: boolean;
  41010. /**
  41011. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  41012. */
  41013. static ShowLoadingScreen: boolean;
  41014. /**
  41015. * Defines the current logging level (while loading the scene)
  41016. * @ignorenaming
  41017. */
  41018. static loggingLevel: number;
  41019. /**
  41020. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  41021. */
  41022. static CleanBoneMatrixWeights: boolean;
  41023. /**
  41024. * Event raised when a plugin is used to load a scene
  41025. */
  41026. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  41027. private static _registeredPlugins;
  41028. private static _getDefaultPlugin;
  41029. private static _getPluginForExtension;
  41030. private static _getPluginForDirectLoad;
  41031. private static _getPluginForFilename;
  41032. private static _getDirectLoad;
  41033. private static _loadData;
  41034. private static _getFileInfo;
  41035. /**
  41036. * Gets a plugin that can load the given extension
  41037. * @param extension defines the extension to load
  41038. * @returns a plugin or null if none works
  41039. */
  41040. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  41041. /**
  41042. * Gets a boolean indicating that the given extension can be loaded
  41043. * @param extension defines the extension to load
  41044. * @returns true if the extension is supported
  41045. */
  41046. static IsPluginForExtensionAvailable(extension: string): boolean;
  41047. /**
  41048. * Adds a new plugin to the list of registered plugins
  41049. * @param plugin defines the plugin to add
  41050. */
  41051. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  41052. /**
  41053. * Import meshes into a scene
  41054. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41055. * @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)
  41056. * @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)
  41057. * @param scene the instance of BABYLON.Scene to append to
  41058. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  41059. * @param onProgress a callback with a progress event for each file being loaded
  41060. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41061. * @param pluginExtension the extension used to determine the plugin
  41062. * @returns The loaded plugin
  41063. */
  41064. 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>;
  41065. /**
  41066. * Import meshes into a scene
  41067. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  41068. * @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)
  41069. * @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)
  41070. * @param scene the instance of BABYLON.Scene to append to
  41071. * @param onProgress a callback with a progress event for each file being loaded
  41072. * @param pluginExtension the extension used to determine the plugin
  41073. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  41074. */
  41075. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  41076. meshes: AbstractMesh[];
  41077. particleSystems: IParticleSystem[];
  41078. skeletons: Skeleton[];
  41079. animationGroups: AnimationGroup[];
  41080. }>;
  41081. /**
  41082. * Load a scene
  41083. * @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)
  41084. * @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)
  41085. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41086. * @param onSuccess a callback with the scene when import succeeds
  41087. * @param onProgress a callback with a progress event for each file being loaded
  41088. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41089. * @param pluginExtension the extension used to determine the plugin
  41090. * @returns The loaded plugin
  41091. */
  41092. 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>;
  41093. /**
  41094. * Load a scene
  41095. * @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)
  41096. * @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)
  41097. * @param engine is the instance of BABYLON.Engine to use to create the scene
  41098. * @param onProgress a callback with a progress event for each file being loaded
  41099. * @param pluginExtension the extension used to determine the plugin
  41100. * @returns The loaded scene
  41101. */
  41102. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41103. /**
  41104. * Append a scene
  41105. * @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)
  41106. * @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)
  41107. * @param scene is the instance of BABYLON.Scene to append to
  41108. * @param onSuccess a callback with the scene when import succeeds
  41109. * @param onProgress a callback with a progress event for each file being loaded
  41110. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41111. * @param pluginExtension the extension used to determine the plugin
  41112. * @returns The loaded plugin
  41113. */
  41114. 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>;
  41115. /**
  41116. * Append a scene
  41117. * @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)
  41118. * @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)
  41119. * @param scene is the instance of BABYLON.Scene to append to
  41120. * @param onProgress a callback with a progress event for each file being loaded
  41121. * @param pluginExtension the extension used to determine the plugin
  41122. * @returns The given scene
  41123. */
  41124. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  41125. /**
  41126. * Load a scene into an asset container
  41127. * @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)
  41128. * @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)
  41129. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  41130. * @param onSuccess a callback with the scene when import succeeds
  41131. * @param onProgress a callback with a progress event for each file being loaded
  41132. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  41133. * @param pluginExtension the extension used to determine the plugin
  41134. * @returns The loaded plugin
  41135. */
  41136. 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>;
  41137. /**
  41138. * Load a scene into an asset container
  41139. * @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)
  41140. * @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)
  41141. * @param scene is the instance of Scene to append to
  41142. * @param onProgress a callback with a progress event for each file being loaded
  41143. * @param pluginExtension the extension used to determine the plugin
  41144. * @returns The loaded asset container
  41145. */
  41146. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  41147. }
  41148. }
  41149. declare module BABYLON {
  41150. /**
  41151. * Generic Controller
  41152. */
  41153. export class GenericController extends WebVRController {
  41154. /**
  41155. * Base Url for the controller model.
  41156. */
  41157. static readonly MODEL_BASE_URL: string;
  41158. /**
  41159. * File name for the controller model.
  41160. */
  41161. static readonly MODEL_FILENAME: string;
  41162. /**
  41163. * Creates a new GenericController from a gamepad
  41164. * @param vrGamepad the gamepad that the controller should be created from
  41165. */
  41166. constructor(vrGamepad: any);
  41167. /**
  41168. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41169. * @param scene scene in which to add meshes
  41170. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41171. */
  41172. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41173. /**
  41174. * Called once for each button that changed state since the last frame
  41175. * @param buttonIdx Which button index changed
  41176. * @param state New state of the button
  41177. * @param changes Which properties on the state changed since last frame
  41178. */
  41179. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41180. }
  41181. }
  41182. declare module BABYLON {
  41183. /**
  41184. * Defines the WindowsMotionController object that the state of the windows motion controller
  41185. */
  41186. export class WindowsMotionController extends WebVRController {
  41187. /**
  41188. * The base url used to load the left and right controller models
  41189. */
  41190. static MODEL_BASE_URL: string;
  41191. /**
  41192. * The name of the left controller model file
  41193. */
  41194. static MODEL_LEFT_FILENAME: string;
  41195. /**
  41196. * The name of the right controller model file
  41197. */
  41198. static MODEL_RIGHT_FILENAME: string;
  41199. /**
  41200. * The controller name prefix for this controller type
  41201. */
  41202. static readonly GAMEPAD_ID_PREFIX: string;
  41203. /**
  41204. * The controller id pattern for this controller type
  41205. */
  41206. private static readonly GAMEPAD_ID_PATTERN;
  41207. private _loadedMeshInfo;
  41208. private readonly _mapping;
  41209. /**
  41210. * Fired when the trackpad on this controller is clicked
  41211. */
  41212. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  41213. /**
  41214. * Fired when the trackpad on this controller is modified
  41215. */
  41216. onTrackpadValuesChangedObservable: Observable<StickValues>;
  41217. /**
  41218. * The current x and y values of this controller's trackpad
  41219. */
  41220. trackpad: StickValues;
  41221. /**
  41222. * Creates a new WindowsMotionController from a gamepad
  41223. * @param vrGamepad the gamepad that the controller should be created from
  41224. */
  41225. constructor(vrGamepad: any);
  41226. /**
  41227. * Fired when the trigger on this controller is modified
  41228. */
  41229. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41230. /**
  41231. * Fired when the menu button on this controller is modified
  41232. */
  41233. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41234. /**
  41235. * Fired when the grip button on this controller is modified
  41236. */
  41237. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41238. /**
  41239. * Fired when the thumbstick button on this controller is modified
  41240. */
  41241. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41242. /**
  41243. * Fired when the touchpad button on this controller is modified
  41244. */
  41245. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41246. /**
  41247. * Fired when the touchpad values on this controller are modified
  41248. */
  41249. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  41250. private _updateTrackpad;
  41251. /**
  41252. * Called once per frame by the engine.
  41253. */
  41254. update(): void;
  41255. /**
  41256. * Called once for each button that changed state since the last frame
  41257. * @param buttonIdx Which button index changed
  41258. * @param state New state of the button
  41259. * @param changes Which properties on the state changed since last frame
  41260. */
  41261. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41262. /**
  41263. * Moves the buttons on the controller mesh based on their current state
  41264. * @param buttonName the name of the button to move
  41265. * @param buttonValue the value of the button which determines the buttons new position
  41266. */
  41267. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  41268. /**
  41269. * Moves the axis on the controller mesh based on its current state
  41270. * @param axis the index of the axis
  41271. * @param axisValue the value of the axis which determines the meshes new position
  41272. * @hidden
  41273. */
  41274. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  41275. /**
  41276. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41277. * @param scene scene in which to add meshes
  41278. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41279. */
  41280. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  41281. /**
  41282. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  41283. * can be transformed by button presses and axes values, based on this._mapping.
  41284. *
  41285. * @param scene scene in which the meshes exist
  41286. * @param meshes list of meshes that make up the controller model to process
  41287. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  41288. */
  41289. private processModel;
  41290. private createMeshInfo;
  41291. /**
  41292. * Gets the ray of the controller in the direction the controller is pointing
  41293. * @param length the length the resulting ray should be
  41294. * @returns a ray in the direction the controller is pointing
  41295. */
  41296. getForwardRay(length?: number): Ray;
  41297. /**
  41298. * Disposes of the controller
  41299. */
  41300. dispose(): void;
  41301. }
  41302. }
  41303. declare module BABYLON {
  41304. /**
  41305. * Oculus Touch Controller
  41306. */
  41307. export class OculusTouchController extends WebVRController {
  41308. /**
  41309. * Base Url for the controller model.
  41310. */
  41311. static MODEL_BASE_URL: string;
  41312. /**
  41313. * File name for the left controller model.
  41314. */
  41315. static MODEL_LEFT_FILENAME: string;
  41316. /**
  41317. * File name for the right controller model.
  41318. */
  41319. static MODEL_RIGHT_FILENAME: string;
  41320. /**
  41321. * Base Url for the Quest controller model.
  41322. */
  41323. static QUEST_MODEL_BASE_URL: string;
  41324. /**
  41325. * @hidden
  41326. * If the controllers are running on a device that needs the updated Quest controller models
  41327. */ private static _IsQuest: boolean;
  41328. /**
  41329. * Fired when the secondary trigger on this controller is modified
  41330. */
  41331. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  41332. /**
  41333. * Fired when the thumb rest on this controller is modified
  41334. */
  41335. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  41336. /**
  41337. * Creates a new OculusTouchController from a gamepad
  41338. * @param vrGamepad the gamepad that the controller should be created from
  41339. */
  41340. constructor(vrGamepad: any);
  41341. /**
  41342. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41343. * @param scene scene in which to add meshes
  41344. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41345. */
  41346. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41347. /**
  41348. * Fired when the A button on this controller is modified
  41349. */
  41350. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41351. /**
  41352. * Fired when the B button on this controller is modified
  41353. */
  41354. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41355. /**
  41356. * Fired when the X button on this controller is modified
  41357. */
  41358. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41359. /**
  41360. * Fired when the Y button on this controller is modified
  41361. */
  41362. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41363. /**
  41364. * Called once for each button that changed state since the last frame
  41365. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  41366. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  41367. * 2) secondary trigger (same)
  41368. * 3) A (right) X (left), touch, pressed = value
  41369. * 4) B / Y
  41370. * 5) thumb rest
  41371. * @param buttonIdx Which button index changed
  41372. * @param state New state of the button
  41373. * @param changes Which properties on the state changed since last frame
  41374. */
  41375. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41376. }
  41377. }
  41378. declare module BABYLON {
  41379. /**
  41380. * Vive Controller
  41381. */
  41382. export class ViveController extends WebVRController {
  41383. /**
  41384. * Base Url for the controller model.
  41385. */
  41386. static MODEL_BASE_URL: string;
  41387. /**
  41388. * File name for the controller model.
  41389. */
  41390. static MODEL_FILENAME: string;
  41391. /**
  41392. * Creates a new ViveController from a gamepad
  41393. * @param vrGamepad the gamepad that the controller should be created from
  41394. */
  41395. constructor(vrGamepad: any);
  41396. /**
  41397. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  41398. * @param scene scene in which to add meshes
  41399. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  41400. */
  41401. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  41402. /**
  41403. * Fired when the left button on this controller is modified
  41404. */
  41405. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41406. /**
  41407. * Fired when the right button on this controller is modified
  41408. */
  41409. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41410. /**
  41411. * Fired when the menu button on this controller is modified
  41412. */
  41413. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  41414. /**
  41415. * Called once for each button that changed state since the last frame
  41416. * Vive mapping:
  41417. * 0: touchpad
  41418. * 1: trigger
  41419. * 2: left AND right buttons
  41420. * 3: menu button
  41421. * @param buttonIdx Which button index changed
  41422. * @param state New state of the button
  41423. * @param changes Which properties on the state changed since last frame
  41424. */
  41425. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  41426. }
  41427. }
  41428. declare module BABYLON {
  41429. /**
  41430. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  41431. */
  41432. export class WebXRControllerModelLoader {
  41433. /**
  41434. * Creates the WebXRControllerModelLoader
  41435. * @param input xr input that creates the controllers
  41436. */
  41437. constructor(input: WebXRInput);
  41438. }
  41439. }
  41440. declare module BABYLON {
  41441. /**
  41442. * Contains an array of blocks representing the octree
  41443. */
  41444. export interface IOctreeContainer<T> {
  41445. /**
  41446. * Blocks within the octree
  41447. */
  41448. blocks: Array<OctreeBlock<T>>;
  41449. }
  41450. /**
  41451. * Class used to store a cell in an octree
  41452. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41453. */
  41454. export class OctreeBlock<T> {
  41455. /**
  41456. * Gets the content of the current block
  41457. */
  41458. entries: T[];
  41459. /**
  41460. * Gets the list of block children
  41461. */
  41462. blocks: Array<OctreeBlock<T>>;
  41463. private _depth;
  41464. private _maxDepth;
  41465. private _capacity;
  41466. private _minPoint;
  41467. private _maxPoint;
  41468. private _boundingVectors;
  41469. private _creationFunc;
  41470. /**
  41471. * Creates a new block
  41472. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41473. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41474. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41475. * @param depth defines the current depth of this block in the octree
  41476. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41477. * @param creationFunc defines a callback to call when an element is added to the block
  41478. */
  41479. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41480. /**
  41481. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41482. */
  41483. readonly capacity: number;
  41484. /**
  41485. * Gets the minimum vector (in world space) of the block's bounding box
  41486. */
  41487. readonly minPoint: Vector3;
  41488. /**
  41489. * Gets the maximum vector (in world space) of the block's bounding box
  41490. */
  41491. readonly maxPoint: Vector3;
  41492. /**
  41493. * Add a new element to this block
  41494. * @param entry defines the element to add
  41495. */
  41496. addEntry(entry: T): void;
  41497. /**
  41498. * Remove an element from this block
  41499. * @param entry defines the element to remove
  41500. */
  41501. removeEntry(entry: T): void;
  41502. /**
  41503. * Add an array of elements to this block
  41504. * @param entries defines the array of elements to add
  41505. */
  41506. addEntries(entries: T[]): void;
  41507. /**
  41508. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41509. * @param frustumPlanes defines the frustum planes to test
  41510. * @param selection defines the array to store current content if selection is positive
  41511. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41512. */
  41513. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41514. /**
  41515. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41516. * @param sphereCenter defines the bounding sphere center
  41517. * @param sphereRadius defines the bounding sphere radius
  41518. * @param selection defines the array to store current content if selection is positive
  41519. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41520. */
  41521. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41522. /**
  41523. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41524. * @param ray defines the ray to test with
  41525. * @param selection defines the array to store current content if selection is positive
  41526. */
  41527. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41528. /**
  41529. * Subdivide the content into child blocks (this block will then be empty)
  41530. */
  41531. createInnerBlocks(): void;
  41532. /**
  41533. * @hidden
  41534. */ 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;
  41535. }
  41536. }
  41537. declare module BABYLON {
  41538. /**
  41539. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41540. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41541. */
  41542. export class Octree<T> {
  41543. /** 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.) */
  41544. maxDepth: number;
  41545. /**
  41546. * Blocks within the octree containing objects
  41547. */
  41548. blocks: Array<OctreeBlock<T>>;
  41549. /**
  41550. * Content stored in the octree
  41551. */
  41552. dynamicContent: T[];
  41553. private _maxBlockCapacity;
  41554. private _selectionContent;
  41555. private _creationFunc;
  41556. /**
  41557. * Creates a octree
  41558. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41559. * @param creationFunc function to be used to instatiate the octree
  41560. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41561. * @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.)
  41562. */
  41563. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41564. /** 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.) */
  41565. maxDepth?: number);
  41566. /**
  41567. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41568. * @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);
  41569. * @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);
  41570. * @param entries meshes to be added to the octree blocks
  41571. */
  41572. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41573. /**
  41574. * Adds a mesh to the octree
  41575. * @param entry Mesh to add to the octree
  41576. */
  41577. addMesh(entry: T): void;
  41578. /**
  41579. * Remove an element from the octree
  41580. * @param entry defines the element to remove
  41581. */
  41582. removeMesh(entry: T): void;
  41583. /**
  41584. * Selects an array of meshes within the frustum
  41585. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41586. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41587. * @returns array of meshes within the frustum
  41588. */
  41589. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41590. /**
  41591. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41592. * @param sphereCenter defines the bounding sphere center
  41593. * @param sphereRadius defines the bounding sphere radius
  41594. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41595. * @returns an array of objects that intersect the sphere
  41596. */
  41597. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41598. /**
  41599. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41600. * @param ray defines the ray to test with
  41601. * @returns array of intersected objects
  41602. */
  41603. intersectsRay(ray: Ray): SmartArray<T>;
  41604. /**
  41605. * Adds a mesh into the octree block if it intersects the block
  41606. */
  41607. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41608. /**
  41609. * Adds a submesh into the octree block if it intersects the block
  41610. */
  41611. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41612. }
  41613. }
  41614. declare module BABYLON {
  41615. interface Scene {
  41616. /**
  41617. * @hidden
  41618. * Backing Filed
  41619. */ private _selectionOctree: Octree<AbstractMesh>;
  41620. /**
  41621. * Gets the octree used to boost mesh selection (picking)
  41622. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41623. */
  41624. selectionOctree: Octree<AbstractMesh>;
  41625. /**
  41626. * Creates or updates the octree used to boost selection (picking)
  41627. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41628. * @param maxCapacity defines the maximum capacity per leaf
  41629. * @param maxDepth defines the maximum depth of the octree
  41630. * @returns an octree of AbstractMesh
  41631. */
  41632. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41633. }
  41634. interface AbstractMesh {
  41635. /**
  41636. * @hidden
  41637. * Backing Field
  41638. */ private _submeshesOctree: Octree<SubMesh>;
  41639. /**
  41640. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41641. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41642. * @param maxCapacity defines the maximum size of each block (64 by default)
  41643. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41644. * @returns the new octree
  41645. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41646. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41647. */
  41648. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41649. }
  41650. /**
  41651. * Defines the octree scene component responsible to manage any octrees
  41652. * in a given scene.
  41653. */
  41654. export class OctreeSceneComponent {
  41655. /**
  41656. * The component name help to identify the component in the list of scene components.
  41657. */
  41658. readonly name: string;
  41659. /**
  41660. * The scene the component belongs to.
  41661. */
  41662. scene: Scene;
  41663. /**
  41664. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41665. */
  41666. readonly checksIsEnabled: boolean;
  41667. /**
  41668. * Creates a new instance of the component for the given scene
  41669. * @param scene Defines the scene to register the component in
  41670. */
  41671. constructor(scene: Scene);
  41672. /**
  41673. * Registers the component in a given scene
  41674. */
  41675. register(): void;
  41676. /**
  41677. * Return the list of active meshes
  41678. * @returns the list of active meshes
  41679. */
  41680. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41681. /**
  41682. * Return the list of active sub meshes
  41683. * @param mesh The mesh to get the candidates sub meshes from
  41684. * @returns the list of active sub meshes
  41685. */
  41686. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41687. private _tempRay;
  41688. /**
  41689. * Return the list of sub meshes intersecting with a given local ray
  41690. * @param mesh defines the mesh to find the submesh for
  41691. * @param localRay defines the ray in local space
  41692. * @returns the list of intersecting sub meshes
  41693. */
  41694. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41695. /**
  41696. * Return the list of sub meshes colliding with a collider
  41697. * @param mesh defines the mesh to find the submesh for
  41698. * @param collider defines the collider to evaluate the collision against
  41699. * @returns the list of colliding sub meshes
  41700. */
  41701. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41702. /**
  41703. * Rebuilds the elements related to this component in case of
  41704. * context lost for instance.
  41705. */
  41706. rebuild(): void;
  41707. /**
  41708. * Disposes the component and the associated ressources.
  41709. */
  41710. dispose(): void;
  41711. }
  41712. }
  41713. declare module BABYLON {
  41714. /**
  41715. * Renders a layer on top of an existing scene
  41716. */
  41717. export class UtilityLayerRenderer implements IDisposable {
  41718. /** the original scene that will be rendered on top of */
  41719. originalScene: Scene;
  41720. private _pointerCaptures;
  41721. private _lastPointerEvents;
  41722. private static _DefaultUtilityLayer;
  41723. private static _DefaultKeepDepthUtilityLayer;
  41724. private _sharedGizmoLight;
  41725. private _renderCamera;
  41726. /**
  41727. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  41728. * @returns the camera that is used when rendering the utility layer
  41729. */
  41730. getRenderCamera(): Nullable<Camera>;
  41731. /**
  41732. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  41733. * @param cam the camera that should be used when rendering the utility layer
  41734. */
  41735. setRenderCamera(cam: Nullable<Camera>): void;
  41736. /**
  41737. * @hidden
  41738. * Light which used by gizmos to get light shading
  41739. */ private _getSharedGizmoLight(): HemisphericLight;
  41740. /**
  41741. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41742. */
  41743. pickUtilitySceneFirst: boolean;
  41744. /**
  41745. * 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)
  41746. */
  41747. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41748. /**
  41749. * 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)
  41750. */
  41751. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41752. /**
  41753. * The scene that is rendered on top of the original scene
  41754. */
  41755. utilityLayerScene: Scene;
  41756. /**
  41757. * If the utility layer should automatically be rendered on top of existing scene
  41758. */
  41759. shouldRender: boolean;
  41760. /**
  41761. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41762. */
  41763. onlyCheckPointerDownEvents: boolean;
  41764. /**
  41765. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41766. */
  41767. processAllEvents: boolean;
  41768. /**
  41769. * Observable raised when the pointer move from the utility layer scene to the main scene
  41770. */
  41771. onPointerOutObservable: Observable<number>;
  41772. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41773. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41774. private _afterRenderObserver;
  41775. private _sceneDisposeObserver;
  41776. private _originalPointerObserver;
  41777. /**
  41778. * Instantiates a UtilityLayerRenderer
  41779. * @param originalScene the original scene that will be rendered on top of
  41780. * @param handleEvents boolean indicating if the utility layer should handle events
  41781. */
  41782. constructor(
  41783. /** the original scene that will be rendered on top of */
  41784. originalScene: Scene, handleEvents?: boolean);
  41785. private _notifyObservers;
  41786. /**
  41787. * Renders the utility layers scene on top of the original scene
  41788. */
  41789. render(): void;
  41790. /**
  41791. * Disposes of the renderer
  41792. */
  41793. dispose(): void;
  41794. private _updateCamera;
  41795. }
  41796. }
  41797. declare module BABYLON {
  41798. /**
  41799. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41800. */
  41801. export class Gizmo implements IDisposable {
  41802. /** The utility layer the gizmo will be added to */
  41803. gizmoLayer: UtilityLayerRenderer;
  41804. /**
  41805. * The root mesh of the gizmo
  41806. */ private _rootMesh: Mesh;
  41807. private _attachedMesh;
  41808. /**
  41809. * Ratio for the scale of the gizmo (Default: 1)
  41810. */
  41811. scaleRatio: number;
  41812. /**
  41813. * If a custom mesh has been set (Default: false)
  41814. */
  41815. protected _customMeshSet: boolean;
  41816. /**
  41817. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41818. * * When set, interactions will be enabled
  41819. */
  41820. attachedMesh: Nullable<AbstractMesh>;
  41821. /**
  41822. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41823. * @param mesh The mesh to replace the default mesh of the gizmo
  41824. */
  41825. setCustomMesh(mesh: Mesh): void;
  41826. /**
  41827. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41828. */
  41829. updateGizmoRotationToMatchAttachedMesh: boolean;
  41830. /**
  41831. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41832. */
  41833. updateGizmoPositionToMatchAttachedMesh: boolean;
  41834. /**
  41835. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  41836. */
  41837. updateScale: boolean;
  41838. protected _interactionsEnabled: boolean;
  41839. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41840. private _beforeRenderObserver;
  41841. private _tempVector;
  41842. /**
  41843. * Creates a gizmo
  41844. * @param gizmoLayer The utility layer the gizmo will be added to
  41845. */
  41846. constructor(
  41847. /** The utility layer the gizmo will be added to */
  41848. gizmoLayer?: UtilityLayerRenderer);
  41849. /**
  41850. * Updates the gizmo to match the attached mesh's position/rotation
  41851. */
  41852. protected _update(): void;
  41853. /**
  41854. * Disposes of the gizmo
  41855. */
  41856. dispose(): void;
  41857. }
  41858. }
  41859. declare module BABYLON {
  41860. /**
  41861. * Single plane drag gizmo
  41862. */
  41863. export class PlaneDragGizmo extends Gizmo {
  41864. /**
  41865. * Drag behavior responsible for the gizmos dragging interactions
  41866. */
  41867. dragBehavior: PointerDragBehavior;
  41868. private _pointerObserver;
  41869. /**
  41870. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41871. */
  41872. snapDistance: number;
  41873. /**
  41874. * Event that fires each time the gizmo snaps to a new location.
  41875. * * snapDistance is the the change in distance
  41876. */
  41877. onSnapObservable: Observable<{
  41878. snapDistance: number;
  41879. }>;
  41880. private _plane;
  41881. private _coloredMaterial;
  41882. private _hoverMaterial;
  41883. private _isEnabled;
  41884. private _parent;
  41885. /** @hidden */ private static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  41886. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  41887. /**
  41888. * Creates a PlaneDragGizmo
  41889. * @param gizmoLayer The utility layer the gizmo will be added to
  41890. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  41891. * @param color The color of the gizmo
  41892. */
  41893. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  41894. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41895. /**
  41896. * If the gizmo is enabled
  41897. */
  41898. isEnabled: boolean;
  41899. /**
  41900. * Disposes of the gizmo
  41901. */
  41902. dispose(): void;
  41903. }
  41904. }
  41905. declare module BABYLON {
  41906. /**
  41907. * Gizmo that enables dragging a mesh along 3 axis
  41908. */
  41909. export class PositionGizmo extends Gizmo {
  41910. /**
  41911. * Internal gizmo used for interactions on the x axis
  41912. */
  41913. xGizmo: AxisDragGizmo;
  41914. /**
  41915. * Internal gizmo used for interactions on the y axis
  41916. */
  41917. yGizmo: AxisDragGizmo;
  41918. /**
  41919. * Internal gizmo used for interactions on the z axis
  41920. */
  41921. zGizmo: AxisDragGizmo;
  41922. /**
  41923. * Internal gizmo used for interactions on the yz plane
  41924. */
  41925. xPlaneGizmo: PlaneDragGizmo;
  41926. /**
  41927. * Internal gizmo used for interactions on the xz plane
  41928. */
  41929. yPlaneGizmo: PlaneDragGizmo;
  41930. /**
  41931. * Internal gizmo used for interactions on the xy plane
  41932. */
  41933. zPlaneGizmo: PlaneDragGizmo;
  41934. /**
  41935. * private variables
  41936. */
  41937. private _meshAttached;
  41938. private _updateGizmoRotationToMatchAttachedMesh;
  41939. private _snapDistance;
  41940. private _scaleRatio;
  41941. /** Fires an event when any of it's sub gizmos are dragged */
  41942. onDragStartObservable: Observable<unknown>;
  41943. /** Fires an event when any of it's sub gizmos are released from dragging */
  41944. onDragEndObservable: Observable<unknown>;
  41945. /**
  41946. * If set to true, planar drag is enabled
  41947. */
  41948. private _planarGizmoEnabled;
  41949. attachedMesh: Nullable<AbstractMesh>;
  41950. /**
  41951. * Creates a PositionGizmo
  41952. * @param gizmoLayer The utility layer the gizmo will be added to
  41953. */
  41954. constructor(gizmoLayer?: UtilityLayerRenderer);
  41955. /**
  41956. * If the planar drag gizmo is enabled
  41957. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  41958. */
  41959. planarGizmoEnabled: boolean;
  41960. updateGizmoRotationToMatchAttachedMesh: boolean;
  41961. /**
  41962. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41963. */
  41964. snapDistance: number;
  41965. /**
  41966. * Ratio for the scale of the gizmo (Default: 1)
  41967. */
  41968. scaleRatio: number;
  41969. /**
  41970. * Disposes of the gizmo
  41971. */
  41972. dispose(): void;
  41973. /**
  41974. * CustomMeshes are not supported by this gizmo
  41975. * @param mesh The mesh to replace the default mesh of the gizmo
  41976. */
  41977. setCustomMesh(mesh: Mesh): void;
  41978. }
  41979. }
  41980. declare module BABYLON {
  41981. /**
  41982. * Single axis drag gizmo
  41983. */
  41984. export class AxisDragGizmo extends Gizmo {
  41985. /**
  41986. * Drag behavior responsible for the gizmos dragging interactions
  41987. */
  41988. dragBehavior: PointerDragBehavior;
  41989. private _pointerObserver;
  41990. /**
  41991. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  41992. */
  41993. snapDistance: number;
  41994. /**
  41995. * Event that fires each time the gizmo snaps to a new location.
  41996. * * snapDistance is the the change in distance
  41997. */
  41998. onSnapObservable: Observable<{
  41999. snapDistance: number;
  42000. }>;
  42001. private _isEnabled;
  42002. private _parent;
  42003. private _arrow;
  42004. private _coloredMaterial;
  42005. private _hoverMaterial;
  42006. /** @hidden */ private static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42007. /** @hidden */ private static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42008. /**
  42009. * Creates an AxisDragGizmo
  42010. * @param gizmoLayer The utility layer the gizmo will be added to
  42011. * @param dragAxis The axis which the gizmo will be able to drag on
  42012. * @param color The color of the gizmo
  42013. */
  42014. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  42015. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42016. /**
  42017. * If the gizmo is enabled
  42018. */
  42019. isEnabled: boolean;
  42020. /**
  42021. * Disposes of the gizmo
  42022. */
  42023. dispose(): void;
  42024. }
  42025. }
  42026. declare module BABYLON.Debug {
  42027. /**
  42028. * The Axes viewer will show 3 axes in a specific point in space
  42029. */
  42030. export class AxesViewer {
  42031. private _xAxis;
  42032. private _yAxis;
  42033. private _zAxis;
  42034. private _scaleLinesFactor;
  42035. private _instanced;
  42036. /**
  42037. * Gets the hosting scene
  42038. */
  42039. scene: Scene;
  42040. /**
  42041. * Gets or sets a number used to scale line length
  42042. */
  42043. scaleLines: number;
  42044. /** Gets the node hierarchy used to render x-axis */
  42045. readonly xAxis: TransformNode;
  42046. /** Gets the node hierarchy used to render y-axis */
  42047. readonly yAxis: TransformNode;
  42048. /** Gets the node hierarchy used to render z-axis */
  42049. readonly zAxis: TransformNode;
  42050. /**
  42051. * Creates a new AxesViewer
  42052. * @param scene defines the hosting scene
  42053. * @param scaleLines defines a number used to scale line length (1 by default)
  42054. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42055. * @param xAxis defines the node hierarchy used to render the x-axis
  42056. * @param yAxis defines the node hierarchy used to render the y-axis
  42057. * @param zAxis defines the node hierarchy used to render the z-axis
  42058. */
  42059. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42060. /**
  42061. * Force the viewer to update
  42062. * @param position defines the position of the viewer
  42063. * @param xaxis defines the x axis of the viewer
  42064. * @param yaxis defines the y axis of the viewer
  42065. * @param zaxis defines the z axis of the viewer
  42066. */
  42067. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42068. /**
  42069. * Creates an instance of this axes viewer.
  42070. * @returns a new axes viewer with instanced meshes
  42071. */
  42072. createInstance(): AxesViewer;
  42073. /** Releases resources */
  42074. dispose(): void;
  42075. private static _SetRenderingGroupId;
  42076. }
  42077. }
  42078. declare module BABYLON.Debug {
  42079. /**
  42080. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42081. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42082. */
  42083. export class BoneAxesViewer extends AxesViewer {
  42084. /**
  42085. * Gets or sets the target mesh where to display the axes viewer
  42086. */
  42087. mesh: Nullable<Mesh>;
  42088. /**
  42089. * Gets or sets the target bone where to display the axes viewer
  42090. */
  42091. bone: Nullable<Bone>;
  42092. /** Gets current position */
  42093. pos: Vector3;
  42094. /** Gets direction of X axis */
  42095. xaxis: Vector3;
  42096. /** Gets direction of Y axis */
  42097. yaxis: Vector3;
  42098. /** Gets direction of Z axis */
  42099. zaxis: Vector3;
  42100. /**
  42101. * Creates a new BoneAxesViewer
  42102. * @param scene defines the hosting scene
  42103. * @param bone defines the target bone
  42104. * @param mesh defines the target mesh
  42105. * @param scaleLines defines a scaling factor for line length (1 by default)
  42106. */
  42107. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42108. /**
  42109. * Force the viewer to update
  42110. */
  42111. update(): void;
  42112. /** Releases resources */
  42113. dispose(): void;
  42114. }
  42115. }
  42116. declare module BABYLON {
  42117. /**
  42118. * Interface used to define scene explorer extensibility option
  42119. */
  42120. export interface IExplorerExtensibilityOption {
  42121. /**
  42122. * Define the option label
  42123. */
  42124. label: string;
  42125. /**
  42126. * Defines the action to execute on click
  42127. */
  42128. action: (entity: any) => void;
  42129. }
  42130. /**
  42131. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42132. */
  42133. export interface IExplorerExtensibilityGroup {
  42134. /**
  42135. * Defines a predicate to test if a given type mut be extended
  42136. */
  42137. predicate: (entity: any) => boolean;
  42138. /**
  42139. * Gets the list of options added to a type
  42140. */
  42141. entries: IExplorerExtensibilityOption[];
  42142. }
  42143. /**
  42144. * Interface used to define the options to use to create the Inspector
  42145. */
  42146. export interface IInspectorOptions {
  42147. /**
  42148. * Display in overlay mode (default: false)
  42149. */
  42150. overlay?: boolean;
  42151. /**
  42152. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42153. */
  42154. globalRoot?: HTMLElement;
  42155. /**
  42156. * Display the Scene explorer
  42157. */
  42158. showExplorer?: boolean;
  42159. /**
  42160. * Display the property inspector
  42161. */
  42162. showInspector?: boolean;
  42163. /**
  42164. * Display in embed mode (both panes on the right)
  42165. */
  42166. embedMode?: boolean;
  42167. /**
  42168. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42169. */
  42170. handleResize?: boolean;
  42171. /**
  42172. * Allow the panes to popup (default: true)
  42173. */
  42174. enablePopup?: boolean;
  42175. /**
  42176. * Allow the panes to be closed by users (default: true)
  42177. */
  42178. enableClose?: boolean;
  42179. /**
  42180. * Optional list of extensibility entries
  42181. */
  42182. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42183. /**
  42184. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42185. */
  42186. inspectorURL?: string;
  42187. }
  42188. interface Scene {
  42189. /**
  42190. * @hidden
  42191. * Backing field
  42192. */ private _debugLayer: DebugLayer;
  42193. /**
  42194. * Gets the debug layer (aka Inspector) associated with the scene
  42195. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42196. */
  42197. debugLayer: DebugLayer;
  42198. }
  42199. /**
  42200. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42201. * what is happening in your scene
  42202. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42203. */
  42204. export class DebugLayer {
  42205. /**
  42206. * Define the url to get the inspector script from.
  42207. * By default it uses the babylonjs CDN.
  42208. * @ignoreNaming
  42209. */
  42210. static InspectorURL: string;
  42211. private _scene;
  42212. private BJSINSPECTOR;
  42213. private _onPropertyChangedObservable?;
  42214. /**
  42215. * Observable triggered when a property is changed through the inspector.
  42216. */
  42217. readonly onPropertyChangedObservable: any;
  42218. /**
  42219. * Instantiates a new debug layer.
  42220. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42221. * what is happening in your scene
  42222. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42223. * @param scene Defines the scene to inspect
  42224. */
  42225. constructor(scene: Scene);
  42226. /** Creates the inspector window. */
  42227. private _createInspector;
  42228. /**
  42229. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42230. * @param entity defines the entity to select
  42231. * @param lineContainerTitle defines the specific block to highlight
  42232. */
  42233. select(entity: any, lineContainerTitle?: string): void;
  42234. /** Get the inspector from bundle or global */
  42235. private _getGlobalInspector;
  42236. /**
  42237. * Get if the inspector is visible or not.
  42238. * @returns true if visible otherwise, false
  42239. */
  42240. isVisible(): boolean;
  42241. /**
  42242. * Hide the inspector and close its window.
  42243. */
  42244. hide(): void;
  42245. /**
  42246. * Launch the debugLayer.
  42247. * @param config Define the configuration of the inspector
  42248. * @return a promise fulfilled when the debug layer is visible
  42249. */
  42250. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42251. }
  42252. }
  42253. declare module BABYLON {
  42254. /**
  42255. * Class containing static functions to help procedurally build meshes
  42256. */
  42257. export class BoxBuilder {
  42258. /**
  42259. * Creates a box mesh
  42260. * * The parameter `size` sets the size (float) of each box side (default 1)
  42261. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42262. * * 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)
  42263. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42264. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42265. * * 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
  42266. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42267. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42268. * @param name defines the name of the mesh
  42269. * @param options defines the options used to create the mesh
  42270. * @param scene defines the hosting scene
  42271. * @returns the box mesh
  42272. */
  42273. static CreateBox(name: string, options: {
  42274. size?: number;
  42275. width?: number;
  42276. height?: number;
  42277. depth?: number;
  42278. faceUV?: Vector4[];
  42279. faceColors?: Color4[];
  42280. sideOrientation?: number;
  42281. frontUVs?: Vector4;
  42282. backUVs?: Vector4;
  42283. wrap?: boolean;
  42284. topBaseAt?: number;
  42285. bottomBaseAt?: number;
  42286. updatable?: boolean;
  42287. }, scene?: Nullable<Scene>): Mesh;
  42288. }
  42289. }
  42290. declare module BABYLON {
  42291. /**
  42292. * Class containing static functions to help procedurally build meshes
  42293. */
  42294. export class SphereBuilder {
  42295. /**
  42296. * Creates a sphere mesh
  42297. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42298. * * 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`)
  42299. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42300. * * 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
  42301. * * 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)
  42302. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42303. * * 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
  42304. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42305. * @param name defines the name of the mesh
  42306. * @param options defines the options used to create the mesh
  42307. * @param scene defines the hosting scene
  42308. * @returns the sphere mesh
  42309. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42310. */
  42311. static CreateSphere(name: string, options: {
  42312. segments?: number;
  42313. diameter?: number;
  42314. diameterX?: number;
  42315. diameterY?: number;
  42316. diameterZ?: number;
  42317. arc?: number;
  42318. slice?: number;
  42319. sideOrientation?: number;
  42320. frontUVs?: Vector4;
  42321. backUVs?: Vector4;
  42322. updatable?: boolean;
  42323. }, scene: any): Mesh;
  42324. }
  42325. }
  42326. declare module BABYLON.Debug {
  42327. /**
  42328. * Used to show the physics impostor around the specific mesh
  42329. */
  42330. export class PhysicsViewer {
  42331. /** @hidden */
  42332. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42333. /** @hidden */
  42334. protected _meshes: Array<Nullable<AbstractMesh>>;
  42335. /** @hidden */
  42336. protected _scene: Nullable<Scene>;
  42337. /** @hidden */
  42338. protected _numMeshes: number;
  42339. /** @hidden */
  42340. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42341. private _renderFunction;
  42342. private _utilityLayer;
  42343. private _debugBoxMesh;
  42344. private _debugSphereMesh;
  42345. private _debugCylinderMesh;
  42346. private _debugMaterial;
  42347. private _debugMeshMeshes;
  42348. /**
  42349. * Creates a new PhysicsViewer
  42350. * @param scene defines the hosting scene
  42351. */
  42352. constructor(scene: Scene);
  42353. /** @hidden */
  42354. protected _updateDebugMeshes(): void;
  42355. /**
  42356. * Renders a specified physic impostor
  42357. * @param impostor defines the impostor to render
  42358. * @param targetMesh defines the mesh represented by the impostor
  42359. * @returns the new debug mesh used to render the impostor
  42360. */
  42361. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42362. /**
  42363. * Hides a specified physic impostor
  42364. * @param impostor defines the impostor to hide
  42365. */
  42366. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42367. private _getDebugMaterial;
  42368. private _getDebugBoxMesh;
  42369. private _getDebugSphereMesh;
  42370. private _getDebugCylinderMesh;
  42371. private _getDebugMeshMesh;
  42372. private _getDebugMesh;
  42373. /** Releases all resources */
  42374. dispose(): void;
  42375. }
  42376. }
  42377. declare module BABYLON {
  42378. /**
  42379. * Class containing static functions to help procedurally build meshes
  42380. */
  42381. export class LinesBuilder {
  42382. /**
  42383. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42384. * * 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
  42385. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42386. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42387. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42388. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42389. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42390. * * 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
  42391. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42392. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42393. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42394. * @param name defines the name of the new line system
  42395. * @param options defines the options used to create the line system
  42396. * @param scene defines the hosting scene
  42397. * @returns a new line system mesh
  42398. */
  42399. static CreateLineSystem(name: string, options: {
  42400. lines: Vector3[][];
  42401. updatable?: boolean;
  42402. instance?: Nullable<LinesMesh>;
  42403. colors?: Nullable<Color4[][]>;
  42404. useVertexAlpha?: boolean;
  42405. }, scene: Nullable<Scene>): LinesMesh;
  42406. /**
  42407. * Creates a line mesh
  42408. * 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
  42409. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42410. * * The parameter `points` is an array successive Vector3
  42411. * * 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
  42412. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42413. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42414. * * When updating an instance, remember that only point positions can change, not the number of points
  42415. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42416. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42417. * @param name defines the name of the new line system
  42418. * @param options defines the options used to create the line system
  42419. * @param scene defines the hosting scene
  42420. * @returns a new line mesh
  42421. */
  42422. static CreateLines(name: string, options: {
  42423. points: Vector3[];
  42424. updatable?: boolean;
  42425. instance?: Nullable<LinesMesh>;
  42426. colors?: Color4[];
  42427. useVertexAlpha?: boolean;
  42428. }, scene?: Nullable<Scene>): LinesMesh;
  42429. /**
  42430. * Creates a dashed line mesh
  42431. * * 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
  42432. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42433. * * The parameter `points` is an array successive Vector3
  42434. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42435. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42436. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42437. * * 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
  42438. * * When updating an instance, remember that only point positions can change, not the number of points
  42439. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42440. * @param name defines the name of the mesh
  42441. * @param options defines the options used to create the mesh
  42442. * @param scene defines the hosting scene
  42443. * @returns the dashed line mesh
  42444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42445. */
  42446. static CreateDashedLines(name: string, options: {
  42447. points: Vector3[];
  42448. dashSize?: number;
  42449. gapSize?: number;
  42450. dashNb?: number;
  42451. updatable?: boolean;
  42452. instance?: LinesMesh;
  42453. }, scene?: Nullable<Scene>): LinesMesh;
  42454. }
  42455. }
  42456. declare module BABYLON {
  42457. /**
  42458. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42459. * in order to better appreciate the issue one might have.
  42460. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42461. */
  42462. export class RayHelper {
  42463. /**
  42464. * Defines the ray we are currently tryin to visualize.
  42465. */
  42466. ray: Nullable<Ray>;
  42467. private _renderPoints;
  42468. private _renderLine;
  42469. private _renderFunction;
  42470. private _scene;
  42471. private _updateToMeshFunction;
  42472. private _attachedToMesh;
  42473. private _meshSpaceDirection;
  42474. private _meshSpaceOrigin;
  42475. /**
  42476. * Helper function to create a colored helper in a scene in one line.
  42477. * @param ray Defines the ray we are currently tryin to visualize
  42478. * @param scene Defines the scene the ray is used in
  42479. * @param color Defines the color we want to see the ray in
  42480. * @returns The newly created ray helper.
  42481. */
  42482. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42483. /**
  42484. * Instantiate a new ray helper.
  42485. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42486. * in order to better appreciate the issue one might have.
  42487. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42488. * @param ray Defines the ray we are currently tryin to visualize
  42489. */
  42490. constructor(ray: Ray);
  42491. /**
  42492. * Shows the ray we are willing to debug.
  42493. * @param scene Defines the scene the ray needs to be rendered in
  42494. * @param color Defines the color the ray needs to be rendered in
  42495. */
  42496. show(scene: Scene, color?: Color3): void;
  42497. /**
  42498. * Hides the ray we are debugging.
  42499. */
  42500. hide(): void;
  42501. private _render;
  42502. /**
  42503. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42504. * @param mesh Defines the mesh we want the helper attached to
  42505. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42506. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42507. * @param length Defines the length of the ray
  42508. */
  42509. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42510. /**
  42511. * Detach the ray helper from the mesh it has previously been attached to.
  42512. */
  42513. detachFromMesh(): void;
  42514. private _updateToMesh;
  42515. /**
  42516. * Dispose the helper and release its associated resources.
  42517. */
  42518. dispose(): void;
  42519. }
  42520. }
  42521. declare module BABYLON.Debug {
  42522. /**
  42523. * Class used to render a debug view of a given skeleton
  42524. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42525. */
  42526. export class SkeletonViewer {
  42527. /** defines the skeleton to render */
  42528. skeleton: Skeleton;
  42529. /** defines the mesh attached to the skeleton */
  42530. mesh: AbstractMesh;
  42531. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42532. autoUpdateBonesMatrices: boolean;
  42533. /** defines the rendering group id to use with the viewer */
  42534. renderingGroupId: number;
  42535. /** Gets or sets the color used to render the skeleton */
  42536. color: Color3;
  42537. private _scene;
  42538. private _debugLines;
  42539. private _debugMesh;
  42540. private _isEnabled;
  42541. private _renderFunction;
  42542. private _utilityLayer;
  42543. /**
  42544. * Returns the mesh used to render the bones
  42545. */
  42546. readonly debugMesh: Nullable<LinesMesh>;
  42547. /**
  42548. * Creates a new SkeletonViewer
  42549. * @param skeleton defines the skeleton to render
  42550. * @param mesh defines the mesh attached to the skeleton
  42551. * @param scene defines the hosting scene
  42552. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42553. * @param renderingGroupId defines the rendering group id to use with the viewer
  42554. */
  42555. constructor(
  42556. /** defines the skeleton to render */
  42557. skeleton: Skeleton,
  42558. /** defines the mesh attached to the skeleton */
  42559. mesh: AbstractMesh, scene: Scene,
  42560. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42561. autoUpdateBonesMatrices?: boolean,
  42562. /** defines the rendering group id to use with the viewer */
  42563. renderingGroupId?: number);
  42564. /** Gets or sets a boolean indicating if the viewer is enabled */
  42565. isEnabled: boolean;
  42566. private _getBonePosition;
  42567. private _getLinesForBonesWithLength;
  42568. private _getLinesForBonesNoLength;
  42569. /** Update the viewer to sync with current skeleton state */
  42570. update(): void;
  42571. /** Release associated resources */
  42572. dispose(): void;
  42573. }
  42574. }
  42575. declare module BABYLON {
  42576. /**
  42577. * Options to create the null engine
  42578. */
  42579. export class NullEngineOptions {
  42580. /**
  42581. * Render width (Default: 512)
  42582. */
  42583. renderWidth: number;
  42584. /**
  42585. * Render height (Default: 256)
  42586. */
  42587. renderHeight: number;
  42588. /**
  42589. * Texture size (Default: 512)
  42590. */
  42591. textureSize: number;
  42592. /**
  42593. * If delta time between frames should be constant
  42594. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42595. */
  42596. deterministicLockstep: boolean;
  42597. /**
  42598. * Maximum about of steps between frames (Default: 4)
  42599. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42600. */
  42601. lockstepMaxSteps: number;
  42602. }
  42603. /**
  42604. * The null engine class provides support for headless version of babylon.js.
  42605. * This can be used in server side scenario or for testing purposes
  42606. */
  42607. export class NullEngine extends Engine {
  42608. private _options;
  42609. /**
  42610. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42611. */
  42612. isDeterministicLockStep(): boolean;
  42613. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42614. getLockstepMaxSteps(): number;
  42615. /**
  42616. * Sets hardware scaling, used to save performance if needed
  42617. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42618. */
  42619. getHardwareScalingLevel(): number;
  42620. constructor(options?: NullEngineOptions);
  42621. createVertexBuffer(vertices: FloatArray): DataBuffer;
  42622. createIndexBuffer(indices: IndicesArray): DataBuffer;
  42623. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42624. getRenderWidth(useScreen?: boolean): number;
  42625. getRenderHeight(useScreen?: boolean): number;
  42626. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  42627. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42628. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  42629. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  42630. bindSamplers(effect: Effect): void;
  42631. enableEffect(effect: Effect): void;
  42632. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42633. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42634. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42635. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42636. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42637. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42638. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42639. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42640. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42641. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42642. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42643. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42644. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42645. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42646. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42647. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42648. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42649. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42650. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42651. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42652. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42653. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42654. bindBuffers(vertexBuffers: {
  42655. [key: string]: VertexBuffer;
  42656. }, indexBuffer: DataBuffer, effect: Effect): void;
  42657. wipeCaches(bruteForce?: boolean): void;
  42658. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42659. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42660. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42661. /** @hidden */ private _createTexture(): WebGLTexture;
  42662. /** @hidden */ private _releaseTexture(texture: InternalTexture): void;
  42663. 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;
  42664. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42665. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42666. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42667. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42668. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  42669. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42670. areAllEffectsReady(): boolean;
  42671. /**
  42672. * @hidden
  42673. * Get the current error code of the webGL context
  42674. * @returns the error code
  42675. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42676. */
  42677. getError(): number;
  42678. /** @hidden */ private _getUnpackAlignement(): number;
  42679. /** @hidden */ private _unpackFlipY(value: boolean): void;
  42680. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42681. /**
  42682. * Updates a dynamic vertex buffer.
  42683. * @param vertexBuffer the vertex buffer to update
  42684. * @param data the data used to update the vertex buffer
  42685. * @param byteOffset the byte offset of the data (optional)
  42686. * @param byteLength the byte length of the data (optional)
  42687. */
  42688. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void; private _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42689. /** @hidden */ private _bindTexture(channel: number, texture: InternalTexture): void;
  42690. /** @hidden */ private _releaseBuffer(buffer: DataBuffer): boolean;
  42691. releaseEffects(): void;
  42692. displayLoadingUI(): void;
  42693. hideLoadingUI(): void;
  42694. /** @hidden */ private _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42695. /** @hidden */ private _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42696. /** @hidden */ private _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42697. /** @hidden */ private _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42698. }
  42699. }
  42700. declare module BABYLON {
  42701. /** @hidden */
  42702. export class _OcclusionDataStorage {
  42703. /** @hidden */
  42704. occlusionInternalRetryCounter: number;
  42705. /** @hidden */
  42706. isOcclusionQueryInProgress: boolean;
  42707. /** @hidden */
  42708. isOccluded: boolean;
  42709. /** @hidden */
  42710. occlusionRetryCount: number;
  42711. /** @hidden */
  42712. occlusionType: number;
  42713. /** @hidden */
  42714. occlusionQueryAlgorithmType: number;
  42715. }
  42716. interface Engine {
  42717. /**
  42718. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42719. * @return the new query
  42720. */
  42721. createQuery(): WebGLQuery;
  42722. /**
  42723. * Delete and release a webGL query
  42724. * @param query defines the query to delete
  42725. * @return the current engine
  42726. */
  42727. deleteQuery(query: WebGLQuery): Engine;
  42728. /**
  42729. * Check if a given query has resolved and got its value
  42730. * @param query defines the query to check
  42731. * @returns true if the query got its value
  42732. */
  42733. isQueryResultAvailable(query: WebGLQuery): boolean;
  42734. /**
  42735. * Gets the value of a given query
  42736. * @param query defines the query to check
  42737. * @returns the value of the query
  42738. */
  42739. getQueryResult(query: WebGLQuery): number;
  42740. /**
  42741. * Initiates an occlusion query
  42742. * @param algorithmType defines the algorithm to use
  42743. * @param query defines the query to use
  42744. * @returns the current engine
  42745. * @see http://doc.babylonjs.com/features/occlusionquery
  42746. */
  42747. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42748. /**
  42749. * Ends an occlusion query
  42750. * @see http://doc.babylonjs.com/features/occlusionquery
  42751. * @param algorithmType defines the algorithm to use
  42752. * @returns the current engine
  42753. */
  42754. endOcclusionQuery(algorithmType: number): Engine;
  42755. /**
  42756. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42757. * Please note that only one query can be issued at a time
  42758. * @returns a time token used to track the time span
  42759. */
  42760. startTimeQuery(): Nullable<_TimeToken>;
  42761. /**
  42762. * Ends a time query
  42763. * @param token defines the token used to measure the time span
  42764. * @returns the time spent (in ns)
  42765. */
  42766. endTimeQuery(token: _TimeToken): int;
  42767. /** @hidden */ private _currentNonTimestampToken: Nullable<_TimeToken>;
  42768. /** @hidden */ private _createTimeQuery(): WebGLQuery;
  42769. /** @hidden */ private _deleteTimeQuery(query: WebGLQuery): void;
  42770. /** @hidden */ private _getGlAlgorithmType(algorithmType: number): number;
  42771. /** @hidden */ private _getTimeQueryResult(query: WebGLQuery): any;
  42772. /** @hidden */ private _getTimeQueryAvailability(query: WebGLQuery): any;
  42773. }
  42774. interface AbstractMesh {
  42775. /**
  42776. * Backing filed
  42777. * @hidden
  42778. */ private __occlusionDataStorage: _OcclusionDataStorage;
  42779. /**
  42780. * Access property
  42781. * @hidden
  42782. */ private _occlusionDataStorage: _OcclusionDataStorage;
  42783. /**
  42784. * 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.
  42785. * The default value is -1 which means don't break the query and wait till the result
  42786. * @see http://doc.babylonjs.com/features/occlusionquery
  42787. */
  42788. occlusionRetryCount: number;
  42789. /**
  42790. * 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:
  42791. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42792. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42793. * * 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.
  42794. * @see http://doc.babylonjs.com/features/occlusionquery
  42795. */
  42796. occlusionType: number;
  42797. /**
  42798. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42799. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42800. * * 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.
  42801. * @see http://doc.babylonjs.com/features/occlusionquery
  42802. */
  42803. occlusionQueryAlgorithmType: number;
  42804. /**
  42805. * 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
  42806. * @see http://doc.babylonjs.com/features/occlusionquery
  42807. */
  42808. isOccluded: boolean;
  42809. /**
  42810. * Flag to check the progress status of the query
  42811. * @see http://doc.babylonjs.com/features/occlusionquery
  42812. */
  42813. isOcclusionQueryInProgress: boolean;
  42814. }
  42815. }
  42816. declare module BABYLON {
  42817. /** @hidden */
  42818. export var _forceTransformFeedbackToBundle: boolean;
  42819. interface Engine {
  42820. /**
  42821. * Creates a webGL transform feedback object
  42822. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42823. * @returns the webGL transform feedback object
  42824. */
  42825. createTransformFeedback(): WebGLTransformFeedback;
  42826. /**
  42827. * Delete a webGL transform feedback object
  42828. * @param value defines the webGL transform feedback object to delete
  42829. */
  42830. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42831. /**
  42832. * Bind a webGL transform feedback object to the webgl context
  42833. * @param value defines the webGL transform feedback object to bind
  42834. */
  42835. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42836. /**
  42837. * Begins a transform feedback operation
  42838. * @param usePoints defines if points or triangles must be used
  42839. */
  42840. beginTransformFeedback(usePoints: boolean): void;
  42841. /**
  42842. * Ends a transform feedback operation
  42843. */
  42844. endTransformFeedback(): void;
  42845. /**
  42846. * Specify the varyings to use with transform feedback
  42847. * @param program defines the associated webGL program
  42848. * @param value defines the list of strings representing the varying names
  42849. */
  42850. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42851. /**
  42852. * Bind a webGL buffer for a transform feedback operation
  42853. * @param value defines the webGL buffer to bind
  42854. */
  42855. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  42856. }
  42857. }
  42858. declare module BABYLON {
  42859. /**
  42860. * Creation options of the multi render target texture.
  42861. */
  42862. export interface IMultiRenderTargetOptions {
  42863. /**
  42864. * Define if the texture needs to create mip maps after render.
  42865. */
  42866. generateMipMaps?: boolean;
  42867. /**
  42868. * Define the types of all the draw buffers we want to create
  42869. */
  42870. types?: number[];
  42871. /**
  42872. * Define the sampling modes of all the draw buffers we want to create
  42873. */
  42874. samplingModes?: number[];
  42875. /**
  42876. * Define if a depth buffer is required
  42877. */
  42878. generateDepthBuffer?: boolean;
  42879. /**
  42880. * Define if a stencil buffer is required
  42881. */
  42882. generateStencilBuffer?: boolean;
  42883. /**
  42884. * Define if a depth texture is required instead of a depth buffer
  42885. */
  42886. generateDepthTexture?: boolean;
  42887. /**
  42888. * Define the number of desired draw buffers
  42889. */
  42890. textureCount?: number;
  42891. /**
  42892. * Define if aspect ratio should be adapted to the texture or stay the scene one
  42893. */
  42894. doNotChangeAspectRatio?: boolean;
  42895. /**
  42896. * Define the default type of the buffers we are creating
  42897. */
  42898. defaultType?: number;
  42899. }
  42900. /**
  42901. * A multi render target, like a render target provides the ability to render to a texture.
  42902. * Unlike the render target, it can render to several draw buffers in one draw.
  42903. * This is specially interesting in deferred rendering or for any effects requiring more than
  42904. * just one color from a single pass.
  42905. */
  42906. export class MultiRenderTarget extends RenderTargetTexture {
  42907. private _internalTextures;
  42908. private _textures;
  42909. private _multiRenderTargetOptions;
  42910. /**
  42911. * Get if draw buffers are currently supported by the used hardware and browser.
  42912. */
  42913. readonly isSupported: boolean;
  42914. /**
  42915. * Get the list of textures generated by the multi render target.
  42916. */
  42917. readonly textures: Texture[];
  42918. /**
  42919. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  42920. */
  42921. readonly depthTexture: Texture;
  42922. /**
  42923. * Set the wrapping mode on U of all the textures we are rendering to.
  42924. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42925. */
  42926. wrapU: number;
  42927. /**
  42928. * Set the wrapping mode on V of all the textures we are rendering to.
  42929. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  42930. */
  42931. wrapV: number;
  42932. /**
  42933. * Instantiate a new multi render target texture.
  42934. * A multi render target, like a render target provides the ability to render to a texture.
  42935. * Unlike the render target, it can render to several draw buffers in one draw.
  42936. * This is specially interesting in deferred rendering or for any effects requiring more than
  42937. * just one color from a single pass.
  42938. * @param name Define the name of the texture
  42939. * @param size Define the size of the buffers to render to
  42940. * @param count Define the number of target we are rendering into
  42941. * @param scene Define the scene the texture belongs to
  42942. * @param options Define the options used to create the multi render target
  42943. */
  42944. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  42945. /** @hidden */ private _rebuild(): void;
  42946. private _createInternalTextures;
  42947. private _createTextures;
  42948. /**
  42949. * Define the number of samples used if MSAA is enabled.
  42950. */
  42951. samples: number;
  42952. /**
  42953. * Resize all the textures in the multi render target.
  42954. * Be carrefull as it will recreate all the data in the new texture.
  42955. * @param size Define the new size
  42956. */
  42957. resize(size: any): void;
  42958. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  42959. /**
  42960. * Dispose the render targets and their associated resources
  42961. */
  42962. dispose(): void;
  42963. /**
  42964. * Release all the underlying texture used as draw buffers.
  42965. */
  42966. releaseInternalTextures(): void;
  42967. }
  42968. }
  42969. declare module BABYLON {
  42970. interface Engine {
  42971. /**
  42972. * Unbind a list of render target textures from the webGL context
  42973. * This is used only when drawBuffer extension or webGL2 are active
  42974. * @param textures defines the render target textures to unbind
  42975. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  42976. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  42977. */
  42978. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  42979. /**
  42980. * Create a multi render target texture
  42981. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  42982. * @param size defines the size of the texture
  42983. * @param options defines the creation options
  42984. * @returns the cube texture as an InternalTexture
  42985. */
  42986. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  42987. /**
  42988. * Update the sample count for a given multiple render target texture
  42989. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  42990. * @param textures defines the textures to update
  42991. * @param samples defines the sample count to set
  42992. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  42993. */
  42994. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  42995. }
  42996. }
  42997. declare module BABYLON {
  42998. /**
  42999. * Gather the list of clipboard event types as constants.
  43000. */
  43001. export class ClipboardEventTypes {
  43002. /**
  43003. * The clipboard event is fired when a copy command is active (pressed).
  43004. */
  43005. static readonly COPY: number;
  43006. /**
  43007. * The clipboard event is fired when a cut command is active (pressed).
  43008. */
  43009. static readonly CUT: number;
  43010. /**
  43011. * The clipboard event is fired when a paste command is active (pressed).
  43012. */
  43013. static readonly PASTE: number;
  43014. }
  43015. /**
  43016. * This class is used to store clipboard related info for the onClipboardObservable event.
  43017. */
  43018. export class ClipboardInfo {
  43019. /**
  43020. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43021. */
  43022. type: number;
  43023. /**
  43024. * Defines the related dom event
  43025. */
  43026. event: ClipboardEvent;
  43027. /**
  43028. *Creates an instance of ClipboardInfo.
  43029. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43030. * @param event Defines the related dom event
  43031. */
  43032. constructor(
  43033. /**
  43034. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43035. */
  43036. type: number,
  43037. /**
  43038. * Defines the related dom event
  43039. */
  43040. event: ClipboardEvent);
  43041. /**
  43042. * Get the clipboard event's type from the keycode.
  43043. * @param keyCode Defines the keyCode for the current keyboard event.
  43044. * @return {number}
  43045. */
  43046. static GetTypeFromCharacter(keyCode: number): number;
  43047. }
  43048. }
  43049. declare module BABYLON {
  43050. /**
  43051. * Google Daydream controller
  43052. */
  43053. export class DaydreamController extends WebVRController {
  43054. /**
  43055. * Base Url for the controller model.
  43056. */
  43057. static MODEL_BASE_URL: string;
  43058. /**
  43059. * File name for the controller model.
  43060. */
  43061. static MODEL_FILENAME: string;
  43062. /**
  43063. * Gamepad Id prefix used to identify Daydream Controller.
  43064. */
  43065. static readonly GAMEPAD_ID_PREFIX: string;
  43066. /**
  43067. * Creates a new DaydreamController from a gamepad
  43068. * @param vrGamepad the gamepad that the controller should be created from
  43069. */
  43070. constructor(vrGamepad: any);
  43071. /**
  43072. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43073. * @param scene scene in which to add meshes
  43074. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43075. */
  43076. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43077. /**
  43078. * Called once for each button that changed state since the last frame
  43079. * @param buttonIdx Which button index changed
  43080. * @param state New state of the button
  43081. * @param changes Which properties on the state changed since last frame
  43082. */
  43083. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43084. }
  43085. }
  43086. declare module BABYLON {
  43087. /**
  43088. * Gear VR Controller
  43089. */
  43090. export class GearVRController extends WebVRController {
  43091. /**
  43092. * Base Url for the controller model.
  43093. */
  43094. static MODEL_BASE_URL: string;
  43095. /**
  43096. * File name for the controller model.
  43097. */
  43098. static MODEL_FILENAME: string;
  43099. /**
  43100. * Gamepad Id prefix used to identify this controller.
  43101. */
  43102. static readonly GAMEPAD_ID_PREFIX: string;
  43103. private readonly _buttonIndexToObservableNameMap;
  43104. /**
  43105. * Creates a new GearVRController from a gamepad
  43106. * @param vrGamepad the gamepad that the controller should be created from
  43107. */
  43108. constructor(vrGamepad: any);
  43109. /**
  43110. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43111. * @param scene scene in which to add meshes
  43112. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43113. */
  43114. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43115. /**
  43116. * Called once for each button that changed state since the last frame
  43117. * @param buttonIdx Which button index changed
  43118. * @param state New state of the button
  43119. * @param changes Which properties on the state changed since last frame
  43120. */
  43121. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43122. }
  43123. }
  43124. declare module BABYLON {
  43125. /**
  43126. * Class containing static functions to help procedurally build meshes
  43127. */
  43128. export class PolyhedronBuilder {
  43129. /**
  43130. * Creates a polyhedron mesh
  43131. * * 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
  43132. * * The parameter `size` (positive float, default 1) sets the polygon size
  43133. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  43134. * * 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`
  43135. * * 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
  43136. * * 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)`)
  43137. * * 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
  43138. * * 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
  43139. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  43140. * * 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
  43141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  43142. * @param name defines the name of the mesh
  43143. * @param options defines the options used to create the mesh
  43144. * @param scene defines the hosting scene
  43145. * @returns the polyhedron mesh
  43146. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  43147. */
  43148. static CreatePolyhedron(name: string, options: {
  43149. type?: number;
  43150. size?: number;
  43151. sizeX?: number;
  43152. sizeY?: number;
  43153. sizeZ?: number;
  43154. custom?: any;
  43155. faceUV?: Vector4[];
  43156. faceColors?: Color4[];
  43157. flat?: boolean;
  43158. updatable?: boolean;
  43159. sideOrientation?: number;
  43160. frontUVs?: Vector4;
  43161. backUVs?: Vector4;
  43162. }, scene?: Nullable<Scene>): Mesh;
  43163. }
  43164. }
  43165. declare module BABYLON {
  43166. /**
  43167. * Gizmo that enables scaling a mesh along 3 axis
  43168. */
  43169. export class ScaleGizmo extends Gizmo {
  43170. /**
  43171. * Internal gizmo used for interactions on the x axis
  43172. */
  43173. xGizmo: AxisScaleGizmo;
  43174. /**
  43175. * Internal gizmo used for interactions on the y axis
  43176. */
  43177. yGizmo: AxisScaleGizmo;
  43178. /**
  43179. * Internal gizmo used for interactions on the z axis
  43180. */
  43181. zGizmo: AxisScaleGizmo;
  43182. /**
  43183. * Internal gizmo used to scale all axis equally
  43184. */
  43185. uniformScaleGizmo: AxisScaleGizmo;
  43186. private _meshAttached;
  43187. private _updateGizmoRotationToMatchAttachedMesh;
  43188. private _snapDistance;
  43189. private _scaleRatio;
  43190. private _uniformScalingMesh;
  43191. private _octahedron;
  43192. /** Fires an event when any of it's sub gizmos are dragged */
  43193. onDragStartObservable: Observable<unknown>;
  43194. /** Fires an event when any of it's sub gizmos are released from dragging */
  43195. onDragEndObservable: Observable<unknown>;
  43196. attachedMesh: Nullable<AbstractMesh>;
  43197. /**
  43198. * Creates a ScaleGizmo
  43199. * @param gizmoLayer The utility layer the gizmo will be added to
  43200. */
  43201. constructor(gizmoLayer?: UtilityLayerRenderer);
  43202. updateGizmoRotationToMatchAttachedMesh: boolean;
  43203. /**
  43204. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43205. */
  43206. snapDistance: number;
  43207. /**
  43208. * Ratio for the scale of the gizmo (Default: 1)
  43209. */
  43210. scaleRatio: number;
  43211. /**
  43212. * Disposes of the gizmo
  43213. */
  43214. dispose(): void;
  43215. }
  43216. }
  43217. declare module BABYLON {
  43218. /**
  43219. * Single axis scale gizmo
  43220. */
  43221. export class AxisScaleGizmo extends Gizmo {
  43222. /**
  43223. * Drag behavior responsible for the gizmos dragging interactions
  43224. */
  43225. dragBehavior: PointerDragBehavior;
  43226. private _pointerObserver;
  43227. /**
  43228. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43229. */
  43230. snapDistance: number;
  43231. /**
  43232. * Event that fires each time the gizmo snaps to a new location.
  43233. * * snapDistance is the the change in distance
  43234. */
  43235. onSnapObservable: Observable<{
  43236. snapDistance: number;
  43237. }>;
  43238. /**
  43239. * If the scaling operation should be done on all axis (default: false)
  43240. */
  43241. uniformScaling: boolean;
  43242. private _isEnabled;
  43243. private _parent;
  43244. private _arrow;
  43245. private _coloredMaterial;
  43246. private _hoverMaterial;
  43247. /**
  43248. * Creates an AxisScaleGizmo
  43249. * @param gizmoLayer The utility layer the gizmo will be added to
  43250. * @param dragAxis The axis which the gizmo will be able to scale on
  43251. * @param color The color of the gizmo
  43252. */
  43253. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  43254. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43255. /**
  43256. * If the gizmo is enabled
  43257. */
  43258. isEnabled: boolean;
  43259. /**
  43260. * Disposes of the gizmo
  43261. */
  43262. dispose(): void;
  43263. /**
  43264. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43265. * @param mesh The mesh to replace the default mesh of the gizmo
  43266. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43267. */
  43268. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43269. }
  43270. }
  43271. declare module BABYLON {
  43272. /**
  43273. * Bounding box gizmo
  43274. */
  43275. export class BoundingBoxGizmo extends Gizmo {
  43276. private _lineBoundingBox;
  43277. private _rotateSpheresParent;
  43278. private _scaleBoxesParent;
  43279. private _boundingDimensions;
  43280. private _renderObserver;
  43281. private _pointerObserver;
  43282. private _scaleDragSpeed;
  43283. private _tmpQuaternion;
  43284. private _tmpVector;
  43285. private _tmpRotationMatrix;
  43286. /**
  43287. * 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)
  43288. */
  43289. ignoreChildren: boolean;
  43290. /**
  43291. * 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)
  43292. */
  43293. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43294. /**
  43295. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43296. */
  43297. rotationSphereSize: number;
  43298. /**
  43299. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43300. */
  43301. scaleBoxSize: number;
  43302. /**
  43303. * 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)
  43304. */
  43305. fixedDragMeshScreenSize: boolean;
  43306. /**
  43307. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43308. */
  43309. fixedDragMeshScreenSizeDistanceFactor: number;
  43310. /**
  43311. * Fired when a rotation sphere or scale box is dragged
  43312. */
  43313. onDragStartObservable: Observable<{}>;
  43314. /**
  43315. * Fired when a scale box is dragged
  43316. */
  43317. onScaleBoxDragObservable: Observable<{}>;
  43318. /**
  43319. * Fired when a scale box drag is ended
  43320. */
  43321. onScaleBoxDragEndObservable: Observable<{}>;
  43322. /**
  43323. * Fired when a rotation sphere is dragged
  43324. */
  43325. onRotationSphereDragObservable: Observable<{}>;
  43326. /**
  43327. * Fired when a rotation sphere drag is ended
  43328. */
  43329. onRotationSphereDragEndObservable: Observable<{}>;
  43330. /**
  43331. * 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)
  43332. */
  43333. scalePivot: Nullable<Vector3>;
  43334. /**
  43335. * Mesh used as a pivot to rotate the attached mesh
  43336. */
  43337. private _anchorMesh;
  43338. private _existingMeshScale;
  43339. private _dragMesh;
  43340. private pointerDragBehavior;
  43341. private coloredMaterial;
  43342. private hoverColoredMaterial;
  43343. /**
  43344. * Sets the color of the bounding box gizmo
  43345. * @param color the color to set
  43346. */
  43347. setColor(color: Color3): void;
  43348. /**
  43349. * Creates an BoundingBoxGizmo
  43350. * @param gizmoLayer The utility layer the gizmo will be added to
  43351. * @param color The color of the gizmo
  43352. */
  43353. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43354. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43355. private _selectNode;
  43356. /**
  43357. * Updates the bounding box information for the Gizmo
  43358. */
  43359. updateBoundingBox(): void;
  43360. private _updateRotationSpheres;
  43361. private _updateScaleBoxes;
  43362. /**
  43363. * Enables rotation on the specified axis and disables rotation on the others
  43364. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43365. */
  43366. setEnabledRotationAxis(axis: string): void;
  43367. /**
  43368. * Enables/disables scaling
  43369. * @param enable if scaling should be enabled
  43370. */
  43371. setEnabledScaling(enable: boolean): void;
  43372. private _updateDummy;
  43373. /**
  43374. * Enables a pointer drag behavior on the bounding box of the gizmo
  43375. */
  43376. enableDragBehavior(): void;
  43377. /**
  43378. * Disposes of the gizmo
  43379. */
  43380. dispose(): void;
  43381. /**
  43382. * 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)
  43383. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43384. * @returns the bounding box mesh with the passed in mesh as a child
  43385. */
  43386. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43387. /**
  43388. * CustomMeshes are not supported by this gizmo
  43389. * @param mesh The mesh to replace the default mesh of the gizmo
  43390. */
  43391. setCustomMesh(mesh: Mesh): void;
  43392. }
  43393. }
  43394. declare module BABYLON {
  43395. /**
  43396. * Single plane rotation gizmo
  43397. */
  43398. export class PlaneRotationGizmo extends Gizmo {
  43399. /**
  43400. * Drag behavior responsible for the gizmos dragging interactions
  43401. */
  43402. dragBehavior: PointerDragBehavior;
  43403. private _pointerObserver;
  43404. /**
  43405. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43406. */
  43407. snapDistance: number;
  43408. /**
  43409. * Event that fires each time the gizmo snaps to a new location.
  43410. * * snapDistance is the the change in distance
  43411. */
  43412. onSnapObservable: Observable<{
  43413. snapDistance: number;
  43414. }>;
  43415. private _isEnabled;
  43416. private _parent;
  43417. /**
  43418. * Creates a PlaneRotationGizmo
  43419. * @param gizmoLayer The utility layer the gizmo will be added to
  43420. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43421. * @param color The color of the gizmo
  43422. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43423. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43424. */
  43425. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  43426. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43427. /**
  43428. * If the gizmo is enabled
  43429. */
  43430. isEnabled: boolean;
  43431. /**
  43432. * Disposes of the gizmo
  43433. */
  43434. dispose(): void;
  43435. }
  43436. }
  43437. declare module BABYLON {
  43438. /**
  43439. * Gizmo that enables rotating a mesh along 3 axis
  43440. */
  43441. export class RotationGizmo extends Gizmo {
  43442. /**
  43443. * Internal gizmo used for interactions on the x axis
  43444. */
  43445. xGizmo: PlaneRotationGizmo;
  43446. /**
  43447. * Internal gizmo used for interactions on the y axis
  43448. */
  43449. yGizmo: PlaneRotationGizmo;
  43450. /**
  43451. * Internal gizmo used for interactions on the z axis
  43452. */
  43453. zGizmo: PlaneRotationGizmo;
  43454. /** Fires an event when any of it's sub gizmos are dragged */
  43455. onDragStartObservable: Observable<unknown>;
  43456. /** Fires an event when any of it's sub gizmos are released from dragging */
  43457. onDragEndObservable: Observable<unknown>;
  43458. private _meshAttached;
  43459. attachedMesh: Nullable<AbstractMesh>;
  43460. /**
  43461. * Creates a RotationGizmo
  43462. * @param gizmoLayer The utility layer the gizmo will be added to
  43463. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43464. * @param useEulerRotation Use and update Euler angle instead of quaternion
  43465. */
  43466. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  43467. updateGizmoRotationToMatchAttachedMesh: boolean;
  43468. /**
  43469. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43470. */
  43471. snapDistance: number;
  43472. /**
  43473. * Ratio for the scale of the gizmo (Default: 1)
  43474. */
  43475. scaleRatio: number;
  43476. /**
  43477. * Disposes of the gizmo
  43478. */
  43479. dispose(): void;
  43480. /**
  43481. * CustomMeshes are not supported by this gizmo
  43482. * @param mesh The mesh to replace the default mesh of the gizmo
  43483. */
  43484. setCustomMesh(mesh: Mesh): void;
  43485. }
  43486. }
  43487. declare module BABYLON {
  43488. /**
  43489. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  43490. */
  43491. export class GizmoManager implements IDisposable {
  43492. private scene;
  43493. /**
  43494. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  43495. */
  43496. gizmos: {
  43497. positionGizmo: Nullable<PositionGizmo>;
  43498. rotationGizmo: Nullable<RotationGizmo>;
  43499. scaleGizmo: Nullable<ScaleGizmo>;
  43500. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  43501. };
  43502. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  43503. clearGizmoOnEmptyPointerEvent: boolean;
  43504. /** Fires an event when the manager is attached to a mesh */
  43505. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  43506. private _gizmosEnabled;
  43507. private _pointerObserver;
  43508. private _attachedMesh;
  43509. private _boundingBoxColor;
  43510. private _defaultUtilityLayer;
  43511. private _defaultKeepDepthUtilityLayer;
  43512. /**
  43513. * When bounding box gizmo is enabled, this can be used to track drag/end events
  43514. */
  43515. boundingBoxDragBehavior: SixDofDragBehavior;
  43516. /**
  43517. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  43518. */
  43519. attachableMeshes: Nullable<Array<AbstractMesh>>;
  43520. /**
  43521. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  43522. */
  43523. usePointerToAttachGizmos: boolean;
  43524. /**
  43525. * Utility layer that the bounding box gizmo belongs to
  43526. */
  43527. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  43528. /**
  43529. * Utility layer that all gizmos besides bounding box belong to
  43530. */
  43531. readonly utilityLayer: UtilityLayerRenderer;
  43532. /**
  43533. * Instatiates a gizmo manager
  43534. * @param scene the scene to overlay the gizmos on top of
  43535. */
  43536. constructor(scene: Scene);
  43537. /**
  43538. * Attaches a set of gizmos to the specified mesh
  43539. * @param mesh The mesh the gizmo's should be attached to
  43540. */
  43541. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  43542. /**
  43543. * If the position gizmo is enabled
  43544. */
  43545. positionGizmoEnabled: boolean;
  43546. /**
  43547. * If the rotation gizmo is enabled
  43548. */
  43549. rotationGizmoEnabled: boolean;
  43550. /**
  43551. * If the scale gizmo is enabled
  43552. */
  43553. scaleGizmoEnabled: boolean;
  43554. /**
  43555. * If the boundingBox gizmo is enabled
  43556. */
  43557. boundingBoxGizmoEnabled: boolean;
  43558. /**
  43559. * Disposes of the gizmo manager
  43560. */
  43561. dispose(): void;
  43562. }
  43563. }
  43564. declare module BABYLON {
  43565. /**
  43566. * A directional light is defined by a direction (what a surprise!).
  43567. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  43568. * 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.
  43569. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43570. */
  43571. export class DirectionalLight extends ShadowLight {
  43572. private _shadowFrustumSize;
  43573. /**
  43574. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  43575. */
  43576. /**
  43577. * Specifies a fix frustum size for the shadow generation.
  43578. */
  43579. shadowFrustumSize: number;
  43580. private _shadowOrthoScale;
  43581. /**
  43582. * Gets the shadow projection scale against the optimal computed one.
  43583. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43584. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43585. */
  43586. /**
  43587. * Sets the shadow projection scale against the optimal computed one.
  43588. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  43589. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  43590. */
  43591. shadowOrthoScale: number;
  43592. /**
  43593. * Automatically compute the projection matrix to best fit (including all the casters)
  43594. * on each frame.
  43595. */
  43596. autoUpdateExtends: boolean;
  43597. private _orthoLeft;
  43598. private _orthoRight;
  43599. private _orthoTop;
  43600. private _orthoBottom;
  43601. /**
  43602. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  43603. * The directional light is emitted from everywhere in the given direction.
  43604. * It can cast shadows.
  43605. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43606. * @param name The friendly name of the light
  43607. * @param direction The direction of the light
  43608. * @param scene The scene the light belongs to
  43609. */
  43610. constructor(name: string, direction: Vector3, scene: Scene);
  43611. /**
  43612. * Returns the string "DirectionalLight".
  43613. * @return The class name
  43614. */
  43615. getClassName(): string;
  43616. /**
  43617. * Returns the integer 1.
  43618. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43619. */
  43620. getTypeID(): number;
  43621. /**
  43622. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  43623. * Returns the DirectionalLight Shadow projection matrix.
  43624. */
  43625. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43626. /**
  43627. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  43628. * Returns the DirectionalLight Shadow projection matrix.
  43629. */
  43630. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  43631. /**
  43632. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  43633. * Returns the DirectionalLight Shadow projection matrix.
  43634. */
  43635. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43636. protected _buildUniformLayout(): void;
  43637. /**
  43638. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  43639. * @param effect The effect to update
  43640. * @param lightIndex The index of the light in the effect to update
  43641. * @returns The directional light
  43642. */
  43643. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  43644. /**
  43645. * Gets the minZ used for shadow according to both the scene and the light.
  43646. *
  43647. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43648. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43649. * @param activeCamera The camera we are returning the min for
  43650. * @returns the depth min z
  43651. */
  43652. getDepthMinZ(activeCamera: Camera): number;
  43653. /**
  43654. * Gets the maxZ used for shadow according to both the scene and the light.
  43655. *
  43656. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  43657. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  43658. * @param activeCamera The camera we are returning the max for
  43659. * @returns the depth max z
  43660. */
  43661. getDepthMaxZ(activeCamera: Camera): number;
  43662. /**
  43663. * Prepares the list of defines specific to the light type.
  43664. * @param defines the list of defines
  43665. * @param lightIndex defines the index of the light for the effect
  43666. */
  43667. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43668. }
  43669. }
  43670. declare module BABYLON {
  43671. /**
  43672. * Class containing static functions to help procedurally build meshes
  43673. */
  43674. export class HemisphereBuilder {
  43675. /**
  43676. * Creates a hemisphere mesh
  43677. * @param name defines the name of the mesh
  43678. * @param options defines the options used to create the mesh
  43679. * @param scene defines the hosting scene
  43680. * @returns the hemisphere mesh
  43681. */
  43682. static CreateHemisphere(name: string, options: {
  43683. segments?: number;
  43684. diameter?: number;
  43685. sideOrientation?: number;
  43686. }, scene: any): Mesh;
  43687. }
  43688. }
  43689. declare module BABYLON {
  43690. /**
  43691. * A spot light is defined by a position, a direction, an angle, and an exponent.
  43692. * These values define a cone of light starting from the position, emitting toward the direction.
  43693. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  43694. * and the exponent defines the speed of the decay of the light with distance (reach).
  43695. * Documentation: https://doc.babylonjs.com/babylon101/lights
  43696. */
  43697. export class SpotLight extends ShadowLight {
  43698. private _angle;
  43699. private _innerAngle;
  43700. private _cosHalfAngle;
  43701. private _lightAngleScale;
  43702. private _lightAngleOffset;
  43703. /**
  43704. * Gets the cone angle of the spot light in Radians.
  43705. */
  43706. /**
  43707. * Sets the cone angle of the spot light in Radians.
  43708. */
  43709. angle: number;
  43710. /**
  43711. * Only used in gltf falloff mode, this defines the angle where
  43712. * the directional falloff will start before cutting at angle which could be seen
  43713. * as outer angle.
  43714. */
  43715. /**
  43716. * Only used in gltf falloff mode, this defines the angle where
  43717. * the directional falloff will start before cutting at angle which could be seen
  43718. * as outer angle.
  43719. */
  43720. innerAngle: number;
  43721. private _shadowAngleScale;
  43722. /**
  43723. * Allows scaling the angle of the light for shadow generation only.
  43724. */
  43725. /**
  43726. * Allows scaling the angle of the light for shadow generation only.
  43727. */
  43728. shadowAngleScale: number;
  43729. /**
  43730. * The light decay speed with the distance from the emission spot.
  43731. */
  43732. exponent: number;
  43733. private _projectionTextureMatrix;
  43734. /**
  43735. * Allows reading the projecton texture
  43736. */
  43737. readonly projectionTextureMatrix: Matrix;
  43738. protected _projectionTextureLightNear: number;
  43739. /**
  43740. * Gets the near clip of the Spotlight for texture projection.
  43741. */
  43742. /**
  43743. * Sets the near clip of the Spotlight for texture projection.
  43744. */
  43745. projectionTextureLightNear: number;
  43746. protected _projectionTextureLightFar: number;
  43747. /**
  43748. * Gets the far clip of the Spotlight for texture projection.
  43749. */
  43750. /**
  43751. * Sets the far clip of the Spotlight for texture projection.
  43752. */
  43753. projectionTextureLightFar: number;
  43754. protected _projectionTextureUpDirection: Vector3;
  43755. /**
  43756. * Gets the Up vector of the Spotlight for texture projection.
  43757. */
  43758. /**
  43759. * Sets the Up vector of the Spotlight for texture projection.
  43760. */
  43761. projectionTextureUpDirection: Vector3;
  43762. private _projectionTexture;
  43763. /**
  43764. * Gets the projection texture of the light.
  43765. */
  43766. /**
  43767. * Sets the projection texture of the light.
  43768. */
  43769. projectionTexture: Nullable<BaseTexture>;
  43770. private _projectionTextureViewLightDirty;
  43771. private _projectionTextureProjectionLightDirty;
  43772. private _projectionTextureDirty;
  43773. private _projectionTextureViewTargetVector;
  43774. private _projectionTextureViewLightMatrix;
  43775. private _projectionTextureProjectionLightMatrix;
  43776. private _projectionTextureScalingMatrix;
  43777. /**
  43778. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  43779. * It can cast shadows.
  43780. * Documentation : https://doc.babylonjs.com/babylon101/lights
  43781. * @param name The light friendly name
  43782. * @param position The position of the spot light in the scene
  43783. * @param direction The direction of the light in the scene
  43784. * @param angle The cone angle of the light in Radians
  43785. * @param exponent The light decay speed with the distance from the emission spot
  43786. * @param scene The scene the lights belongs to
  43787. */
  43788. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  43789. /**
  43790. * Returns the string "SpotLight".
  43791. * @returns the class name
  43792. */
  43793. getClassName(): string;
  43794. /**
  43795. * Returns the integer 2.
  43796. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  43797. */
  43798. getTypeID(): number;
  43799. /**
  43800. * Overrides the direction setter to recompute the projection texture view light Matrix.
  43801. */
  43802. protected _setDirection(value: Vector3): void;
  43803. /**
  43804. * Overrides the position setter to recompute the projection texture view light Matrix.
  43805. */
  43806. protected _setPosition(value: Vector3): void;
  43807. /**
  43808. * 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.
  43809. * Returns the SpotLight.
  43810. */
  43811. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  43812. protected _computeProjectionTextureViewLightMatrix(): void;
  43813. protected _computeProjectionTextureProjectionLightMatrix(): void;
  43814. /**
  43815. * Main function for light texture projection matrix computing.
  43816. */
  43817. protected _computeProjectionTextureMatrix(): void;
  43818. protected _buildUniformLayout(): void;
  43819. private _computeAngleValues;
  43820. /**
  43821. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  43822. * @param effect The effect to update
  43823. * @param lightIndex The index of the light in the effect to update
  43824. * @returns The spot light
  43825. */
  43826. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  43827. /**
  43828. * Disposes the light and the associated resources.
  43829. */
  43830. dispose(): void;
  43831. /**
  43832. * Prepares the list of defines specific to the light type.
  43833. * @param defines the list of defines
  43834. * @param lightIndex defines the index of the light for the effect
  43835. */
  43836. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  43837. }
  43838. }
  43839. declare module BABYLON {
  43840. /**
  43841. * Gizmo that enables viewing a light
  43842. */
  43843. export class LightGizmo extends Gizmo {
  43844. private _lightMesh;
  43845. private _material;
  43846. private cachedPosition;
  43847. private cachedForward;
  43848. /**
  43849. * Creates a LightGizmo
  43850. * @param gizmoLayer The utility layer the gizmo will be added to
  43851. */
  43852. constructor(gizmoLayer?: UtilityLayerRenderer);
  43853. private _light;
  43854. /**
  43855. * The light that the gizmo is attached to
  43856. */
  43857. light: Nullable<Light>;
  43858. /**
  43859. * Gets the material used to render the light gizmo
  43860. */
  43861. readonly material: StandardMaterial;
  43862. /**
  43863. * @hidden
  43864. * Updates the gizmo to match the attached mesh's position/rotation
  43865. */
  43866. protected _update(): void;
  43867. private static _Scale;
  43868. /**
  43869. * Creates the lines for a light mesh
  43870. */
  43871. private static _createLightLines;
  43872. /**
  43873. * Disposes of the light gizmo
  43874. */
  43875. dispose(): void;
  43876. private static _CreateHemisphericLightMesh;
  43877. private static _CreatePointLightMesh;
  43878. private static _CreateSpotLightMesh;
  43879. private static _CreateDirectionalLightMesh;
  43880. }
  43881. }
  43882. declare module BABYLON {
  43883. /** @hidden */
  43884. export var backgroundFragmentDeclaration: {
  43885. name: string;
  43886. shader: string;
  43887. };
  43888. }
  43889. declare module BABYLON {
  43890. /** @hidden */
  43891. export var backgroundUboDeclaration: {
  43892. name: string;
  43893. shader: string;
  43894. };
  43895. }
  43896. declare module BABYLON {
  43897. /** @hidden */
  43898. export var backgroundPixelShader: {
  43899. name: string;
  43900. shader: string;
  43901. };
  43902. }
  43903. declare module BABYLON {
  43904. /** @hidden */
  43905. export var backgroundVertexDeclaration: {
  43906. name: string;
  43907. shader: string;
  43908. };
  43909. }
  43910. declare module BABYLON {
  43911. /** @hidden */
  43912. export var backgroundVertexShader: {
  43913. name: string;
  43914. shader: string;
  43915. };
  43916. }
  43917. declare module BABYLON {
  43918. /**
  43919. * Background material used to create an efficient environement around your scene.
  43920. */
  43921. export class BackgroundMaterial extends PushMaterial {
  43922. /**
  43923. * Standard reflectance value at parallel view angle.
  43924. */
  43925. static StandardReflectance0: number;
  43926. /**
  43927. * Standard reflectance value at grazing angle.
  43928. */
  43929. static StandardReflectance90: number;
  43930. protected _primaryColor: Color3;
  43931. /**
  43932. * Key light Color (multiply against the environement texture)
  43933. */
  43934. primaryColor: Color3;
  43935. protected __perceptualColor: Nullable<Color3>;
  43936. /**
  43937. * Experimental Internal Use Only.
  43938. *
  43939. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  43940. * This acts as a helper to set the primary color to a more "human friendly" value.
  43941. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  43942. * output color as close as possible from the chosen value.
  43943. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  43944. * part of lighting setup.)
  43945. */ private _perceptualColor: Nullable<Color3>;
  43946. protected _primaryColorShadowLevel: float;
  43947. /**
  43948. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  43949. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  43950. */
  43951. primaryColorShadowLevel: float;
  43952. protected _primaryColorHighlightLevel: float;
  43953. /**
  43954. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  43955. * The primary color is used at the level chosen to define what the white area would look.
  43956. */
  43957. primaryColorHighlightLevel: float;
  43958. protected _reflectionTexture: Nullable<BaseTexture>;
  43959. /**
  43960. * Reflection Texture used in the material.
  43961. * Should be author in a specific way for the best result (refer to the documentation).
  43962. */
  43963. reflectionTexture: Nullable<BaseTexture>;
  43964. protected _reflectionBlur: float;
  43965. /**
  43966. * Reflection Texture level of blur.
  43967. *
  43968. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  43969. * texture twice.
  43970. */
  43971. reflectionBlur: float;
  43972. protected _diffuseTexture: Nullable<BaseTexture>;
  43973. /**
  43974. * Diffuse Texture used in the material.
  43975. * Should be author in a specific way for the best result (refer to the documentation).
  43976. */
  43977. diffuseTexture: Nullable<BaseTexture>;
  43978. protected _shadowLights: Nullable<IShadowLight[]>;
  43979. /**
  43980. * Specify the list of lights casting shadow on the material.
  43981. * All scene shadow lights will be included if null.
  43982. */
  43983. shadowLights: Nullable<IShadowLight[]>;
  43984. protected _shadowLevel: float;
  43985. /**
  43986. * Helps adjusting the shadow to a softer level if required.
  43987. * 0 means black shadows and 1 means no shadows.
  43988. */
  43989. shadowLevel: float;
  43990. protected _sceneCenter: Vector3;
  43991. /**
  43992. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  43993. * It is usually zero but might be interesting to modify according to your setup.
  43994. */
  43995. sceneCenter: Vector3;
  43996. protected _opacityFresnel: boolean;
  43997. /**
  43998. * This helps specifying that the material is falling off to the sky box at grazing angle.
  43999. * This helps ensuring a nice transition when the camera goes under the ground.
  44000. */
  44001. opacityFresnel: boolean;
  44002. protected _reflectionFresnel: boolean;
  44003. /**
  44004. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44005. * This helps adding a mirror texture on the ground.
  44006. */
  44007. reflectionFresnel: boolean;
  44008. protected _reflectionFalloffDistance: number;
  44009. /**
  44010. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44011. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44012. */
  44013. reflectionFalloffDistance: number;
  44014. protected _reflectionAmount: number;
  44015. /**
  44016. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44017. */
  44018. reflectionAmount: number;
  44019. protected _reflectionReflectance0: number;
  44020. /**
  44021. * This specifies the weight of the reflection at grazing angle.
  44022. */
  44023. reflectionReflectance0: number;
  44024. protected _reflectionReflectance90: number;
  44025. /**
  44026. * This specifies the weight of the reflection at a perpendicular point of view.
  44027. */
  44028. reflectionReflectance90: number;
  44029. /**
  44030. * Sets the reflection reflectance fresnel values according to the default standard
  44031. * empirically know to work well :-)
  44032. */
  44033. reflectionStandardFresnelWeight: number;
  44034. protected _useRGBColor: boolean;
  44035. /**
  44036. * Helps to directly use the maps channels instead of their level.
  44037. */
  44038. useRGBColor: boolean;
  44039. protected _enableNoise: boolean;
  44040. /**
  44041. * This helps reducing the banding effect that could occur on the background.
  44042. */
  44043. enableNoise: boolean;
  44044. /**
  44045. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44046. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44047. * Recommended to be keep at 1.0 except for special cases.
  44048. */
  44049. fovMultiplier: number;
  44050. private _fovMultiplier;
  44051. /**
  44052. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44053. */
  44054. useEquirectangularFOV: boolean;
  44055. private _maxSimultaneousLights;
  44056. /**
  44057. * Number of Simultaneous lights allowed on the material.
  44058. */
  44059. maxSimultaneousLights: int;
  44060. /**
  44061. * Default configuration related to image processing available in the Background Material.
  44062. */
  44063. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44064. /**
  44065. * Keep track of the image processing observer to allow dispose and replace.
  44066. */
  44067. private _imageProcessingObserver;
  44068. /**
  44069. * Attaches a new image processing configuration to the PBR Material.
  44070. * @param configuration (if null the scene configuration will be use)
  44071. */
  44072. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44073. /**
  44074. * Gets the image processing configuration used either in this material.
  44075. */
  44076. /**
  44077. * Sets the Default image processing configuration used either in the this material.
  44078. *
  44079. * If sets to null, the scene one is in use.
  44080. */
  44081. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44082. /**
  44083. * Gets wether the color curves effect is enabled.
  44084. */
  44085. /**
  44086. * Sets wether the color curves effect is enabled.
  44087. */
  44088. cameraColorCurvesEnabled: boolean;
  44089. /**
  44090. * Gets wether the color grading effect is enabled.
  44091. */
  44092. /**
  44093. * Gets wether the color grading effect is enabled.
  44094. */
  44095. cameraColorGradingEnabled: boolean;
  44096. /**
  44097. * Gets wether tonemapping is enabled or not.
  44098. */
  44099. /**
  44100. * Sets wether tonemapping is enabled or not
  44101. */
  44102. cameraToneMappingEnabled: boolean;
  44103. /**
  44104. * The camera exposure used on this material.
  44105. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44106. * This corresponds to a photographic exposure.
  44107. */
  44108. /**
  44109. * The camera exposure used on this material.
  44110. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44111. * This corresponds to a photographic exposure.
  44112. */
  44113. cameraExposure: float;
  44114. /**
  44115. * Gets The camera contrast used on this material.
  44116. */
  44117. /**
  44118. * Sets The camera contrast used on this material.
  44119. */
  44120. cameraContrast: float;
  44121. /**
  44122. * Gets the Color Grading 2D Lookup Texture.
  44123. */
  44124. /**
  44125. * Sets the Color Grading 2D Lookup Texture.
  44126. */
  44127. cameraColorGradingTexture: Nullable<BaseTexture>;
  44128. /**
  44129. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44130. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44131. * 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;
  44132. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44133. */
  44134. /**
  44135. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44136. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44137. * 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;
  44138. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44139. */
  44140. cameraColorCurves: Nullable<ColorCurves>;
  44141. /**
  44142. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44143. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44144. */
  44145. switchToBGR: boolean;
  44146. private _renderTargets;
  44147. private _reflectionControls;
  44148. private _white;
  44149. private _primaryShadowColor;
  44150. private _primaryHighlightColor;
  44151. /**
  44152. * Instantiates a Background Material in the given scene
  44153. * @param name The friendly name of the material
  44154. * @param scene The scene to add the material to
  44155. */
  44156. constructor(name: string, scene: Scene);
  44157. /**
  44158. * Gets a boolean indicating that current material needs to register RTT
  44159. */
  44160. readonly hasRenderTargetTextures: boolean;
  44161. /**
  44162. * The entire material has been created in order to prevent overdraw.
  44163. * @returns false
  44164. */
  44165. needAlphaTesting(): boolean;
  44166. /**
  44167. * The entire material has been created in order to prevent overdraw.
  44168. * @returns true if blending is enable
  44169. */
  44170. needAlphaBlending(): boolean;
  44171. /**
  44172. * Checks wether the material is ready to be rendered for a given mesh.
  44173. * @param mesh The mesh to render
  44174. * @param subMesh The submesh to check against
  44175. * @param useInstances Specify wether or not the material is used with instances
  44176. * @returns true if all the dependencies are ready (Textures, Effects...)
  44177. */
  44178. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44179. /**
  44180. * Compute the primary color according to the chosen perceptual color.
  44181. */
  44182. private _computePrimaryColorFromPerceptualColor;
  44183. /**
  44184. * Compute the highlights and shadow colors according to their chosen levels.
  44185. */
  44186. private _computePrimaryColors;
  44187. /**
  44188. * Build the uniform buffer used in the material.
  44189. */
  44190. buildUniformLayout(): void;
  44191. /**
  44192. * Unbind the material.
  44193. */
  44194. unbind(): void;
  44195. /**
  44196. * Bind only the world matrix to the material.
  44197. * @param world The world matrix to bind.
  44198. */
  44199. bindOnlyWorldMatrix(world: Matrix): void;
  44200. /**
  44201. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44202. * @param world The world matrix to bind.
  44203. * @param subMesh The submesh to bind for.
  44204. */
  44205. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44206. /**
  44207. * Dispose the material.
  44208. * @param forceDisposeEffect Force disposal of the associated effect.
  44209. * @param forceDisposeTextures Force disposal of the associated textures.
  44210. */
  44211. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  44212. /**
  44213. * Clones the material.
  44214. * @param name The cloned name.
  44215. * @returns The cloned material.
  44216. */
  44217. clone(name: string): BackgroundMaterial;
  44218. /**
  44219. * Serializes the current material to its JSON representation.
  44220. * @returns The JSON representation.
  44221. */
  44222. serialize(): any;
  44223. /**
  44224. * Gets the class name of the material
  44225. * @returns "BackgroundMaterial"
  44226. */
  44227. getClassName(): string;
  44228. /**
  44229. * Parse a JSON input to create back a background material.
  44230. * @param source The JSON data to parse
  44231. * @param scene The scene to create the parsed material in
  44232. * @param rootUrl The root url of the assets the material depends upon
  44233. * @returns the instantiated BackgroundMaterial.
  44234. */
  44235. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  44236. }
  44237. }
  44238. declare module BABYLON {
  44239. /**
  44240. * Represents the different options available during the creation of
  44241. * a Environment helper.
  44242. *
  44243. * This can control the default ground, skybox and image processing setup of your scene.
  44244. */
  44245. export interface IEnvironmentHelperOptions {
  44246. /**
  44247. * Specifies wether or not to create a ground.
  44248. * True by default.
  44249. */
  44250. createGround: boolean;
  44251. /**
  44252. * Specifies the ground size.
  44253. * 15 by default.
  44254. */
  44255. groundSize: number;
  44256. /**
  44257. * The texture used on the ground for the main color.
  44258. * Comes from the BabylonJS CDN by default.
  44259. *
  44260. * Remarks: Can be either a texture or a url.
  44261. */
  44262. groundTexture: string | BaseTexture;
  44263. /**
  44264. * The color mixed in the ground texture by default.
  44265. * BabylonJS clearColor by default.
  44266. */
  44267. groundColor: Color3;
  44268. /**
  44269. * Specifies the ground opacity.
  44270. * 1 by default.
  44271. */
  44272. groundOpacity: number;
  44273. /**
  44274. * Enables the ground to receive shadows.
  44275. * True by default.
  44276. */
  44277. enableGroundShadow: boolean;
  44278. /**
  44279. * Helps preventing the shadow to be fully black on the ground.
  44280. * 0.5 by default.
  44281. */
  44282. groundShadowLevel: number;
  44283. /**
  44284. * Creates a mirror texture attach to the ground.
  44285. * false by default.
  44286. */
  44287. enableGroundMirror: boolean;
  44288. /**
  44289. * Specifies the ground mirror size ratio.
  44290. * 0.3 by default as the default kernel is 64.
  44291. */
  44292. groundMirrorSizeRatio: number;
  44293. /**
  44294. * Specifies the ground mirror blur kernel size.
  44295. * 64 by default.
  44296. */
  44297. groundMirrorBlurKernel: number;
  44298. /**
  44299. * Specifies the ground mirror visibility amount.
  44300. * 1 by default
  44301. */
  44302. groundMirrorAmount: number;
  44303. /**
  44304. * Specifies the ground mirror reflectance weight.
  44305. * This uses the standard weight of the background material to setup the fresnel effect
  44306. * of the mirror.
  44307. * 1 by default.
  44308. */
  44309. groundMirrorFresnelWeight: number;
  44310. /**
  44311. * Specifies the ground mirror Falloff distance.
  44312. * This can helps reducing the size of the reflection.
  44313. * 0 by Default.
  44314. */
  44315. groundMirrorFallOffDistance: number;
  44316. /**
  44317. * Specifies the ground mirror texture type.
  44318. * Unsigned Int by Default.
  44319. */
  44320. groundMirrorTextureType: number;
  44321. /**
  44322. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  44323. * the shown objects.
  44324. */
  44325. groundYBias: number;
  44326. /**
  44327. * Specifies wether or not to create a skybox.
  44328. * True by default.
  44329. */
  44330. createSkybox: boolean;
  44331. /**
  44332. * Specifies the skybox size.
  44333. * 20 by default.
  44334. */
  44335. skyboxSize: number;
  44336. /**
  44337. * The texture used on the skybox for the main color.
  44338. * Comes from the BabylonJS CDN by default.
  44339. *
  44340. * Remarks: Can be either a texture or a url.
  44341. */
  44342. skyboxTexture: string | BaseTexture;
  44343. /**
  44344. * The color mixed in the skybox texture by default.
  44345. * BabylonJS clearColor by default.
  44346. */
  44347. skyboxColor: Color3;
  44348. /**
  44349. * The background rotation around the Y axis of the scene.
  44350. * This helps aligning the key lights of your scene with the background.
  44351. * 0 by default.
  44352. */
  44353. backgroundYRotation: number;
  44354. /**
  44355. * Compute automatically the size of the elements to best fit with the scene.
  44356. */
  44357. sizeAuto: boolean;
  44358. /**
  44359. * Default position of the rootMesh if autoSize is not true.
  44360. */
  44361. rootPosition: Vector3;
  44362. /**
  44363. * Sets up the image processing in the scene.
  44364. * true by default.
  44365. */
  44366. setupImageProcessing: boolean;
  44367. /**
  44368. * The texture used as your environment texture in the scene.
  44369. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  44370. *
  44371. * Remarks: Can be either a texture or a url.
  44372. */
  44373. environmentTexture: string | BaseTexture;
  44374. /**
  44375. * The value of the exposure to apply to the scene.
  44376. * 0.6 by default if setupImageProcessing is true.
  44377. */
  44378. cameraExposure: number;
  44379. /**
  44380. * The value of the contrast to apply to the scene.
  44381. * 1.6 by default if setupImageProcessing is true.
  44382. */
  44383. cameraContrast: number;
  44384. /**
  44385. * Specifies wether or not tonemapping should be enabled in the scene.
  44386. * true by default if setupImageProcessing is true.
  44387. */
  44388. toneMappingEnabled: boolean;
  44389. }
  44390. /**
  44391. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  44392. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  44393. * It also helps with the default setup of your imageProcessing configuration.
  44394. */
  44395. export class EnvironmentHelper {
  44396. /**
  44397. * Default ground texture URL.
  44398. */
  44399. private static _groundTextureCDNUrl;
  44400. /**
  44401. * Default skybox texture URL.
  44402. */
  44403. private static _skyboxTextureCDNUrl;
  44404. /**
  44405. * Default environment texture URL.
  44406. */
  44407. private static _environmentTextureCDNUrl;
  44408. /**
  44409. * Creates the default options for the helper.
  44410. */
  44411. private static _getDefaultOptions;
  44412. private _rootMesh;
  44413. /**
  44414. * Gets the root mesh created by the helper.
  44415. */
  44416. readonly rootMesh: Mesh;
  44417. private _skybox;
  44418. /**
  44419. * Gets the skybox created by the helper.
  44420. */
  44421. readonly skybox: Nullable<Mesh>;
  44422. private _skyboxTexture;
  44423. /**
  44424. * Gets the skybox texture created by the helper.
  44425. */
  44426. readonly skyboxTexture: Nullable<BaseTexture>;
  44427. private _skyboxMaterial;
  44428. /**
  44429. * Gets the skybox material created by the helper.
  44430. */
  44431. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  44432. private _ground;
  44433. /**
  44434. * Gets the ground mesh created by the helper.
  44435. */
  44436. readonly ground: Nullable<Mesh>;
  44437. private _groundTexture;
  44438. /**
  44439. * Gets the ground texture created by the helper.
  44440. */
  44441. readonly groundTexture: Nullable<BaseTexture>;
  44442. private _groundMirror;
  44443. /**
  44444. * Gets the ground mirror created by the helper.
  44445. */
  44446. readonly groundMirror: Nullable<MirrorTexture>;
  44447. /**
  44448. * Gets the ground mirror render list to helps pushing the meshes
  44449. * you wish in the ground reflection.
  44450. */
  44451. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  44452. private _groundMaterial;
  44453. /**
  44454. * Gets the ground material created by the helper.
  44455. */
  44456. readonly groundMaterial: Nullable<BackgroundMaterial>;
  44457. /**
  44458. * Stores the creation options.
  44459. */
  44460. private readonly _scene;
  44461. private _options;
  44462. /**
  44463. * This observable will be notified with any error during the creation of the environment,
  44464. * mainly texture creation errors.
  44465. */
  44466. onErrorObservable: Observable<{
  44467. message?: string;
  44468. exception?: any;
  44469. }>;
  44470. /**
  44471. * constructor
  44472. * @param options Defines the options we want to customize the helper
  44473. * @param scene The scene to add the material to
  44474. */
  44475. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  44476. /**
  44477. * Updates the background according to the new options
  44478. * @param options
  44479. */
  44480. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  44481. /**
  44482. * Sets the primary color of all the available elements.
  44483. * @param color the main color to affect to the ground and the background
  44484. */
  44485. setMainColor(color: Color3): void;
  44486. /**
  44487. * Setup the image processing according to the specified options.
  44488. */
  44489. private _setupImageProcessing;
  44490. /**
  44491. * Setup the environment texture according to the specified options.
  44492. */
  44493. private _setupEnvironmentTexture;
  44494. /**
  44495. * Setup the background according to the specified options.
  44496. */
  44497. private _setupBackground;
  44498. /**
  44499. * Get the scene sizes according to the setup.
  44500. */
  44501. private _getSceneSize;
  44502. /**
  44503. * Setup the ground according to the specified options.
  44504. */
  44505. private _setupGround;
  44506. /**
  44507. * Setup the ground material according to the specified options.
  44508. */
  44509. private _setupGroundMaterial;
  44510. /**
  44511. * Setup the ground diffuse texture according to the specified options.
  44512. */
  44513. private _setupGroundDiffuseTexture;
  44514. /**
  44515. * Setup the ground mirror texture according to the specified options.
  44516. */
  44517. private _setupGroundMirrorTexture;
  44518. /**
  44519. * Setup the ground to receive the mirror texture.
  44520. */
  44521. private _setupMirrorInGroundMaterial;
  44522. /**
  44523. * Setup the skybox according to the specified options.
  44524. */
  44525. private _setupSkybox;
  44526. /**
  44527. * Setup the skybox material according to the specified options.
  44528. */
  44529. private _setupSkyboxMaterial;
  44530. /**
  44531. * Setup the skybox reflection texture according to the specified options.
  44532. */
  44533. private _setupSkyboxReflectionTexture;
  44534. private _errorHandler;
  44535. /**
  44536. * Dispose all the elements created by the Helper.
  44537. */
  44538. dispose(): void;
  44539. }
  44540. }
  44541. declare module BABYLON {
  44542. /**
  44543. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  44544. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  44545. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  44546. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  44547. */
  44548. export class PhotoDome extends TransformNode {
  44549. /**
  44550. * Define the image as a Monoscopic panoramic 360 image.
  44551. */
  44552. static readonly MODE_MONOSCOPIC: number;
  44553. /**
  44554. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44555. */
  44556. static readonly MODE_TOPBOTTOM: number;
  44557. /**
  44558. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44559. */
  44560. static readonly MODE_SIDEBYSIDE: number;
  44561. private _useDirectMapping;
  44562. /**
  44563. * The texture being displayed on the sphere
  44564. */
  44565. protected _photoTexture: Texture;
  44566. /**
  44567. * Gets or sets the texture being displayed on the sphere
  44568. */
  44569. photoTexture: Texture;
  44570. /**
  44571. * Observable raised when an error occured while loading the 360 image
  44572. */
  44573. onLoadErrorObservable: Observable<string>;
  44574. /**
  44575. * The skybox material
  44576. */
  44577. protected _material: BackgroundMaterial;
  44578. /**
  44579. * The surface used for the skybox
  44580. */
  44581. protected _mesh: Mesh;
  44582. /**
  44583. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44584. * Also see the options.resolution property.
  44585. */
  44586. fovMultiplier: number;
  44587. private _imageMode;
  44588. /**
  44589. * Gets or set the current video mode for the video. It can be:
  44590. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  44591. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  44592. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  44593. */
  44594. imageMode: number;
  44595. /**
  44596. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  44597. * @param name Element's name, child elements will append suffixes for their own names.
  44598. * @param urlsOfPhoto defines the url of the photo to display
  44599. * @param options defines an object containing optional or exposed sub element properties
  44600. * @param onError defines a callback called when an error occured while loading the texture
  44601. */
  44602. constructor(name: string, urlOfPhoto: string, options: {
  44603. resolution?: number;
  44604. size?: number;
  44605. useDirectMapping?: boolean;
  44606. faceForward?: boolean;
  44607. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  44608. private _onBeforeCameraRenderObserver;
  44609. private _changeImageMode;
  44610. /**
  44611. * Releases resources associated with this node.
  44612. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  44613. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  44614. */
  44615. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  44616. }
  44617. }
  44618. declare module BABYLON {
  44619. /** @hidden */
  44620. export var rgbdDecodePixelShader: {
  44621. name: string;
  44622. shader: string;
  44623. };
  44624. }
  44625. declare module BABYLON {
  44626. /**
  44627. * Class used to host texture specific utilities
  44628. */
  44629. export class BRDFTextureTools {
  44630. /**
  44631. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  44632. * @param texture the texture to expand.
  44633. */
  44634. private static _ExpandDefaultBRDFTexture;
  44635. /**
  44636. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  44637. * @param scene defines the hosting scene
  44638. * @returns the environment BRDF texture
  44639. */
  44640. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  44641. private static _environmentBRDFBase64Texture;
  44642. }
  44643. }
  44644. declare module BABYLON {
  44645. /**
  44646. * @hidden
  44647. */
  44648. export interface IMaterialClearCoatDefines {
  44649. CLEARCOAT: boolean;
  44650. CLEARCOAT_DEFAULTIOR: boolean;
  44651. CLEARCOAT_TEXTURE: boolean;
  44652. CLEARCOAT_TEXTUREDIRECTUV: number;
  44653. CLEARCOAT_BUMP: boolean;
  44654. CLEARCOAT_BUMPDIRECTUV: number;
  44655. CLEARCOAT_TINT: boolean;
  44656. CLEARCOAT_TINT_TEXTURE: boolean;
  44657. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  44658. /** @hidden */ private _areTexturesDirty: boolean;
  44659. }
  44660. /**
  44661. * Define the code related to the clear coat parameters of the pbr material.
  44662. */
  44663. export class PBRClearCoatConfiguration {
  44664. /**
  44665. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44666. * The default fits with a polyurethane material.
  44667. */
  44668. private static readonly _DefaultIndexOfRefraction;
  44669. private _isEnabled;
  44670. /**
  44671. * Defines if the clear coat is enabled in the material.
  44672. */
  44673. isEnabled: boolean;
  44674. /**
  44675. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  44676. */
  44677. intensity: number;
  44678. /**
  44679. * Defines the clear coat layer roughness.
  44680. */
  44681. roughness: number;
  44682. private _indexOfRefraction;
  44683. /**
  44684. * Defines the index of refraction of the clear coat.
  44685. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  44686. * The default fits with a polyurethane material.
  44687. * Changing the default value is more performance intensive.
  44688. */
  44689. indexOfRefraction: number;
  44690. private _texture;
  44691. /**
  44692. * Stores the clear coat values in a texture.
  44693. */
  44694. texture: Nullable<BaseTexture>;
  44695. private _bumpTexture;
  44696. /**
  44697. * Define the clear coat specific bump texture.
  44698. */
  44699. bumpTexture: Nullable<BaseTexture>;
  44700. private _isTintEnabled;
  44701. /**
  44702. * Defines if the clear coat tint is enabled in the material.
  44703. */
  44704. isTintEnabled: boolean;
  44705. /**
  44706. * Defines the clear coat tint of the material.
  44707. * This is only use if tint is enabled
  44708. */
  44709. tintColor: Color3;
  44710. /**
  44711. * Defines the distance at which the tint color should be found in the
  44712. * clear coat media.
  44713. * This is only use if tint is enabled
  44714. */
  44715. tintColorAtDistance: number;
  44716. /**
  44717. * Defines the clear coat layer thickness.
  44718. * This is only use if tint is enabled
  44719. */
  44720. tintThickness: number;
  44721. private _tintTexture;
  44722. /**
  44723. * Stores the clear tint values in a texture.
  44724. * rgb is tint
  44725. * a is a thickness factor
  44726. */
  44727. tintTexture: Nullable<BaseTexture>;
  44728. /** @hidden */
  44729. private _internalMarkAllSubMeshesAsTexturesDirty;
  44730. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44731. /**
  44732. * Instantiate a new istance of clear coat configuration.
  44733. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44734. */
  44735. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44736. /**
  44737. * Gets wehter the submesh is ready to be used or not.
  44738. * @param defines the list of "defines" to update.
  44739. * @param scene defines the scene the material belongs to.
  44740. * @param engine defines the engine the material belongs to.
  44741. * @param disableBumpMap defines wether the material disables bump or not.
  44742. * @returns - boolean indicating that the submesh is ready or not.
  44743. */
  44744. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  44745. /**
  44746. * Checks to see if a texture is used in the material.
  44747. * @param defines the list of "defines" to update.
  44748. * @param scene defines the scene to the material belongs to.
  44749. */
  44750. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  44751. /**
  44752. * Binds the material data.
  44753. * @param uniformBuffer defines the Uniform buffer to fill in.
  44754. * @param scene defines the scene the material belongs to.
  44755. * @param engine defines the engine the material belongs to.
  44756. * @param disableBumpMap defines wether the material disables bump or not.
  44757. * @param isFrozen defines wether the material is frozen or not.
  44758. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  44759. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  44760. */
  44761. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  44762. /**
  44763. * Checks to see if a texture is used in the material.
  44764. * @param texture - Base texture to use.
  44765. * @returns - Boolean specifying if a texture is used in the material.
  44766. */
  44767. hasTexture(texture: BaseTexture): boolean;
  44768. /**
  44769. * Returns an array of the actively used textures.
  44770. * @param activeTextures Array of BaseTextures
  44771. */
  44772. getActiveTextures(activeTextures: BaseTexture[]): void;
  44773. /**
  44774. * Returns the animatable textures.
  44775. * @param animatables Array of animatable textures.
  44776. */
  44777. getAnimatables(animatables: IAnimatable[]): void;
  44778. /**
  44779. * Disposes the resources of the material.
  44780. * @param forceDisposeTextures - Forces the disposal of all textures.
  44781. */
  44782. dispose(forceDisposeTextures?: boolean): void;
  44783. /**
  44784. * Get the current class name of the texture useful for serialization or dynamic coding.
  44785. * @returns "PBRClearCoatConfiguration"
  44786. */
  44787. getClassName(): string;
  44788. /**
  44789. * Add fallbacks to the effect fallbacks list.
  44790. * @param defines defines the Base texture to use.
  44791. * @param fallbacks defines the current fallback list.
  44792. * @param currentRank defines the current fallback rank.
  44793. * @returns the new fallback rank.
  44794. */
  44795. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44796. /**
  44797. * Add the required uniforms to the current list.
  44798. * @param uniforms defines the current uniform list.
  44799. */
  44800. static AddUniforms(uniforms: string[]): void;
  44801. /**
  44802. * Add the required samplers to the current list.
  44803. * @param samplers defines the current sampler list.
  44804. */
  44805. static AddSamplers(samplers: string[]): void;
  44806. /**
  44807. * Add the required uniforms to the current buffer.
  44808. * @param uniformBuffer defines the current uniform buffer.
  44809. */
  44810. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44811. /**
  44812. * Makes a duplicate of the current configuration into another one.
  44813. * @param clearCoatConfiguration define the config where to copy the info
  44814. */
  44815. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  44816. /**
  44817. * Serializes this clear coat configuration.
  44818. * @returns - An object with the serialized config.
  44819. */
  44820. serialize(): any;
  44821. /**
  44822. * Parses a anisotropy Configuration from a serialized object.
  44823. * @param source - Serialized object.
  44824. * @param scene Defines the scene we are parsing for
  44825. * @param rootUrl Defines the rootUrl to load from
  44826. */
  44827. parse(source: any, scene: Scene, rootUrl: string): void;
  44828. }
  44829. }
  44830. declare module BABYLON {
  44831. /**
  44832. * @hidden
  44833. */
  44834. export interface IMaterialAnisotropicDefines {
  44835. ANISOTROPIC: boolean;
  44836. ANISOTROPIC_TEXTURE: boolean;
  44837. ANISOTROPIC_TEXTUREDIRECTUV: number;
  44838. MAINUV1: boolean; private _areTexturesDirty: boolean; private _needUVs: boolean;
  44839. }
  44840. /**
  44841. * Define the code related to the anisotropic parameters of the pbr material.
  44842. */
  44843. export class PBRAnisotropicConfiguration {
  44844. private _isEnabled;
  44845. /**
  44846. * Defines if the anisotropy is enabled in the material.
  44847. */
  44848. isEnabled: boolean;
  44849. /**
  44850. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  44851. */
  44852. intensity: number;
  44853. /**
  44854. * Defines if the effect is along the tangents, bitangents or in between.
  44855. * By default, the effect is "strectching" the highlights along the tangents.
  44856. */
  44857. direction: Vector2;
  44858. private _texture;
  44859. /**
  44860. * Stores the anisotropy values in a texture.
  44861. * rg is direction (like normal from -1 to 1)
  44862. * b is a intensity
  44863. */
  44864. texture: Nullable<BaseTexture>;
  44865. /** @hidden */
  44866. private _internalMarkAllSubMeshesAsTexturesDirty;
  44867. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  44868. /**
  44869. * Instantiate a new istance of anisotropy configuration.
  44870. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  44871. */
  44872. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  44873. /**
  44874. * Specifies that the submesh is ready to be used.
  44875. * @param defines the list of "defines" to update.
  44876. * @param scene defines the scene the material belongs to.
  44877. * @returns - boolean indicating that the submesh is ready or not.
  44878. */
  44879. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  44880. /**
  44881. * Checks to see if a texture is used in the material.
  44882. * @param defines the list of "defines" to update.
  44883. * @param mesh the mesh we are preparing the defines for.
  44884. * @param scene defines the scene the material belongs to.
  44885. */
  44886. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  44887. /**
  44888. * Binds the material data.
  44889. * @param uniformBuffer defines the Uniform buffer to fill in.
  44890. * @param scene defines the scene the material belongs to.
  44891. * @param isFrozen defines wether the material is frozen or not.
  44892. */
  44893. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  44894. /**
  44895. * Checks to see if a texture is used in the material.
  44896. * @param texture - Base texture to use.
  44897. * @returns - Boolean specifying if a texture is used in the material.
  44898. */
  44899. hasTexture(texture: BaseTexture): boolean;
  44900. /**
  44901. * Returns an array of the actively used textures.
  44902. * @param activeTextures Array of BaseTextures
  44903. */
  44904. getActiveTextures(activeTextures: BaseTexture[]): void;
  44905. /**
  44906. * Returns the animatable textures.
  44907. * @param animatables Array of animatable textures.
  44908. */
  44909. getAnimatables(animatables: IAnimatable[]): void;
  44910. /**
  44911. * Disposes the resources of the material.
  44912. * @param forceDisposeTextures - Forces the disposal of all textures.
  44913. */
  44914. dispose(forceDisposeTextures?: boolean): void;
  44915. /**
  44916. * Get the current class name of the texture useful for serialization or dynamic coding.
  44917. * @returns "PBRAnisotropicConfiguration"
  44918. */
  44919. getClassName(): string;
  44920. /**
  44921. * Add fallbacks to the effect fallbacks list.
  44922. * @param defines defines the Base texture to use.
  44923. * @param fallbacks defines the current fallback list.
  44924. * @param currentRank defines the current fallback rank.
  44925. * @returns the new fallback rank.
  44926. */
  44927. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  44928. /**
  44929. * Add the required uniforms to the current list.
  44930. * @param uniforms defines the current uniform list.
  44931. */
  44932. static AddUniforms(uniforms: string[]): void;
  44933. /**
  44934. * Add the required uniforms to the current buffer.
  44935. * @param uniformBuffer defines the current uniform buffer.
  44936. */
  44937. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  44938. /**
  44939. * Add the required samplers to the current list.
  44940. * @param samplers defines the current sampler list.
  44941. */
  44942. static AddSamplers(samplers: string[]): void;
  44943. /**
  44944. * Makes a duplicate of the current configuration into another one.
  44945. * @param anisotropicConfiguration define the config where to copy the info
  44946. */
  44947. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  44948. /**
  44949. * Serializes this anisotropy configuration.
  44950. * @returns - An object with the serialized config.
  44951. */
  44952. serialize(): any;
  44953. /**
  44954. * Parses a anisotropy Configuration from a serialized object.
  44955. * @param source - Serialized object.
  44956. * @param scene Defines the scene we are parsing for
  44957. * @param rootUrl Defines the rootUrl to load from
  44958. */
  44959. parse(source: any, scene: Scene, rootUrl: string): void;
  44960. }
  44961. }
  44962. declare module BABYLON {
  44963. /**
  44964. * @hidden
  44965. */
  44966. export interface IMaterialBRDFDefines {
  44967. BRDF_V_HEIGHT_CORRELATED: boolean;
  44968. MS_BRDF_ENERGY_CONSERVATION: boolean;
  44969. SPHERICAL_HARMONICS: boolean;
  44970. /** @hidden */ private _areMiscDirty: boolean;
  44971. }
  44972. /**
  44973. * Define the code related to the BRDF parameters of the pbr material.
  44974. */
  44975. export class PBRBRDFConfiguration {
  44976. /**
  44977. * Default value used for the energy conservation.
  44978. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44979. */
  44980. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  44981. /**
  44982. * Default value used for the Smith Visibility Height Correlated mode.
  44983. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  44984. */
  44985. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  44986. /**
  44987. * Default value used for the IBL diffuse part.
  44988. * This can help switching back to the polynomials mode globally which is a tiny bit
  44989. * less GPU intensive at the drawback of a lower quality.
  44990. */
  44991. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  44992. private _useEnergyConservation;
  44993. /**
  44994. * Defines if the material uses energy conservation.
  44995. */
  44996. useEnergyConservation: boolean;
  44997. private _useSmithVisibilityHeightCorrelated;
  44998. /**
  44999. * LEGACY Mode set to false
  45000. * Defines if the material uses height smith correlated visibility term.
  45001. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45002. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45003. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45004. * Not relying on height correlated will also disable energy conservation.
  45005. */
  45006. useSmithVisibilityHeightCorrelated: boolean;
  45007. private _useSphericalHarmonics;
  45008. /**
  45009. * LEGACY Mode set to false
  45010. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  45011. * diffuse part of the IBL.
  45012. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  45013. * to the ground truth.
  45014. */
  45015. useSphericalHarmonics: boolean;
  45016. /** @hidden */
  45017. private _internalMarkAllSubMeshesAsMiscDirty;
  45018. /** @hidden */ private _markAllSubMeshesAsMiscDirty(): void;
  45019. /**
  45020. * Instantiate a new istance of clear coat configuration.
  45021. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45022. */
  45023. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45024. /**
  45025. * Checks to see if a texture is used in the material.
  45026. * @param defines the list of "defines" to update.
  45027. */
  45028. prepareDefines(defines: IMaterialBRDFDefines): void;
  45029. /**
  45030. * Get the current class name of the texture useful for serialization or dynamic coding.
  45031. * @returns "PBRClearCoatConfiguration"
  45032. */
  45033. getClassName(): string;
  45034. /**
  45035. * Makes a duplicate of the current configuration into another one.
  45036. * @param brdfConfiguration define the config where to copy the info
  45037. */
  45038. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45039. /**
  45040. * Serializes this BRDF configuration.
  45041. * @returns - An object with the serialized config.
  45042. */
  45043. serialize(): any;
  45044. /**
  45045. * Parses a anisotropy Configuration from a serialized object.
  45046. * @param source - Serialized object.
  45047. * @param scene Defines the scene we are parsing for
  45048. * @param rootUrl Defines the rootUrl to load from
  45049. */
  45050. parse(source: any, scene: Scene, rootUrl: string): void;
  45051. }
  45052. }
  45053. declare module BABYLON {
  45054. /**
  45055. * @hidden
  45056. */
  45057. export interface IMaterialSheenDefines {
  45058. SHEEN: boolean;
  45059. SHEEN_TEXTURE: boolean;
  45060. SHEEN_TEXTUREDIRECTUV: number;
  45061. SHEEN_LINKWITHALBEDO: boolean;
  45062. /** @hidden */ private _areTexturesDirty: boolean;
  45063. }
  45064. /**
  45065. * Define the code related to the Sheen parameters of the pbr material.
  45066. */
  45067. export class PBRSheenConfiguration {
  45068. private _isEnabled;
  45069. /**
  45070. * Defines if the material uses sheen.
  45071. */
  45072. isEnabled: boolean;
  45073. private _linkSheenWithAlbedo;
  45074. /**
  45075. * Defines if the sheen is linked to the sheen color.
  45076. */
  45077. linkSheenWithAlbedo: boolean;
  45078. /**
  45079. * Defines the sheen intensity.
  45080. */
  45081. intensity: number;
  45082. /**
  45083. * Defines the sheen color.
  45084. */
  45085. color: Color3;
  45086. private _texture;
  45087. /**
  45088. * Stores the sheen tint values in a texture.
  45089. * rgb is tint
  45090. * a is a intensity
  45091. */
  45092. texture: Nullable<BaseTexture>;
  45093. /** @hidden */
  45094. private _internalMarkAllSubMeshesAsTexturesDirty;
  45095. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45096. /**
  45097. * Instantiate a new istance of clear coat configuration.
  45098. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45099. */
  45100. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45101. /**
  45102. * Specifies that the submesh is ready to be used.
  45103. * @param defines the list of "defines" to update.
  45104. * @param scene defines the scene the material belongs to.
  45105. * @returns - boolean indicating that the submesh is ready or not.
  45106. */
  45107. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45108. /**
  45109. * Checks to see if a texture is used in the material.
  45110. * @param defines the list of "defines" to update.
  45111. * @param scene defines the scene the material belongs to.
  45112. */
  45113. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45114. /**
  45115. * Binds the material data.
  45116. * @param uniformBuffer defines the Uniform buffer to fill in.
  45117. * @param scene defines the scene the material belongs to.
  45118. * @param isFrozen defines wether the material is frozen or not.
  45119. */
  45120. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45121. /**
  45122. * Checks to see if a texture is used in the material.
  45123. * @param texture - Base texture to use.
  45124. * @returns - Boolean specifying if a texture is used in the material.
  45125. */
  45126. hasTexture(texture: BaseTexture): boolean;
  45127. /**
  45128. * Returns an array of the actively used textures.
  45129. * @param activeTextures Array of BaseTextures
  45130. */
  45131. getActiveTextures(activeTextures: BaseTexture[]): void;
  45132. /**
  45133. * Returns the animatable textures.
  45134. * @param animatables Array of animatable textures.
  45135. */
  45136. getAnimatables(animatables: IAnimatable[]): void;
  45137. /**
  45138. * Disposes the resources of the material.
  45139. * @param forceDisposeTextures - Forces the disposal of all textures.
  45140. */
  45141. dispose(forceDisposeTextures?: boolean): void;
  45142. /**
  45143. * Get the current class name of the texture useful for serialization or dynamic coding.
  45144. * @returns "PBRSheenConfiguration"
  45145. */
  45146. getClassName(): string;
  45147. /**
  45148. * Add fallbacks to the effect fallbacks list.
  45149. * @param defines defines the Base texture to use.
  45150. * @param fallbacks defines the current fallback list.
  45151. * @param currentRank defines the current fallback rank.
  45152. * @returns the new fallback rank.
  45153. */
  45154. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45155. /**
  45156. * Add the required uniforms to the current list.
  45157. * @param uniforms defines the current uniform list.
  45158. */
  45159. static AddUniforms(uniforms: string[]): void;
  45160. /**
  45161. * Add the required uniforms to the current buffer.
  45162. * @param uniformBuffer defines the current uniform buffer.
  45163. */
  45164. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45165. /**
  45166. * Add the required samplers to the current list.
  45167. * @param samplers defines the current sampler list.
  45168. */
  45169. static AddSamplers(samplers: string[]): void;
  45170. /**
  45171. * Makes a duplicate of the current configuration into another one.
  45172. * @param sheenConfiguration define the config where to copy the info
  45173. */
  45174. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45175. /**
  45176. * Serializes this BRDF configuration.
  45177. * @returns - An object with the serialized config.
  45178. */
  45179. serialize(): any;
  45180. /**
  45181. * Parses a anisotropy Configuration from a serialized object.
  45182. * @param source - Serialized object.
  45183. * @param scene Defines the scene we are parsing for
  45184. * @param rootUrl Defines the rootUrl to load from
  45185. */
  45186. parse(source: any, scene: Scene, rootUrl: string): void;
  45187. }
  45188. }
  45189. declare module BABYLON {
  45190. /**
  45191. * @hidden
  45192. */
  45193. export interface IMaterialSubSurfaceDefines {
  45194. SUBSURFACE: boolean;
  45195. SS_REFRACTION: boolean;
  45196. SS_TRANSLUCENCY: boolean;
  45197. SS_SCATERRING: boolean;
  45198. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45199. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45200. SS_REFRACTIONMAP_3D: boolean;
  45201. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45202. SS_LODINREFRACTIONALPHA: boolean;
  45203. SS_GAMMAREFRACTION: boolean;
  45204. SS_RGBDREFRACTION: boolean;
  45205. SS_LINEARSPECULARREFRACTION: boolean;
  45206. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45207. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45208. /** @hidden */ private _areTexturesDirty: boolean;
  45209. }
  45210. /**
  45211. * Define the code related to the sub surface parameters of the pbr material.
  45212. */
  45213. export class PBRSubSurfaceConfiguration {
  45214. private _isRefractionEnabled;
  45215. /**
  45216. * Defines if the refraction is enabled in the material.
  45217. */
  45218. isRefractionEnabled: boolean;
  45219. private _isTranslucencyEnabled;
  45220. /**
  45221. * Defines if the translucency is enabled in the material.
  45222. */
  45223. isTranslucencyEnabled: boolean;
  45224. private _isScatteringEnabled;
  45225. /**
  45226. * Defines the refraction intensity of the material.
  45227. * The refraction when enabled replaces the Diffuse part of the material.
  45228. * The intensity helps transitionning between diffuse and refraction.
  45229. */
  45230. refractionIntensity: number;
  45231. /**
  45232. * Defines the translucency intensity of the material.
  45233. * When translucency has been enabled, this defines how much of the "translucency"
  45234. * is addded to the diffuse part of the material.
  45235. */
  45236. translucencyIntensity: number;
  45237. /**
  45238. * Defines the scattering intensity of the material.
  45239. * When scattering has been enabled, this defines how much of the "scattered light"
  45240. * is addded to the diffuse part of the material.
  45241. */
  45242. scatteringIntensity: number;
  45243. private _thicknessTexture;
  45244. /**
  45245. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  45246. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  45247. * 0 would mean minimumThickness
  45248. * 1 would mean maximumThickness
  45249. * The other channels might be use as a mask to vary the different effects intensity.
  45250. */
  45251. thicknessTexture: Nullable<BaseTexture>;
  45252. private _refractionTexture;
  45253. /**
  45254. * Defines the texture to use for refraction.
  45255. */
  45256. refractionTexture: Nullable<BaseTexture>;
  45257. private _indexOfRefraction;
  45258. /**
  45259. * Defines the index of refraction used in the material.
  45260. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  45261. */
  45262. indexOfRefraction: number;
  45263. private _invertRefractionY;
  45264. /**
  45265. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  45266. */
  45267. invertRefractionY: boolean;
  45268. private _linkRefractionWithTransparency;
  45269. /**
  45270. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  45271. * Materials half opaque for instance using refraction could benefit from this control.
  45272. */
  45273. linkRefractionWithTransparency: boolean;
  45274. /**
  45275. * Defines the minimum thickness stored in the thickness map.
  45276. * If no thickness map is defined, this value will be used to simulate thickness.
  45277. */
  45278. minimumThickness: number;
  45279. /**
  45280. * Defines the maximum thickness stored in the thickness map.
  45281. */
  45282. maximumThickness: number;
  45283. /**
  45284. * Defines the volume tint of the material.
  45285. * This is used for both translucency and scattering.
  45286. */
  45287. tintColor: Color3;
  45288. /**
  45289. * Defines the distance at which the tint color should be found in the media.
  45290. * This is used for refraction only.
  45291. */
  45292. tintColorAtDistance: number;
  45293. /**
  45294. * Defines how far each channel transmit through the media.
  45295. * It is defined as a color to simplify it selection.
  45296. */
  45297. diffusionDistance: Color3;
  45298. private _useMaskFromThicknessTexture;
  45299. /**
  45300. * Stores the intensity of the different subsurface effects in the thickness texture.
  45301. * * the green channel is the translucency intensity.
  45302. * * the blue channel is the scattering intensity.
  45303. * * the alpha channel is the refraction intensity.
  45304. */
  45305. useMaskFromThicknessTexture: boolean;
  45306. /** @hidden */
  45307. private _internalMarkAllSubMeshesAsTexturesDirty;
  45308. /** @hidden */ private _markAllSubMeshesAsTexturesDirty(): void;
  45309. /**
  45310. * Instantiate a new istance of sub surface configuration.
  45311. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45312. */
  45313. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45314. /**
  45315. * Gets wehter the submesh is ready to be used or not.
  45316. * @param defines the list of "defines" to update.
  45317. * @param scene defines the scene the material belongs to.
  45318. * @returns - boolean indicating that the submesh is ready or not.
  45319. */
  45320. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  45321. /**
  45322. * Checks to see if a texture is used in the material.
  45323. * @param defines the list of "defines" to update.
  45324. * @param scene defines the scene to the material belongs to.
  45325. */
  45326. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  45327. /**
  45328. * Binds the material data.
  45329. * @param uniformBuffer defines the Uniform buffer to fill in.
  45330. * @param scene defines the scene the material belongs to.
  45331. * @param engine defines the engine the material belongs to.
  45332. * @param isFrozen defines wether the material is frozen or not.
  45333. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  45334. */
  45335. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  45336. /**
  45337. * Unbinds the material from the mesh.
  45338. * @param activeEffect defines the effect that should be unbound from.
  45339. * @returns true if unbound, otherwise false
  45340. */
  45341. unbind(activeEffect: Effect): boolean;
  45342. /**
  45343. * Returns the texture used for refraction or null if none is used.
  45344. * @param scene defines the scene the material belongs to.
  45345. * @returns - Refraction texture if present. If no refraction texture and refraction
  45346. * is linked with transparency, returns environment texture. Otherwise, returns null.
  45347. */
  45348. private _getRefractionTexture;
  45349. /**
  45350. * Returns true if alpha blending should be disabled.
  45351. */
  45352. readonly disableAlphaBlending: boolean;
  45353. /**
  45354. * Fills the list of render target textures.
  45355. * @param renderTargets the list of render targets to update
  45356. */
  45357. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  45358. /**
  45359. * Checks to see if a texture is used in the material.
  45360. * @param texture - Base texture to use.
  45361. * @returns - Boolean specifying if a texture is used in the material.
  45362. */
  45363. hasTexture(texture: BaseTexture): boolean;
  45364. /**
  45365. * Gets a boolean indicating that current material needs to register RTT
  45366. * @returns true if this uses a render target otherwise false.
  45367. */
  45368. hasRenderTargetTextures(): boolean;
  45369. /**
  45370. * Returns an array of the actively used textures.
  45371. * @param activeTextures Array of BaseTextures
  45372. */
  45373. getActiveTextures(activeTextures: BaseTexture[]): void;
  45374. /**
  45375. * Returns the animatable textures.
  45376. * @param animatables Array of animatable textures.
  45377. */
  45378. getAnimatables(animatables: IAnimatable[]): void;
  45379. /**
  45380. * Disposes the resources of the material.
  45381. * @param forceDisposeTextures - Forces the disposal of all textures.
  45382. */
  45383. dispose(forceDisposeTextures?: boolean): void;
  45384. /**
  45385. * Get the current class name of the texture useful for serialization or dynamic coding.
  45386. * @returns "PBRSubSurfaceConfiguration"
  45387. */
  45388. getClassName(): string;
  45389. /**
  45390. * Add fallbacks to the effect fallbacks list.
  45391. * @param defines defines the Base texture to use.
  45392. * @param fallbacks defines the current fallback list.
  45393. * @param currentRank defines the current fallback rank.
  45394. * @returns the new fallback rank.
  45395. */
  45396. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45397. /**
  45398. * Add the required uniforms to the current list.
  45399. * @param uniforms defines the current uniform list.
  45400. */
  45401. static AddUniforms(uniforms: string[]): void;
  45402. /**
  45403. * Add the required samplers to the current list.
  45404. * @param samplers defines the current sampler list.
  45405. */
  45406. static AddSamplers(samplers: string[]): void;
  45407. /**
  45408. * Add the required uniforms to the current buffer.
  45409. * @param uniformBuffer defines the current uniform buffer.
  45410. */
  45411. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45412. /**
  45413. * Makes a duplicate of the current configuration into another one.
  45414. * @param configuration define the config where to copy the info
  45415. */
  45416. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  45417. /**
  45418. * Serializes this Sub Surface configuration.
  45419. * @returns - An object with the serialized config.
  45420. */
  45421. serialize(): any;
  45422. /**
  45423. * Parses a anisotropy Configuration from a serialized object.
  45424. * @param source - Serialized object.
  45425. * @param scene Defines the scene we are parsing for
  45426. * @param rootUrl Defines the rootUrl to load from
  45427. */
  45428. parse(source: any, scene: Scene, rootUrl: string): void;
  45429. }
  45430. }
  45431. declare module BABYLON {
  45432. /** @hidden */
  45433. export var pbrFragmentDeclaration: {
  45434. name: string;
  45435. shader: string;
  45436. };
  45437. }
  45438. declare module BABYLON {
  45439. /** @hidden */
  45440. export var pbrUboDeclaration: {
  45441. name: string;
  45442. shader: string;
  45443. };
  45444. }
  45445. declare module BABYLON {
  45446. /** @hidden */
  45447. export var pbrFragmentExtraDeclaration: {
  45448. name: string;
  45449. shader: string;
  45450. };
  45451. }
  45452. declare module BABYLON {
  45453. /** @hidden */
  45454. export var pbrFragmentSamplersDeclaration: {
  45455. name: string;
  45456. shader: string;
  45457. };
  45458. }
  45459. declare module BABYLON {
  45460. /** @hidden */
  45461. export var pbrHelperFunctions: {
  45462. name: string;
  45463. shader: string;
  45464. };
  45465. }
  45466. declare module BABYLON {
  45467. /** @hidden */
  45468. export var harmonicsFunctions: {
  45469. name: string;
  45470. shader: string;
  45471. };
  45472. }
  45473. declare module BABYLON {
  45474. /** @hidden */
  45475. export var pbrDirectLightingSetupFunctions: {
  45476. name: string;
  45477. shader: string;
  45478. };
  45479. }
  45480. declare module BABYLON {
  45481. /** @hidden */
  45482. export var pbrDirectLightingFalloffFunctions: {
  45483. name: string;
  45484. shader: string;
  45485. };
  45486. }
  45487. declare module BABYLON {
  45488. /** @hidden */
  45489. export var pbrBRDFFunctions: {
  45490. name: string;
  45491. shader: string;
  45492. };
  45493. }
  45494. declare module BABYLON {
  45495. /** @hidden */
  45496. export var pbrDirectLightingFunctions: {
  45497. name: string;
  45498. shader: string;
  45499. };
  45500. }
  45501. declare module BABYLON {
  45502. /** @hidden */
  45503. export var pbrIBLFunctions: {
  45504. name: string;
  45505. shader: string;
  45506. };
  45507. }
  45508. declare module BABYLON {
  45509. /** @hidden */
  45510. export var pbrDebug: {
  45511. name: string;
  45512. shader: string;
  45513. };
  45514. }
  45515. declare module BABYLON {
  45516. /** @hidden */
  45517. export var pbrPixelShader: {
  45518. name: string;
  45519. shader: string;
  45520. };
  45521. }
  45522. declare module BABYLON {
  45523. /** @hidden */
  45524. export var pbrVertexDeclaration: {
  45525. name: string;
  45526. shader: string;
  45527. };
  45528. }
  45529. declare module BABYLON {
  45530. /** @hidden */
  45531. export var pbrVertexShader: {
  45532. name: string;
  45533. shader: string;
  45534. };
  45535. }
  45536. declare module BABYLON {
  45537. /**
  45538. * Manages the defines for the PBR Material.
  45539. * @hidden
  45540. */
  45541. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  45542. PBR: boolean;
  45543. MAINUV1: boolean;
  45544. MAINUV2: boolean;
  45545. UV1: boolean;
  45546. UV2: boolean;
  45547. ALBEDO: boolean;
  45548. ALBEDODIRECTUV: number;
  45549. VERTEXCOLOR: boolean;
  45550. AMBIENT: boolean;
  45551. AMBIENTDIRECTUV: number;
  45552. AMBIENTINGRAYSCALE: boolean;
  45553. OPACITY: boolean;
  45554. VERTEXALPHA: boolean;
  45555. OPACITYDIRECTUV: number;
  45556. OPACITYRGB: boolean;
  45557. ALPHATEST: boolean;
  45558. DEPTHPREPASS: boolean;
  45559. ALPHABLEND: boolean;
  45560. ALPHAFROMALBEDO: boolean;
  45561. ALPHATESTVALUE: string;
  45562. SPECULAROVERALPHA: boolean;
  45563. RADIANCEOVERALPHA: boolean;
  45564. ALPHAFRESNEL: boolean;
  45565. LINEARALPHAFRESNEL: boolean;
  45566. PREMULTIPLYALPHA: boolean;
  45567. EMISSIVE: boolean;
  45568. EMISSIVEDIRECTUV: number;
  45569. REFLECTIVITY: boolean;
  45570. REFLECTIVITYDIRECTUV: number;
  45571. SPECULARTERM: boolean;
  45572. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  45573. MICROSURFACEAUTOMATIC: boolean;
  45574. LODBASEDMICROSFURACE: boolean;
  45575. MICROSURFACEMAP: boolean;
  45576. MICROSURFACEMAPDIRECTUV: number;
  45577. METALLICWORKFLOW: boolean;
  45578. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  45579. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  45580. METALLNESSSTOREINMETALMAPBLUE: boolean;
  45581. AOSTOREINMETALMAPRED: boolean;
  45582. ENVIRONMENTBRDF: boolean;
  45583. ENVIRONMENTBRDF_RGBD: boolean;
  45584. NORMAL: boolean;
  45585. TANGENT: boolean;
  45586. BUMP: boolean;
  45587. BUMPDIRECTUV: number;
  45588. OBJECTSPACE_NORMALMAP: boolean;
  45589. PARALLAX: boolean;
  45590. PARALLAXOCCLUSION: boolean;
  45591. NORMALXYSCALE: boolean;
  45592. LIGHTMAP: boolean;
  45593. LIGHTMAPDIRECTUV: number;
  45594. USELIGHTMAPASSHADOWMAP: boolean;
  45595. GAMMALIGHTMAP: boolean;
  45596. REFLECTION: boolean;
  45597. REFLECTIONMAP_3D: boolean;
  45598. REFLECTIONMAP_SPHERICAL: boolean;
  45599. REFLECTIONMAP_PLANAR: boolean;
  45600. REFLECTIONMAP_CUBIC: boolean;
  45601. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  45602. REFLECTIONMAP_PROJECTION: boolean;
  45603. REFLECTIONMAP_SKYBOX: boolean;
  45604. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  45605. REFLECTIONMAP_EXPLICIT: boolean;
  45606. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  45607. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  45608. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  45609. INVERTCUBICMAP: boolean;
  45610. USESPHERICALFROMREFLECTIONMAP: boolean;
  45611. USEIRRADIANCEMAP: boolean;
  45612. SPHERICAL_HARMONICS: boolean;
  45613. USESPHERICALINVERTEX: boolean;
  45614. REFLECTIONMAP_OPPOSITEZ: boolean;
  45615. LODINREFLECTIONALPHA: boolean;
  45616. GAMMAREFLECTION: boolean;
  45617. RGBDREFLECTION: boolean;
  45618. LINEARSPECULARREFLECTION: boolean;
  45619. RADIANCEOCCLUSION: boolean;
  45620. HORIZONOCCLUSION: boolean;
  45621. INSTANCES: boolean;
  45622. NUM_BONE_INFLUENCERS: number;
  45623. BonesPerMesh: number;
  45624. BONETEXTURE: boolean;
  45625. NONUNIFORMSCALING: boolean;
  45626. MORPHTARGETS: boolean;
  45627. MORPHTARGETS_NORMAL: boolean;
  45628. MORPHTARGETS_TANGENT: boolean;
  45629. MORPHTARGETS_UV: boolean;
  45630. NUM_MORPH_INFLUENCERS: number;
  45631. IMAGEPROCESSING: boolean;
  45632. VIGNETTE: boolean;
  45633. VIGNETTEBLENDMODEMULTIPLY: boolean;
  45634. VIGNETTEBLENDMODEOPAQUE: boolean;
  45635. TONEMAPPING: boolean;
  45636. TONEMAPPING_ACES: boolean;
  45637. CONTRAST: boolean;
  45638. COLORCURVES: boolean;
  45639. COLORGRADING: boolean;
  45640. COLORGRADING3D: boolean;
  45641. SAMPLER3DGREENDEPTH: boolean;
  45642. SAMPLER3DBGRMAP: boolean;
  45643. IMAGEPROCESSINGPOSTPROCESS: boolean;
  45644. EXPOSURE: boolean;
  45645. MULTIVIEW: boolean;
  45646. USEPHYSICALLIGHTFALLOFF: boolean;
  45647. USEGLTFLIGHTFALLOFF: boolean;
  45648. TWOSIDEDLIGHTING: boolean;
  45649. SHADOWFLOAT: boolean;
  45650. CLIPPLANE: boolean;
  45651. CLIPPLANE2: boolean;
  45652. CLIPPLANE3: boolean;
  45653. CLIPPLANE4: boolean;
  45654. POINTSIZE: boolean;
  45655. FOG: boolean;
  45656. LOGARITHMICDEPTH: boolean;
  45657. FORCENORMALFORWARD: boolean;
  45658. SPECULARAA: boolean;
  45659. CLEARCOAT: boolean;
  45660. CLEARCOAT_DEFAULTIOR: boolean;
  45661. CLEARCOAT_TEXTURE: boolean;
  45662. CLEARCOAT_TEXTUREDIRECTUV: number;
  45663. CLEARCOAT_BUMP: boolean;
  45664. CLEARCOAT_BUMPDIRECTUV: number;
  45665. CLEARCOAT_TINT: boolean;
  45666. CLEARCOAT_TINT_TEXTURE: boolean;
  45667. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45668. ANISOTROPIC: boolean;
  45669. ANISOTROPIC_TEXTURE: boolean;
  45670. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45671. BRDF_V_HEIGHT_CORRELATED: boolean;
  45672. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45673. SHEEN: boolean;
  45674. SHEEN_TEXTURE: boolean;
  45675. SHEEN_TEXTUREDIRECTUV: number;
  45676. SHEEN_LINKWITHALBEDO: boolean;
  45677. SUBSURFACE: boolean;
  45678. SS_REFRACTION: boolean;
  45679. SS_TRANSLUCENCY: boolean;
  45680. SS_SCATERRING: boolean;
  45681. SS_THICKNESSANDMASK_TEXTURE: boolean;
  45682. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  45683. SS_REFRACTIONMAP_3D: boolean;
  45684. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  45685. SS_LODINREFRACTIONALPHA: boolean;
  45686. SS_GAMMAREFRACTION: boolean;
  45687. SS_RGBDREFRACTION: boolean;
  45688. SS_LINEARSPECULARREFRACTION: boolean;
  45689. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  45690. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  45691. UNLIT: boolean;
  45692. DEBUGMODE: number;
  45693. /**
  45694. * Initializes the PBR Material defines.
  45695. */
  45696. constructor();
  45697. /**
  45698. * Resets the PBR Material defines.
  45699. */
  45700. reset(): void;
  45701. }
  45702. /**
  45703. * The Physically based material base class of BJS.
  45704. *
  45705. * This offers the main features of a standard PBR material.
  45706. * For more information, please refer to the documentation :
  45707. * https://doc.babylonjs.com/how_to/physically_based_rendering
  45708. */
  45709. export abstract class PBRBaseMaterial extends PushMaterial {
  45710. /**
  45711. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  45712. */
  45713. static readonly PBRMATERIAL_OPAQUE: number;
  45714. /**
  45715. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  45716. */
  45717. static readonly PBRMATERIAL_ALPHATEST: number;
  45718. /**
  45719. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45720. */
  45721. static readonly PBRMATERIAL_ALPHABLEND: number;
  45722. /**
  45723. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  45724. * They are also discarded below the alpha cutoff threshold to improve performances.
  45725. */
  45726. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  45727. /**
  45728. * Defines the default value of how much AO map is occluding the analytical lights
  45729. * (point spot...).
  45730. */
  45731. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  45732. /**
  45733. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  45734. */
  45735. static readonly LIGHTFALLOFF_PHYSICAL: number;
  45736. /**
  45737. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  45738. * to enhance interoperability with other engines.
  45739. */
  45740. static readonly LIGHTFALLOFF_GLTF: number;
  45741. /**
  45742. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  45743. * to enhance interoperability with other materials.
  45744. */
  45745. static readonly LIGHTFALLOFF_STANDARD: number;
  45746. /**
  45747. * Intensity of the direct lights e.g. the four lights available in your scene.
  45748. * This impacts both the direct diffuse and specular highlights.
  45749. */
  45750. protected _directIntensity: number;
  45751. /**
  45752. * Intensity of the emissive part of the material.
  45753. * This helps controlling the emissive effect without modifying the emissive color.
  45754. */
  45755. protected _emissiveIntensity: number;
  45756. /**
  45757. * Intensity of the environment e.g. how much the environment will light the object
  45758. * either through harmonics for rough material or through the refelction for shiny ones.
  45759. */
  45760. protected _environmentIntensity: number;
  45761. /**
  45762. * This is a special control allowing the reduction of the specular highlights coming from the
  45763. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  45764. */
  45765. protected _specularIntensity: number;
  45766. /**
  45767. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  45768. */
  45769. private _lightingInfos;
  45770. /**
  45771. * Debug Control allowing disabling the bump map on this material.
  45772. */
  45773. protected _disableBumpMap: boolean;
  45774. /**
  45775. * AKA Diffuse Texture in standard nomenclature.
  45776. */
  45777. protected _albedoTexture: Nullable<BaseTexture>;
  45778. /**
  45779. * AKA Occlusion Texture in other nomenclature.
  45780. */
  45781. protected _ambientTexture: Nullable<BaseTexture>;
  45782. /**
  45783. * AKA Occlusion Texture Intensity in other nomenclature.
  45784. */
  45785. protected _ambientTextureStrength: number;
  45786. /**
  45787. * Defines how much the AO map is occluding the analytical lights (point spot...).
  45788. * 1 means it completely occludes it
  45789. * 0 mean it has no impact
  45790. */
  45791. protected _ambientTextureImpactOnAnalyticalLights: number;
  45792. /**
  45793. * Stores the alpha values in a texture.
  45794. */
  45795. protected _opacityTexture: Nullable<BaseTexture>;
  45796. /**
  45797. * Stores the reflection values in a texture.
  45798. */
  45799. protected _reflectionTexture: Nullable<BaseTexture>;
  45800. /**
  45801. * Stores the emissive values in a texture.
  45802. */
  45803. protected _emissiveTexture: Nullable<BaseTexture>;
  45804. /**
  45805. * AKA Specular texture in other nomenclature.
  45806. */
  45807. protected _reflectivityTexture: Nullable<BaseTexture>;
  45808. /**
  45809. * Used to switch from specular/glossiness to metallic/roughness workflow.
  45810. */
  45811. protected _metallicTexture: Nullable<BaseTexture>;
  45812. /**
  45813. * Specifies the metallic scalar of the metallic/roughness workflow.
  45814. * Can also be used to scale the metalness values of the metallic texture.
  45815. */
  45816. protected _metallic: Nullable<number>;
  45817. /**
  45818. * Specifies the roughness scalar of the metallic/roughness workflow.
  45819. * Can also be used to scale the roughness values of the metallic texture.
  45820. */
  45821. protected _roughness: Nullable<number>;
  45822. /**
  45823. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  45824. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  45825. */
  45826. protected _microSurfaceTexture: Nullable<BaseTexture>;
  45827. /**
  45828. * Stores surface normal data used to displace a mesh in a texture.
  45829. */
  45830. protected _bumpTexture: Nullable<BaseTexture>;
  45831. /**
  45832. * Stores the pre-calculated light information of a mesh in a texture.
  45833. */
  45834. protected _lightmapTexture: Nullable<BaseTexture>;
  45835. /**
  45836. * The color of a material in ambient lighting.
  45837. */
  45838. protected _ambientColor: Color3;
  45839. /**
  45840. * AKA Diffuse Color in other nomenclature.
  45841. */
  45842. protected _albedoColor: Color3;
  45843. /**
  45844. * AKA Specular Color in other nomenclature.
  45845. */
  45846. protected _reflectivityColor: Color3;
  45847. /**
  45848. * The color applied when light is reflected from a material.
  45849. */
  45850. protected _reflectionColor: Color3;
  45851. /**
  45852. * The color applied when light is emitted from a material.
  45853. */
  45854. protected _emissiveColor: Color3;
  45855. /**
  45856. * AKA Glossiness in other nomenclature.
  45857. */
  45858. protected _microSurface: number;
  45859. /**
  45860. * Specifies that the material will use the light map as a show map.
  45861. */
  45862. protected _useLightmapAsShadowmap: boolean;
  45863. /**
  45864. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  45865. * makes the reflect vector face the model (under horizon).
  45866. */
  45867. protected _useHorizonOcclusion: boolean;
  45868. /**
  45869. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  45870. * too much the area relying on ambient texture to define their ambient occlusion.
  45871. */
  45872. protected _useRadianceOcclusion: boolean;
  45873. /**
  45874. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  45875. */
  45876. protected _useAlphaFromAlbedoTexture: boolean;
  45877. /**
  45878. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  45879. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  45880. */
  45881. protected _useSpecularOverAlpha: boolean;
  45882. /**
  45883. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  45884. */
  45885. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  45886. /**
  45887. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  45888. */
  45889. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  45890. /**
  45891. * Specifies if the metallic texture contains the roughness information in its green channel.
  45892. */
  45893. protected _useRoughnessFromMetallicTextureGreen: boolean;
  45894. /**
  45895. * Specifies if the metallic texture contains the metallness information in its blue channel.
  45896. */
  45897. protected _useMetallnessFromMetallicTextureBlue: boolean;
  45898. /**
  45899. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  45900. */
  45901. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  45902. /**
  45903. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  45904. */
  45905. protected _useAmbientInGrayScale: boolean;
  45906. /**
  45907. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  45908. * The material will try to infer what glossiness each pixel should be.
  45909. */
  45910. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  45911. /**
  45912. * Defines the falloff type used in this material.
  45913. * It by default is Physical.
  45914. */
  45915. protected _lightFalloff: number;
  45916. /**
  45917. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  45918. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  45919. */
  45920. protected _useRadianceOverAlpha: boolean;
  45921. /**
  45922. * Allows using an object space normal map (instead of tangent space).
  45923. */
  45924. protected _useObjectSpaceNormalMap: boolean;
  45925. /**
  45926. * Allows using the bump map in parallax mode.
  45927. */
  45928. protected _useParallax: boolean;
  45929. /**
  45930. * Allows using the bump map in parallax occlusion mode.
  45931. */
  45932. protected _useParallaxOcclusion: boolean;
  45933. /**
  45934. * Controls the scale bias of the parallax mode.
  45935. */
  45936. protected _parallaxScaleBias: number;
  45937. /**
  45938. * If sets to true, disables all the lights affecting the material.
  45939. */
  45940. protected _disableLighting: boolean;
  45941. /**
  45942. * Number of Simultaneous lights allowed on the material.
  45943. */
  45944. protected _maxSimultaneousLights: number;
  45945. /**
  45946. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45947. */
  45948. protected _invertNormalMapX: boolean;
  45949. /**
  45950. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45951. */
  45952. protected _invertNormalMapY: boolean;
  45953. /**
  45954. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  45955. */
  45956. protected _twoSidedLighting: boolean;
  45957. /**
  45958. * Defines the alpha limits in alpha test mode.
  45959. */
  45960. protected _alphaCutOff: number;
  45961. /**
  45962. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  45963. */
  45964. protected _forceAlphaTest: boolean;
  45965. /**
  45966. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45967. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  45968. */
  45969. protected _useAlphaFresnel: boolean;
  45970. /**
  45971. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  45972. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  45973. */
  45974. protected _useLinearAlphaFresnel: boolean;
  45975. /**
  45976. * The transparency mode of the material.
  45977. */
  45978. protected _transparencyMode: Nullable<number>;
  45979. /**
  45980. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  45981. * from cos thetav and roughness:
  45982. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  45983. */
  45984. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  45985. /**
  45986. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  45987. */
  45988. protected _forceIrradianceInFragment: boolean;
  45989. /**
  45990. * Force normal to face away from face.
  45991. */
  45992. protected _forceNormalForward: boolean;
  45993. /**
  45994. * Enables specular anti aliasing in the PBR shader.
  45995. * It will both interacts on the Geometry for analytical and IBL lighting.
  45996. * It also prefilter the roughness map based on the bump values.
  45997. */
  45998. protected _enableSpecularAntiAliasing: boolean;
  45999. /**
  46000. * Default configuration related to image processing available in the PBR Material.
  46001. */
  46002. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46003. /**
  46004. * Keep track of the image processing observer to allow dispose and replace.
  46005. */
  46006. private _imageProcessingObserver;
  46007. /**
  46008. * Attaches a new image processing configuration to the PBR Material.
  46009. * @param configuration
  46010. */
  46011. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46012. /**
  46013. * Stores the available render targets.
  46014. */
  46015. private _renderTargets;
  46016. /**
  46017. * Sets the global ambient color for the material used in lighting calculations.
  46018. */
  46019. private _globalAmbientColor;
  46020. /**
  46021. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46022. */
  46023. private _useLogarithmicDepth;
  46024. /**
  46025. * If set to true, no lighting calculations will be applied.
  46026. */
  46027. private _unlit;
  46028. private _debugMode;
  46029. /**
  46030. * @hidden
  46031. * This is reserved for the inspector.
  46032. * Defines the material debug mode.
  46033. * It helps seeing only some components of the material while troubleshooting.
  46034. */
  46035. debugMode: number;
  46036. /**
  46037. * @hidden
  46038. * This is reserved for the inspector.
  46039. * Specify from where on screen the debug mode should start.
  46040. * The value goes from -1 (full screen) to 1 (not visible)
  46041. * It helps with side by side comparison against the final render
  46042. * This defaults to -1
  46043. */
  46044. private debugLimit;
  46045. /**
  46046. * @hidden
  46047. * This is reserved for the inspector.
  46048. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46049. * You can use the factor to better multiply the final value.
  46050. */
  46051. private debugFactor;
  46052. /**
  46053. * Defines the clear coat layer parameters for the material.
  46054. */
  46055. readonly clearCoat: PBRClearCoatConfiguration;
  46056. /**
  46057. * Defines the anisotropic parameters for the material.
  46058. */
  46059. readonly anisotropy: PBRAnisotropicConfiguration;
  46060. /**
  46061. * Defines the BRDF parameters for the material.
  46062. */
  46063. readonly brdf: PBRBRDFConfiguration;
  46064. /**
  46065. * Defines the Sheen parameters for the material.
  46066. */
  46067. readonly sheen: PBRSheenConfiguration;
  46068. /**
  46069. * Defines the SubSurface parameters for the material.
  46070. */
  46071. readonly subSurface: PBRSubSurfaceConfiguration;
  46072. /**
  46073. * Custom callback helping to override the default shader used in the material.
  46074. */
  46075. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46076. /**
  46077. * Instantiates a new PBRMaterial instance.
  46078. *
  46079. * @param name The material name
  46080. * @param scene The scene the material will be use in.
  46081. */
  46082. constructor(name: string, scene: Scene);
  46083. /**
  46084. * Gets a boolean indicating that current material needs to register RTT
  46085. */
  46086. readonly hasRenderTargetTextures: boolean;
  46087. /**
  46088. * Gets the name of the material class.
  46089. */
  46090. getClassName(): string;
  46091. /**
  46092. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46093. */
  46094. /**
  46095. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46096. */
  46097. useLogarithmicDepth: boolean;
  46098. /**
  46099. * Gets the current transparency mode.
  46100. */
  46101. /**
  46102. * Sets the transparency mode of the material.
  46103. *
  46104. * | Value | Type | Description |
  46105. * | ----- | ----------------------------------- | ----------- |
  46106. * | 0 | OPAQUE | |
  46107. * | 1 | ALPHATEST | |
  46108. * | 2 | ALPHABLEND | |
  46109. * | 3 | ALPHATESTANDBLEND | |
  46110. *
  46111. */
  46112. transparencyMode: Nullable<number>;
  46113. /**
  46114. * Returns true if alpha blending should be disabled.
  46115. */
  46116. private readonly _disableAlphaBlending;
  46117. /**
  46118. * Specifies whether or not this material should be rendered in alpha blend mode.
  46119. */
  46120. needAlphaBlending(): boolean;
  46121. /**
  46122. * Specifies if the mesh will require alpha blending.
  46123. * @param mesh - BJS mesh.
  46124. */
  46125. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46126. /**
  46127. * Specifies whether or not this material should be rendered in alpha test mode.
  46128. */
  46129. needAlphaTesting(): boolean;
  46130. /**
  46131. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  46132. */
  46133. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  46134. /**
  46135. * Gets the texture used for the alpha test.
  46136. */
  46137. getAlphaTestTexture(): Nullable<BaseTexture>;
  46138. /**
  46139. * Specifies that the submesh is ready to be used.
  46140. * @param mesh - BJS mesh.
  46141. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  46142. * @param useInstances - Specifies that instances should be used.
  46143. * @returns - boolean indicating that the submesh is ready or not.
  46144. */
  46145. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  46146. /**
  46147. * Specifies if the material uses metallic roughness workflow.
  46148. * @returns boolean specifiying if the material uses metallic roughness workflow.
  46149. */
  46150. isMetallicWorkflow(): boolean;
  46151. private _prepareEffect;
  46152. private _prepareDefines;
  46153. /**
  46154. * Force shader compilation
  46155. */
  46156. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  46157. clipPlane: boolean;
  46158. }>): void;
  46159. /**
  46160. * Initializes the uniform buffer layout for the shader.
  46161. */
  46162. buildUniformLayout(): void;
  46163. /**
  46164. * Unbinds the material from the mesh
  46165. */
  46166. unbind(): void;
  46167. /**
  46168. * Binds the submesh data.
  46169. * @param world - The world matrix.
  46170. * @param mesh - The BJS mesh.
  46171. * @param subMesh - A submesh of the BJS mesh.
  46172. */
  46173. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  46174. /**
  46175. * Returns the animatable textures.
  46176. * @returns - Array of animatable textures.
  46177. */
  46178. getAnimatables(): IAnimatable[];
  46179. /**
  46180. * Returns the texture used for reflections.
  46181. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  46182. */
  46183. private _getReflectionTexture;
  46184. /**
  46185. * Returns an array of the actively used textures.
  46186. * @returns - Array of BaseTextures
  46187. */
  46188. getActiveTextures(): BaseTexture[];
  46189. /**
  46190. * Checks to see if a texture is used in the material.
  46191. * @param texture - Base texture to use.
  46192. * @returns - Boolean specifying if a texture is used in the material.
  46193. */
  46194. hasTexture(texture: BaseTexture): boolean;
  46195. /**
  46196. * Disposes the resources of the material.
  46197. * @param forceDisposeEffect - Forces the disposal of effects.
  46198. * @param forceDisposeTextures - Forces the disposal of all textures.
  46199. */
  46200. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  46201. }
  46202. }
  46203. declare module BABYLON {
  46204. /**
  46205. * The Physically based material of BJS.
  46206. *
  46207. * This offers the main features of a standard PBR material.
  46208. * For more information, please refer to the documentation :
  46209. * https://doc.babylonjs.com/how_to/physically_based_rendering
  46210. */
  46211. export class PBRMaterial extends PBRBaseMaterial {
  46212. /**
  46213. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46214. */
  46215. static readonly PBRMATERIAL_OPAQUE: number;
  46216. /**
  46217. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46218. */
  46219. static readonly PBRMATERIAL_ALPHATEST: number;
  46220. /**
  46221. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46222. */
  46223. static readonly PBRMATERIAL_ALPHABLEND: number;
  46224. /**
  46225. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46226. * They are also discarded below the alpha cutoff threshold to improve performances.
  46227. */
  46228. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46229. /**
  46230. * Defines the default value of how much AO map is occluding the analytical lights
  46231. * (point spot...).
  46232. */
  46233. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46234. /**
  46235. * Intensity of the direct lights e.g. the four lights available in your scene.
  46236. * This impacts both the direct diffuse and specular highlights.
  46237. */
  46238. directIntensity: number;
  46239. /**
  46240. * Intensity of the emissive part of the material.
  46241. * This helps controlling the emissive effect without modifying the emissive color.
  46242. */
  46243. emissiveIntensity: number;
  46244. /**
  46245. * Intensity of the environment e.g. how much the environment will light the object
  46246. * either through harmonics for rough material or through the refelction for shiny ones.
  46247. */
  46248. environmentIntensity: number;
  46249. /**
  46250. * This is a special control allowing the reduction of the specular highlights coming from the
  46251. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46252. */
  46253. specularIntensity: number;
  46254. /**
  46255. * Debug Control allowing disabling the bump map on this material.
  46256. */
  46257. disableBumpMap: boolean;
  46258. /**
  46259. * AKA Diffuse Texture in standard nomenclature.
  46260. */
  46261. albedoTexture: BaseTexture;
  46262. /**
  46263. * AKA Occlusion Texture in other nomenclature.
  46264. */
  46265. ambientTexture: BaseTexture;
  46266. /**
  46267. * AKA Occlusion Texture Intensity in other nomenclature.
  46268. */
  46269. ambientTextureStrength: number;
  46270. /**
  46271. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46272. * 1 means it completely occludes it
  46273. * 0 mean it has no impact
  46274. */
  46275. ambientTextureImpactOnAnalyticalLights: number;
  46276. /**
  46277. * Stores the alpha values in a texture.
  46278. */
  46279. opacityTexture: BaseTexture;
  46280. /**
  46281. * Stores the reflection values in a texture.
  46282. */
  46283. reflectionTexture: Nullable<BaseTexture>;
  46284. /**
  46285. * Stores the emissive values in a texture.
  46286. */
  46287. emissiveTexture: BaseTexture;
  46288. /**
  46289. * AKA Specular texture in other nomenclature.
  46290. */
  46291. reflectivityTexture: BaseTexture;
  46292. /**
  46293. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46294. */
  46295. metallicTexture: BaseTexture;
  46296. /**
  46297. * Specifies the metallic scalar of the metallic/roughness workflow.
  46298. * Can also be used to scale the metalness values of the metallic texture.
  46299. */
  46300. metallic: Nullable<number>;
  46301. /**
  46302. * Specifies the roughness scalar of the metallic/roughness workflow.
  46303. * Can also be used to scale the roughness values of the metallic texture.
  46304. */
  46305. roughness: Nullable<number>;
  46306. /**
  46307. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46308. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46309. */
  46310. microSurfaceTexture: BaseTexture;
  46311. /**
  46312. * Stores surface normal data used to displace a mesh in a texture.
  46313. */
  46314. bumpTexture: BaseTexture;
  46315. /**
  46316. * Stores the pre-calculated light information of a mesh in a texture.
  46317. */
  46318. lightmapTexture: BaseTexture;
  46319. /**
  46320. * Stores the refracted light information in a texture.
  46321. */
  46322. refractionTexture: Nullable<BaseTexture>;
  46323. /**
  46324. * The color of a material in ambient lighting.
  46325. */
  46326. ambientColor: Color3;
  46327. /**
  46328. * AKA Diffuse Color in other nomenclature.
  46329. */
  46330. albedoColor: Color3;
  46331. /**
  46332. * AKA Specular Color in other nomenclature.
  46333. */
  46334. reflectivityColor: Color3;
  46335. /**
  46336. * The color reflected from the material.
  46337. */
  46338. reflectionColor: Color3;
  46339. /**
  46340. * The color emitted from the material.
  46341. */
  46342. emissiveColor: Color3;
  46343. /**
  46344. * AKA Glossiness in other nomenclature.
  46345. */
  46346. microSurface: number;
  46347. /**
  46348. * source material index of refraction (IOR)' / 'destination material IOR.
  46349. */
  46350. indexOfRefraction: number;
  46351. /**
  46352. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46353. */
  46354. invertRefractionY: boolean;
  46355. /**
  46356. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46357. * Materials half opaque for instance using refraction could benefit from this control.
  46358. */
  46359. linkRefractionWithTransparency: boolean;
  46360. /**
  46361. * If true, the light map contains occlusion information instead of lighting info.
  46362. */
  46363. useLightmapAsShadowmap: boolean;
  46364. /**
  46365. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46366. */
  46367. useAlphaFromAlbedoTexture: boolean;
  46368. /**
  46369. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46370. */
  46371. forceAlphaTest: boolean;
  46372. /**
  46373. * Defines the alpha limits in alpha test mode.
  46374. */
  46375. alphaCutOff: number;
  46376. /**
  46377. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  46378. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46379. */
  46380. useSpecularOverAlpha: boolean;
  46381. /**
  46382. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46383. */
  46384. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46385. /**
  46386. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46387. */
  46388. useRoughnessFromMetallicTextureAlpha: boolean;
  46389. /**
  46390. * Specifies if the metallic texture contains the roughness information in its green channel.
  46391. */
  46392. useRoughnessFromMetallicTextureGreen: boolean;
  46393. /**
  46394. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46395. */
  46396. useMetallnessFromMetallicTextureBlue: boolean;
  46397. /**
  46398. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46399. */
  46400. useAmbientOcclusionFromMetallicTextureRed: boolean;
  46401. /**
  46402. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46403. */
  46404. useAmbientInGrayScale: boolean;
  46405. /**
  46406. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46407. * The material will try to infer what glossiness each pixel should be.
  46408. */
  46409. useAutoMicroSurfaceFromReflectivityMap: boolean;
  46410. /**
  46411. * BJS is using an harcoded light falloff based on a manually sets up range.
  46412. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46413. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46414. */
  46415. /**
  46416. * BJS is using an harcoded light falloff based on a manually sets up range.
  46417. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  46418. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  46419. */
  46420. usePhysicalLightFalloff: boolean;
  46421. /**
  46422. * In order to support the falloff compatibility with gltf, a special mode has been added
  46423. * to reproduce the gltf light falloff.
  46424. */
  46425. /**
  46426. * In order to support the falloff compatibility with gltf, a special mode has been added
  46427. * to reproduce the gltf light falloff.
  46428. */
  46429. useGLTFLightFalloff: boolean;
  46430. /**
  46431. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46432. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46433. */
  46434. useRadianceOverAlpha: boolean;
  46435. /**
  46436. * Allows using an object space normal map (instead of tangent space).
  46437. */
  46438. useObjectSpaceNormalMap: boolean;
  46439. /**
  46440. * Allows using the bump map in parallax mode.
  46441. */
  46442. useParallax: boolean;
  46443. /**
  46444. * Allows using the bump map in parallax occlusion mode.
  46445. */
  46446. useParallaxOcclusion: boolean;
  46447. /**
  46448. * Controls the scale bias of the parallax mode.
  46449. */
  46450. parallaxScaleBias: number;
  46451. /**
  46452. * If sets to true, disables all the lights affecting the material.
  46453. */
  46454. disableLighting: boolean;
  46455. /**
  46456. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46457. */
  46458. forceIrradianceInFragment: boolean;
  46459. /**
  46460. * Number of Simultaneous lights allowed on the material.
  46461. */
  46462. maxSimultaneousLights: number;
  46463. /**
  46464. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  46465. */
  46466. invertNormalMapX: boolean;
  46467. /**
  46468. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  46469. */
  46470. invertNormalMapY: boolean;
  46471. /**
  46472. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46473. */
  46474. twoSidedLighting: boolean;
  46475. /**
  46476. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46477. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46478. */
  46479. useAlphaFresnel: boolean;
  46480. /**
  46481. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46482. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46483. */
  46484. useLinearAlphaFresnel: boolean;
  46485. /**
  46486. * Let user defines the brdf lookup texture used for IBL.
  46487. * A default 8bit version is embedded but you could point at :
  46488. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  46489. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  46490. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  46491. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  46492. */
  46493. environmentBRDFTexture: Nullable<BaseTexture>;
  46494. /**
  46495. * Force normal to face away from face.
  46496. */
  46497. forceNormalForward: boolean;
  46498. /**
  46499. * Enables specular anti aliasing in the PBR shader.
  46500. * It will both interacts on the Geometry for analytical and IBL lighting.
  46501. * It also prefilter the roughness map based on the bump values.
  46502. */
  46503. enableSpecularAntiAliasing: boolean;
  46504. /**
  46505. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46506. * makes the reflect vector face the model (under horizon).
  46507. */
  46508. useHorizonOcclusion: boolean;
  46509. /**
  46510. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46511. * too much the area relying on ambient texture to define their ambient occlusion.
  46512. */
  46513. useRadianceOcclusion: boolean;
  46514. /**
  46515. * If set to true, no lighting calculations will be applied.
  46516. */
  46517. unlit: boolean;
  46518. /**
  46519. * Gets the image processing configuration used either in this material.
  46520. */
  46521. /**
  46522. * Sets the Default image processing configuration used either in the this material.
  46523. *
  46524. * If sets to null, the scene one is in use.
  46525. */
  46526. imageProcessingConfiguration: ImageProcessingConfiguration;
  46527. /**
  46528. * Gets wether the color curves effect is enabled.
  46529. */
  46530. /**
  46531. * Sets wether the color curves effect is enabled.
  46532. */
  46533. cameraColorCurvesEnabled: boolean;
  46534. /**
  46535. * Gets wether the color grading effect is enabled.
  46536. */
  46537. /**
  46538. * Gets wether the color grading effect is enabled.
  46539. */
  46540. cameraColorGradingEnabled: boolean;
  46541. /**
  46542. * Gets wether tonemapping is enabled or not.
  46543. */
  46544. /**
  46545. * Sets wether tonemapping is enabled or not
  46546. */
  46547. cameraToneMappingEnabled: boolean;
  46548. /**
  46549. * The camera exposure used on this material.
  46550. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46551. * This corresponds to a photographic exposure.
  46552. */
  46553. /**
  46554. * The camera exposure used on this material.
  46555. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  46556. * This corresponds to a photographic exposure.
  46557. */
  46558. cameraExposure: number;
  46559. /**
  46560. * Gets The camera contrast used on this material.
  46561. */
  46562. /**
  46563. * Sets The camera contrast used on this material.
  46564. */
  46565. cameraContrast: number;
  46566. /**
  46567. * Gets the Color Grading 2D Lookup Texture.
  46568. */
  46569. /**
  46570. * Sets the Color Grading 2D Lookup Texture.
  46571. */
  46572. cameraColorGradingTexture: Nullable<BaseTexture>;
  46573. /**
  46574. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46575. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46576. * 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;
  46577. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46578. */
  46579. /**
  46580. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  46581. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  46582. * 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;
  46583. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  46584. */
  46585. cameraColorCurves: Nullable<ColorCurves>;
  46586. /**
  46587. * Instantiates a new PBRMaterial instance.
  46588. *
  46589. * @param name The material name
  46590. * @param scene The scene the material will be use in.
  46591. */
  46592. constructor(name: string, scene: Scene);
  46593. /**
  46594. * Returns the name of this material class.
  46595. */
  46596. getClassName(): string;
  46597. /**
  46598. * Makes a duplicate of the current material.
  46599. * @param name - name to use for the new material.
  46600. */
  46601. clone(name: string): PBRMaterial;
  46602. /**
  46603. * Serializes this PBR Material.
  46604. * @returns - An object with the serialized material.
  46605. */
  46606. serialize(): any;
  46607. /**
  46608. * Parses a PBR Material from a serialized object.
  46609. * @param source - Serialized object.
  46610. * @param scene - BJS scene instance.
  46611. * @param rootUrl - url for the scene object
  46612. * @returns - PBRMaterial
  46613. */
  46614. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  46615. }
  46616. }
  46617. declare module BABYLON {
  46618. /**
  46619. * Direct draw surface info
  46620. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  46621. */
  46622. export interface DDSInfo {
  46623. /**
  46624. * Width of the texture
  46625. */
  46626. width: number;
  46627. /**
  46628. * Width of the texture
  46629. */
  46630. height: number;
  46631. /**
  46632. * Number of Mipmaps for the texture
  46633. * @see https://en.wikipedia.org/wiki/Mipmap
  46634. */
  46635. mipmapCount: number;
  46636. /**
  46637. * If the textures format is a known fourCC format
  46638. * @see https://www.fourcc.org/
  46639. */
  46640. isFourCC: boolean;
  46641. /**
  46642. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  46643. */
  46644. isRGB: boolean;
  46645. /**
  46646. * If the texture is a lumincance format
  46647. */
  46648. isLuminance: boolean;
  46649. /**
  46650. * If this is a cube texture
  46651. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  46652. */
  46653. isCube: boolean;
  46654. /**
  46655. * If the texture is a compressed format eg. FOURCC_DXT1
  46656. */
  46657. isCompressed: boolean;
  46658. /**
  46659. * The dxgiFormat of the texture
  46660. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  46661. */
  46662. dxgiFormat: number;
  46663. /**
  46664. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  46665. */
  46666. textureType: number;
  46667. /**
  46668. * Sphericle polynomial created for the dds texture
  46669. */
  46670. sphericalPolynomial?: SphericalPolynomial;
  46671. }
  46672. /**
  46673. * Class used to provide DDS decompression tools
  46674. */
  46675. export class DDSTools {
  46676. /**
  46677. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  46678. */
  46679. static StoreLODInAlphaChannel: boolean;
  46680. /**
  46681. * Gets DDS information from an array buffer
  46682. * @param arrayBuffer defines the array buffer to read data from
  46683. * @returns the DDS information
  46684. */
  46685. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  46686. private static _FloatView;
  46687. private static _Int32View;
  46688. private static _ToHalfFloat;
  46689. private static _FromHalfFloat;
  46690. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  46691. private static _GetHalfFloatRGBAArrayBuffer;
  46692. private static _GetFloatRGBAArrayBuffer;
  46693. private static _GetFloatAsUIntRGBAArrayBuffer;
  46694. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  46695. private static _GetRGBAArrayBuffer;
  46696. private static _ExtractLongWordOrder;
  46697. private static _GetRGBArrayBuffer;
  46698. private static _GetLuminanceArrayBuffer;
  46699. /**
  46700. * Uploads DDS Levels to a Babylon Texture
  46701. * @hidden
  46702. */
  46703. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  46704. }
  46705. interface Engine {
  46706. /**
  46707. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  46708. * @param rootUrl defines the url where the file to load is located
  46709. * @param scene defines the current scene
  46710. * @param lodScale defines scale to apply to the mip map selection
  46711. * @param lodOffset defines offset to apply to the mip map selection
  46712. * @param onLoad defines an optional callback raised when the texture is loaded
  46713. * @param onError defines an optional callback raised if there is an issue to load the texture
  46714. * @param format defines the format of the data
  46715. * @param forcedExtension defines the extension to use to pick the right loader
  46716. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  46717. * @returns the cube texture as an InternalTexture
  46718. */
  46719. 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;
  46720. }
  46721. }
  46722. declare module BABYLON {
  46723. /**
  46724. * Implementation of the DDS Texture Loader.
  46725. * @hidden
  46726. */
  46727. export class _DDSTextureLoader implements IInternalTextureLoader {
  46728. /**
  46729. * Defines wether the loader supports cascade loading the different faces.
  46730. */
  46731. readonly supportCascades: boolean;
  46732. /**
  46733. * This returns if the loader support the current file information.
  46734. * @param extension defines the file extension of the file being loaded
  46735. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46736. * @param fallback defines the fallback internal texture if any
  46737. * @param isBase64 defines whether the texture is encoded as a base64
  46738. * @param isBuffer defines whether the texture data are stored as a buffer
  46739. * @returns true if the loader can load the specified file
  46740. */
  46741. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46742. /**
  46743. * Transform the url before loading if required.
  46744. * @param rootUrl the url of the texture
  46745. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46746. * @returns the transformed texture
  46747. */
  46748. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46749. /**
  46750. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46751. * @param rootUrl the url of the texture
  46752. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46753. * @returns the fallback texture
  46754. */
  46755. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46756. /**
  46757. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46758. * @param data contains the texture data
  46759. * @param texture defines the BabylonJS internal texture
  46760. * @param createPolynomials will be true if polynomials have been requested
  46761. * @param onLoad defines the callback to trigger once the texture is ready
  46762. * @param onError defines the callback to trigger in case of error
  46763. */
  46764. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46765. /**
  46766. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46767. * @param data contains the texture data
  46768. * @param texture defines the BabylonJS internal texture
  46769. * @param callback defines the method to call once ready to upload
  46770. */
  46771. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46772. }
  46773. }
  46774. declare module BABYLON {
  46775. /** @hidden */
  46776. export var rgbdEncodePixelShader: {
  46777. name: string;
  46778. shader: string;
  46779. };
  46780. }
  46781. declare module BABYLON {
  46782. /**
  46783. * Raw texture data and descriptor sufficient for WebGL texture upload
  46784. */
  46785. export interface EnvironmentTextureInfo {
  46786. /**
  46787. * Version of the environment map
  46788. */
  46789. version: number;
  46790. /**
  46791. * Width of image
  46792. */
  46793. width: number;
  46794. /**
  46795. * Irradiance information stored in the file.
  46796. */
  46797. irradiance: any;
  46798. /**
  46799. * Specular information stored in the file.
  46800. */
  46801. specular: any;
  46802. }
  46803. /**
  46804. * Sets of helpers addressing the serialization and deserialization of environment texture
  46805. * stored in a BabylonJS env file.
  46806. * Those files are usually stored as .env files.
  46807. */
  46808. export class EnvironmentTextureTools {
  46809. /**
  46810. * Magic number identifying the env file.
  46811. */
  46812. private static _MagicBytes;
  46813. /**
  46814. * Gets the environment info from an env file.
  46815. * @param data The array buffer containing the .env bytes.
  46816. * @returns the environment file info (the json header) if successfully parsed.
  46817. */
  46818. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46819. /**
  46820. * Creates an environment texture from a loaded cube texture.
  46821. * @param texture defines the cube texture to convert in env file
  46822. * @return a promise containing the environment data if succesfull.
  46823. */
  46824. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46825. /**
  46826. * Creates a JSON representation of the spherical data.
  46827. * @param texture defines the texture containing the polynomials
  46828. * @return the JSON representation of the spherical info
  46829. */
  46830. private static _CreateEnvTextureIrradiance;
  46831. /**
  46832. * Uploads the texture info contained in the env file to the GPU.
  46833. * @param texture defines the internal texture to upload to
  46834. * @param arrayBuffer defines the buffer cotaining the data to load
  46835. * @param info defines the texture info retrieved through the GetEnvInfo method
  46836. * @returns a promise
  46837. */
  46838. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46839. /**
  46840. * Uploads the levels of image data to the GPU.
  46841. * @param texture defines the internal texture to upload to
  46842. * @param imageData defines the array buffer views of image data [mipmap][face]
  46843. * @returns a promise
  46844. */
  46845. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46846. /**
  46847. * Uploads spherical polynomials information to the texture.
  46848. * @param texture defines the texture we are trying to upload the information to
  46849. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46850. */
  46851. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46852. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46853. }
  46854. }
  46855. declare module BABYLON {
  46856. /**
  46857. * Implementation of the ENV Texture Loader.
  46858. * @hidden
  46859. */
  46860. export class _ENVTextureLoader implements IInternalTextureLoader {
  46861. /**
  46862. * Defines wether the loader supports cascade loading the different faces.
  46863. */
  46864. readonly supportCascades: boolean;
  46865. /**
  46866. * This returns if the loader support the current file information.
  46867. * @param extension defines the file extension of the file being loaded
  46868. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46869. * @param fallback defines the fallback internal texture if any
  46870. * @param isBase64 defines whether the texture is encoded as a base64
  46871. * @param isBuffer defines whether the texture data are stored as a buffer
  46872. * @returns true if the loader can load the specified file
  46873. */
  46874. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  46875. /**
  46876. * Transform the url before loading if required.
  46877. * @param rootUrl the url of the texture
  46878. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46879. * @returns the transformed texture
  46880. */
  46881. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  46882. /**
  46883. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  46884. * @param rootUrl the url of the texture
  46885. * @param textureFormatInUse defines the current compressed format in use iun the engine
  46886. * @returns the fallback texture
  46887. */
  46888. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  46889. /**
  46890. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  46891. * @param data contains the texture data
  46892. * @param texture defines the BabylonJS internal texture
  46893. * @param createPolynomials will be true if polynomials have been requested
  46894. * @param onLoad defines the callback to trigger once the texture is ready
  46895. * @param onError defines the callback to trigger in case of error
  46896. */
  46897. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  46898. /**
  46899. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  46900. * @param data contains the texture data
  46901. * @param texture defines the BabylonJS internal texture
  46902. * @param callback defines the method to call once ready to upload
  46903. */
  46904. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  46905. }
  46906. }
  46907. declare module BABYLON {
  46908. /**
  46909. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  46910. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  46911. */
  46912. export class KhronosTextureContainer {
  46913. /** contents of the KTX container file */
  46914. arrayBuffer: any;
  46915. private static HEADER_LEN;
  46916. private static COMPRESSED_2D;
  46917. private static COMPRESSED_3D;
  46918. private static TEX_2D;
  46919. private static TEX_3D;
  46920. /**
  46921. * Gets the openGL type
  46922. */
  46923. glType: number;
  46924. /**
  46925. * Gets the openGL type size
  46926. */
  46927. glTypeSize: number;
  46928. /**
  46929. * Gets the openGL format
  46930. */
  46931. glFormat: number;
  46932. /**
  46933. * Gets the openGL internal format
  46934. */
  46935. glInternalFormat: number;
  46936. /**
  46937. * Gets the base internal format
  46938. */
  46939. glBaseInternalFormat: number;
  46940. /**
  46941. * Gets image width in pixel
  46942. */
  46943. pixelWidth: number;
  46944. /**
  46945. * Gets image height in pixel
  46946. */
  46947. pixelHeight: number;
  46948. /**
  46949. * Gets image depth in pixels
  46950. */
  46951. pixelDepth: number;
  46952. /**
  46953. * Gets the number of array elements
  46954. */
  46955. numberOfArrayElements: number;
  46956. /**
  46957. * Gets the number of faces
  46958. */
  46959. numberOfFaces: number;
  46960. /**
  46961. * Gets the number of mipmap levels
  46962. */
  46963. numberOfMipmapLevels: number;
  46964. /**
  46965. * Gets the bytes of key value data
  46966. */
  46967. bytesOfKeyValueData: number;
  46968. /**
  46969. * Gets the load type
  46970. */
  46971. loadType: number;
  46972. /**
  46973. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  46974. */
  46975. isInvalid: boolean;
  46976. /**
  46977. * Creates a new KhronosTextureContainer
  46978. * @param arrayBuffer contents of the KTX container file
  46979. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  46980. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  46981. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  46982. */
  46983. constructor(
  46984. /** contents of the KTX container file */
  46985. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  46986. /**
  46987. * Uploads KTX content to a Babylon Texture.
  46988. * It is assumed that the texture has already been created & is currently bound
  46989. * @hidden
  46990. */
  46991. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  46992. private _upload2DCompressedLevels;
  46993. }
  46994. }
  46995. declare module BABYLON {
  46996. /**
  46997. * Implementation of the KTX Texture Loader.
  46998. * @hidden
  46999. */
  47000. export class _KTXTextureLoader implements IInternalTextureLoader {
  47001. /**
  47002. * Defines wether the loader supports cascade loading the different faces.
  47003. */
  47004. readonly supportCascades: boolean;
  47005. /**
  47006. * This returns if the loader support the current file information.
  47007. * @param extension defines the file extension of the file being loaded
  47008. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47009. * @param fallback defines the fallback internal texture if any
  47010. * @param isBase64 defines whether the texture is encoded as a base64
  47011. * @param isBuffer defines whether the texture data are stored as a buffer
  47012. * @returns true if the loader can load the specified file
  47013. */
  47014. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47015. /**
  47016. * Transform the url before loading if required.
  47017. * @param rootUrl the url of the texture
  47018. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47019. * @returns the transformed texture
  47020. */
  47021. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47022. /**
  47023. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47024. * @param rootUrl the url of the texture
  47025. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47026. * @returns the fallback texture
  47027. */
  47028. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47029. /**
  47030. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47031. * @param data contains the texture data
  47032. * @param texture defines the BabylonJS internal texture
  47033. * @param createPolynomials will be true if polynomials have been requested
  47034. * @param onLoad defines the callback to trigger once the texture is ready
  47035. * @param onError defines the callback to trigger in case of error
  47036. */
  47037. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47038. /**
  47039. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47040. * @param data contains the texture data
  47041. * @param texture defines the BabylonJS internal texture
  47042. * @param callback defines the method to call once ready to upload
  47043. */
  47044. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47045. }
  47046. }
  47047. declare module BABYLON {
  47048. /**
  47049. * Options for the default xr helper
  47050. */
  47051. export class WebXRDefaultExperienceOptions {
  47052. /**
  47053. * Floor meshes that should be used for teleporting
  47054. */
  47055. floorMeshes: Array<AbstractMesh>;
  47056. }
  47057. /**
  47058. * Default experience which provides a similar setup to the previous webVRExperience
  47059. */
  47060. export class WebXRDefaultExperience {
  47061. /**
  47062. * Base experience
  47063. */
  47064. baseExperience: WebXRExperienceHelper;
  47065. /**
  47066. * Input experience extension
  47067. */
  47068. input: WebXRInput;
  47069. /**
  47070. * Loads the controller models
  47071. */
  47072. controllerModelLoader: WebXRControllerModelLoader;
  47073. /**
  47074. * Enables laser pointer and selection
  47075. */
  47076. pointerSelection: WebXRControllerPointerSelection;
  47077. /**
  47078. * Enables teleportation
  47079. */
  47080. teleportation: WebXRControllerTeleportation;
  47081. /**
  47082. * Enables ui for enetering/exiting xr
  47083. */
  47084. enterExitUI: WebXREnterExitUI;
  47085. /**
  47086. * Default output canvas xr should render to
  47087. */
  47088. outputCanvas: WebXRManagedOutputCanvas;
  47089. /**
  47090. * Creates the default xr experience
  47091. * @param scene scene
  47092. * @param options options for basic configuration
  47093. * @returns resulting WebXRDefaultExperience
  47094. */
  47095. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47096. private constructor();
  47097. /**
  47098. * DIsposes of the experience helper
  47099. */
  47100. dispose(): void;
  47101. }
  47102. }
  47103. declare module BABYLON {
  47104. /** @hidden */
  47105. export var _forceSceneHelpersToBundle: boolean;
  47106. interface Scene {
  47107. /**
  47108. * Creates a default light for the scene.
  47109. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47110. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47111. */
  47112. createDefaultLight(replace?: boolean): void;
  47113. /**
  47114. * Creates a default camera for the scene.
  47115. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47116. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47117. * @param replace has default false, when true replaces the active camera in the scene
  47118. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47119. */
  47120. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47121. /**
  47122. * Creates a default camera and a default light.
  47123. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47124. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47125. * @param replace has the default false, when true replaces the active camera/light in the scene
  47126. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47127. */
  47128. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47129. /**
  47130. * Creates a new sky box
  47131. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47132. * @param environmentTexture defines the texture to use as environment texture
  47133. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47134. * @param scale defines the overall scale of the skybox
  47135. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47136. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47137. * @returns a new mesh holding the sky box
  47138. */
  47139. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47140. /**
  47141. * Creates a new environment
  47142. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  47143. * @param options defines the options you can use to configure the environment
  47144. * @returns the new EnvironmentHelper
  47145. */
  47146. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  47147. /**
  47148. * Creates a new VREXperienceHelper
  47149. * @see http://doc.babylonjs.com/how_to/webvr_helper
  47150. * @param webVROptions defines the options used to create the new VREXperienceHelper
  47151. * @returns a new VREXperienceHelper
  47152. */
  47153. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  47154. /**
  47155. * Creates a new WebXRDefaultExperience
  47156. * @see http://doc.babylonjs.com/how_to/webxr
  47157. * @param options experience options
  47158. * @returns a promise for a new WebXRDefaultExperience
  47159. */
  47160. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47161. }
  47162. }
  47163. declare module BABYLON {
  47164. /**
  47165. * Contains position and normal vectors for a vertex
  47166. */
  47167. export class PositionNormalVertex {
  47168. /** the position of the vertex (defaut: 0,0,0) */
  47169. position: Vector3;
  47170. /** the normal of the vertex (defaut: 0,1,0) */
  47171. normal: Vector3;
  47172. /**
  47173. * Creates a PositionNormalVertex
  47174. * @param position the position of the vertex (defaut: 0,0,0)
  47175. * @param normal the normal of the vertex (defaut: 0,1,0)
  47176. */
  47177. constructor(
  47178. /** the position of the vertex (defaut: 0,0,0) */
  47179. position?: Vector3,
  47180. /** the normal of the vertex (defaut: 0,1,0) */
  47181. normal?: Vector3);
  47182. /**
  47183. * Clones the PositionNormalVertex
  47184. * @returns the cloned PositionNormalVertex
  47185. */
  47186. clone(): PositionNormalVertex;
  47187. }
  47188. /**
  47189. * Contains position, normal and uv vectors for a vertex
  47190. */
  47191. export class PositionNormalTextureVertex {
  47192. /** the position of the vertex (defaut: 0,0,0) */
  47193. position: Vector3;
  47194. /** the normal of the vertex (defaut: 0,1,0) */
  47195. normal: Vector3;
  47196. /** the uv of the vertex (default: 0,0) */
  47197. uv: Vector2;
  47198. /**
  47199. * Creates a PositionNormalTextureVertex
  47200. * @param position the position of the vertex (defaut: 0,0,0)
  47201. * @param normal the normal of the vertex (defaut: 0,1,0)
  47202. * @param uv the uv of the vertex (default: 0,0)
  47203. */
  47204. constructor(
  47205. /** the position of the vertex (defaut: 0,0,0) */
  47206. position?: Vector3,
  47207. /** the normal of the vertex (defaut: 0,1,0) */
  47208. normal?: Vector3,
  47209. /** the uv of the vertex (default: 0,0) */
  47210. uv?: Vector2);
  47211. /**
  47212. * Clones the PositionNormalTextureVertex
  47213. * @returns the cloned PositionNormalTextureVertex
  47214. */
  47215. clone(): PositionNormalTextureVertex;
  47216. }
  47217. }
  47218. declare module BABYLON {
  47219. /**
  47220. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  47221. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  47222. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  47223. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  47224. */
  47225. export class VideoDome extends TransformNode {
  47226. /**
  47227. * Define the video source as a Monoscopic panoramic 360 video.
  47228. */
  47229. static readonly MODE_MONOSCOPIC: number;
  47230. /**
  47231. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47232. */
  47233. static readonly MODE_TOPBOTTOM: number;
  47234. /**
  47235. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47236. */
  47237. static readonly MODE_SIDEBYSIDE: number;
  47238. private _halfDome;
  47239. private _useDirectMapping;
  47240. /**
  47241. * The video texture being displayed on the sphere
  47242. */
  47243. protected _videoTexture: VideoTexture;
  47244. /**
  47245. * Gets the video texture being displayed on the sphere
  47246. */
  47247. readonly videoTexture: VideoTexture;
  47248. /**
  47249. * The skybox material
  47250. */
  47251. protected _material: BackgroundMaterial;
  47252. /**
  47253. * The surface used for the skybox
  47254. */
  47255. protected _mesh: Mesh;
  47256. /**
  47257. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  47258. */
  47259. private _halfDomeMask;
  47260. /**
  47261. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47262. * Also see the options.resolution property.
  47263. */
  47264. fovMultiplier: number;
  47265. private _videoMode;
  47266. /**
  47267. * Gets or set the current video mode for the video. It can be:
  47268. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  47269. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  47270. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  47271. */
  47272. videoMode: number;
  47273. /**
  47274. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  47275. *
  47276. */
  47277. /**
  47278. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  47279. */
  47280. halfDome: boolean;
  47281. /**
  47282. * Oberserver used in Stereoscopic VR Mode.
  47283. */
  47284. private _onBeforeCameraRenderObserver;
  47285. /**
  47286. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  47287. * @param name Element's name, child elements will append suffixes for their own names.
  47288. * @param urlsOrVideo defines the url(s) or the video element to use
  47289. * @param options An object containing optional or exposed sub element properties
  47290. */
  47291. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  47292. resolution?: number;
  47293. clickToPlay?: boolean;
  47294. autoPlay?: boolean;
  47295. loop?: boolean;
  47296. size?: number;
  47297. poster?: string;
  47298. faceForward?: boolean;
  47299. useDirectMapping?: boolean;
  47300. halfDomeMode?: boolean;
  47301. }, scene: Scene);
  47302. private _changeVideoMode;
  47303. /**
  47304. * Releases resources associated with this node.
  47305. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  47306. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  47307. */
  47308. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  47309. }
  47310. }
  47311. declare module BABYLON {
  47312. /**
  47313. * This class can be used to get instrumentation data from a Babylon engine
  47314. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47315. */
  47316. export class EngineInstrumentation implements IDisposable {
  47317. /**
  47318. * Define the instrumented engine.
  47319. */
  47320. engine: Engine;
  47321. private _captureGPUFrameTime;
  47322. private _gpuFrameTimeToken;
  47323. private _gpuFrameTime;
  47324. private _captureShaderCompilationTime;
  47325. private _shaderCompilationTime;
  47326. private _onBeginFrameObserver;
  47327. private _onEndFrameObserver;
  47328. private _onBeforeShaderCompilationObserver;
  47329. private _onAfterShaderCompilationObserver;
  47330. /**
  47331. * Gets the perf counter used for GPU frame time
  47332. */
  47333. readonly gpuFrameTimeCounter: PerfCounter;
  47334. /**
  47335. * Gets the GPU frame time capture status
  47336. */
  47337. /**
  47338. * Enable or disable the GPU frame time capture
  47339. */
  47340. captureGPUFrameTime: boolean;
  47341. /**
  47342. * Gets the perf counter used for shader compilation time
  47343. */
  47344. readonly shaderCompilationTimeCounter: PerfCounter;
  47345. /**
  47346. * Gets the shader compilation time capture status
  47347. */
  47348. /**
  47349. * Enable or disable the shader compilation time capture
  47350. */
  47351. captureShaderCompilationTime: boolean;
  47352. /**
  47353. * Instantiates a new engine instrumentation.
  47354. * This class can be used to get instrumentation data from a Babylon engine
  47355. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  47356. * @param engine Defines the engine to instrument
  47357. */
  47358. constructor(
  47359. /**
  47360. * Define the instrumented engine.
  47361. */
  47362. engine: Engine);
  47363. /**
  47364. * Dispose and release associated resources.
  47365. */
  47366. dispose(): void;
  47367. }
  47368. }
  47369. declare module BABYLON {
  47370. /**
  47371. * This class can be used to get instrumentation data from a Babylon engine
  47372. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47373. */
  47374. export class SceneInstrumentation implements IDisposable {
  47375. /**
  47376. * Defines the scene to instrument
  47377. */
  47378. scene: Scene;
  47379. private _captureActiveMeshesEvaluationTime;
  47380. private _activeMeshesEvaluationTime;
  47381. private _captureRenderTargetsRenderTime;
  47382. private _renderTargetsRenderTime;
  47383. private _captureFrameTime;
  47384. private _frameTime;
  47385. private _captureRenderTime;
  47386. private _renderTime;
  47387. private _captureInterFrameTime;
  47388. private _interFrameTime;
  47389. private _captureParticlesRenderTime;
  47390. private _particlesRenderTime;
  47391. private _captureSpritesRenderTime;
  47392. private _spritesRenderTime;
  47393. private _capturePhysicsTime;
  47394. private _physicsTime;
  47395. private _captureAnimationsTime;
  47396. private _animationsTime;
  47397. private _captureCameraRenderTime;
  47398. private _cameraRenderTime;
  47399. private _onBeforeActiveMeshesEvaluationObserver;
  47400. private _onAfterActiveMeshesEvaluationObserver;
  47401. private _onBeforeRenderTargetsRenderObserver;
  47402. private _onAfterRenderTargetsRenderObserver;
  47403. private _onAfterRenderObserver;
  47404. private _onBeforeDrawPhaseObserver;
  47405. private _onAfterDrawPhaseObserver;
  47406. private _onBeforeAnimationsObserver;
  47407. private _onBeforeParticlesRenderingObserver;
  47408. private _onAfterParticlesRenderingObserver;
  47409. private _onBeforeSpritesRenderingObserver;
  47410. private _onAfterSpritesRenderingObserver;
  47411. private _onBeforePhysicsObserver;
  47412. private _onAfterPhysicsObserver;
  47413. private _onAfterAnimationsObserver;
  47414. private _onBeforeCameraRenderObserver;
  47415. private _onAfterCameraRenderObserver;
  47416. /**
  47417. * Gets the perf counter used for active meshes evaluation time
  47418. */
  47419. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  47420. /**
  47421. * Gets the active meshes evaluation time capture status
  47422. */
  47423. /**
  47424. * Enable or disable the active meshes evaluation time capture
  47425. */
  47426. captureActiveMeshesEvaluationTime: boolean;
  47427. /**
  47428. * Gets the perf counter used for render targets render time
  47429. */
  47430. readonly renderTargetsRenderTimeCounter: PerfCounter;
  47431. /**
  47432. * Gets the render targets render time capture status
  47433. */
  47434. /**
  47435. * Enable or disable the render targets render time capture
  47436. */
  47437. captureRenderTargetsRenderTime: boolean;
  47438. /**
  47439. * Gets the perf counter used for particles render time
  47440. */
  47441. readonly particlesRenderTimeCounter: PerfCounter;
  47442. /**
  47443. * Gets the particles render time capture status
  47444. */
  47445. /**
  47446. * Enable or disable the particles render time capture
  47447. */
  47448. captureParticlesRenderTime: boolean;
  47449. /**
  47450. * Gets the perf counter used for sprites render time
  47451. */
  47452. readonly spritesRenderTimeCounter: PerfCounter;
  47453. /**
  47454. * Gets the sprites render time capture status
  47455. */
  47456. /**
  47457. * Enable or disable the sprites render time capture
  47458. */
  47459. captureSpritesRenderTime: boolean;
  47460. /**
  47461. * Gets the perf counter used for physics time
  47462. */
  47463. readonly physicsTimeCounter: PerfCounter;
  47464. /**
  47465. * Gets the physics time capture status
  47466. */
  47467. /**
  47468. * Enable or disable the physics time capture
  47469. */
  47470. capturePhysicsTime: boolean;
  47471. /**
  47472. * Gets the perf counter used for animations time
  47473. */
  47474. readonly animationsTimeCounter: PerfCounter;
  47475. /**
  47476. * Gets the animations time capture status
  47477. */
  47478. /**
  47479. * Enable or disable the animations time capture
  47480. */
  47481. captureAnimationsTime: boolean;
  47482. /**
  47483. * Gets the perf counter used for frame time capture
  47484. */
  47485. readonly frameTimeCounter: PerfCounter;
  47486. /**
  47487. * Gets the frame time capture status
  47488. */
  47489. /**
  47490. * Enable or disable the frame time capture
  47491. */
  47492. captureFrameTime: boolean;
  47493. /**
  47494. * Gets the perf counter used for inter-frames time capture
  47495. */
  47496. readonly interFrameTimeCounter: PerfCounter;
  47497. /**
  47498. * Gets the inter-frames time capture status
  47499. */
  47500. /**
  47501. * Enable or disable the inter-frames time capture
  47502. */
  47503. captureInterFrameTime: boolean;
  47504. /**
  47505. * Gets the perf counter used for render time capture
  47506. */
  47507. readonly renderTimeCounter: PerfCounter;
  47508. /**
  47509. * Gets the render time capture status
  47510. */
  47511. /**
  47512. * Enable or disable the render time capture
  47513. */
  47514. captureRenderTime: boolean;
  47515. /**
  47516. * Gets the perf counter used for camera render time capture
  47517. */
  47518. readonly cameraRenderTimeCounter: PerfCounter;
  47519. /**
  47520. * Gets the camera render time capture status
  47521. */
  47522. /**
  47523. * Enable or disable the camera render time capture
  47524. */
  47525. captureCameraRenderTime: boolean;
  47526. /**
  47527. * Gets the perf counter used for draw calls
  47528. */
  47529. readonly drawCallsCounter: PerfCounter;
  47530. /**
  47531. * Instantiates a new scene instrumentation.
  47532. * This class can be used to get instrumentation data from a Babylon engine
  47533. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  47534. * @param scene Defines the scene to instrument
  47535. */
  47536. constructor(
  47537. /**
  47538. * Defines the scene to instrument
  47539. */
  47540. scene: Scene);
  47541. /**
  47542. * Dispose and release associated resources.
  47543. */
  47544. dispose(): void;
  47545. }
  47546. }
  47547. declare module BABYLON {
  47548. /** @hidden */
  47549. export var glowMapGenerationPixelShader: {
  47550. name: string;
  47551. shader: string;
  47552. };
  47553. }
  47554. declare module BABYLON {
  47555. /** @hidden */
  47556. export var glowMapGenerationVertexShader: {
  47557. name: string;
  47558. shader: string;
  47559. };
  47560. }
  47561. declare module BABYLON {
  47562. /**
  47563. * Effect layer options. This helps customizing the behaviour
  47564. * of the effect layer.
  47565. */
  47566. export interface IEffectLayerOptions {
  47567. /**
  47568. * Multiplication factor apply to the canvas size to compute the render target size
  47569. * used to generated the objects (the smaller the faster).
  47570. */
  47571. mainTextureRatio: number;
  47572. /**
  47573. * Enforces a fixed size texture to ensure effect stability across devices.
  47574. */
  47575. mainTextureFixedSize?: number;
  47576. /**
  47577. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  47578. */
  47579. alphaBlendingMode: number;
  47580. /**
  47581. * The camera attached to the layer.
  47582. */
  47583. camera: Nullable<Camera>;
  47584. /**
  47585. * The rendering group to draw the layer in.
  47586. */
  47587. renderingGroupId: number;
  47588. }
  47589. /**
  47590. * The effect layer Helps adding post process effect blended with the main pass.
  47591. *
  47592. * This can be for instance use to generate glow or higlight effects on the scene.
  47593. *
  47594. * The effect layer class can not be used directly and is intented to inherited from to be
  47595. * customized per effects.
  47596. */
  47597. export abstract class EffectLayer {
  47598. private _vertexBuffers;
  47599. private _indexBuffer;
  47600. private _cachedDefines;
  47601. private _effectLayerMapGenerationEffect;
  47602. private _effectLayerOptions;
  47603. private _mergeEffect;
  47604. protected _scene: Scene;
  47605. protected _engine: Engine;
  47606. protected _maxSize: number;
  47607. protected _mainTextureDesiredSize: ISize;
  47608. protected _mainTexture: RenderTargetTexture;
  47609. protected _shouldRender: boolean;
  47610. protected _postProcesses: PostProcess[];
  47611. protected _textures: BaseTexture[];
  47612. protected _emissiveTextureAndColor: {
  47613. texture: Nullable<BaseTexture>;
  47614. color: Color4;
  47615. };
  47616. /**
  47617. * The name of the layer
  47618. */
  47619. name: string;
  47620. /**
  47621. * The clear color of the texture used to generate the glow map.
  47622. */
  47623. neutralColor: Color4;
  47624. /**
  47625. * Specifies wether the highlight layer is enabled or not.
  47626. */
  47627. isEnabled: boolean;
  47628. /**
  47629. * Gets the camera attached to the layer.
  47630. */
  47631. readonly camera: Nullable<Camera>;
  47632. /**
  47633. * Gets the rendering group id the layer should render in.
  47634. */
  47635. renderingGroupId: number;
  47636. /**
  47637. * An event triggered when the effect layer has been disposed.
  47638. */
  47639. onDisposeObservable: Observable<EffectLayer>;
  47640. /**
  47641. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  47642. */
  47643. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  47644. /**
  47645. * An event triggered when the generated texture is being merged in the scene.
  47646. */
  47647. onBeforeComposeObservable: Observable<EffectLayer>;
  47648. /**
  47649. * An event triggered when the generated texture has been merged in the scene.
  47650. */
  47651. onAfterComposeObservable: Observable<EffectLayer>;
  47652. /**
  47653. * An event triggered when the efffect layer changes its size.
  47654. */
  47655. onSizeChangedObservable: Observable<EffectLayer>;
  47656. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  47657. /**
  47658. * Instantiates a new effect Layer and references it in the scene.
  47659. * @param name The name of the layer
  47660. * @param scene The scene to use the layer in
  47661. */
  47662. constructor(
  47663. /** The Friendly of the effect in the scene */
  47664. name: string, scene: Scene);
  47665. /**
  47666. * Get the effect name of the layer.
  47667. * @return The effect name
  47668. */
  47669. abstract getEffectName(): string;
  47670. /**
  47671. * Checks for the readiness of the element composing the layer.
  47672. * @param subMesh the mesh to check for
  47673. * @param useInstances specify wether or not to use instances to render the mesh
  47674. * @return true if ready otherwise, false
  47675. */
  47676. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  47677. /**
  47678. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  47679. * @returns true if the effect requires stencil during the main canvas render pass.
  47680. */
  47681. abstract needStencil(): boolean;
  47682. /**
  47683. * Create the merge effect. This is the shader use to blit the information back
  47684. * to the main canvas at the end of the scene rendering.
  47685. * @returns The effect containing the shader used to merge the effect on the main canvas
  47686. */
  47687. protected abstract _createMergeEffect(): Effect;
  47688. /**
  47689. * Creates the render target textures and post processes used in the effect layer.
  47690. */
  47691. protected abstract _createTextureAndPostProcesses(): void;
  47692. /**
  47693. * Implementation specific of rendering the generating effect on the main canvas.
  47694. * @param effect The effect used to render through
  47695. */
  47696. protected abstract _internalRender(effect: Effect): void;
  47697. /**
  47698. * Sets the required values for both the emissive texture and and the main color.
  47699. */
  47700. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  47701. /**
  47702. * Free any resources and references associated to a mesh.
  47703. * Internal use
  47704. * @param mesh The mesh to free.
  47705. */
  47706. abstract _disposeMesh(mesh: Mesh): void;
  47707. /**
  47708. * Serializes this layer (Glow or Highlight for example)
  47709. * @returns a serialized layer object
  47710. */
  47711. abstract serialize?(): any;
  47712. /**
  47713. * Initializes the effect layer with the required options.
  47714. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  47715. */
  47716. protected _init(options: Partial<IEffectLayerOptions>): void;
  47717. /**
  47718. * Generates the index buffer of the full screen quad blending to the main canvas.
  47719. */
  47720. private _generateIndexBuffer;
  47721. /**
  47722. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  47723. */
  47724. private _generateVertexBuffer;
  47725. /**
  47726. * Sets the main texture desired size which is the closest power of two
  47727. * of the engine canvas size.
  47728. */
  47729. private _setMainTextureSize;
  47730. /**
  47731. * Creates the main texture for the effect layer.
  47732. */
  47733. protected _createMainTexture(): void;
  47734. /**
  47735. * Adds specific effects defines.
  47736. * @param defines The defines to add specifics to.
  47737. */
  47738. protected _addCustomEffectDefines(defines: string[]): void;
  47739. /**
  47740. * Checks for the readiness of the element composing the layer.
  47741. * @param subMesh the mesh to check for
  47742. * @param useInstances specify wether or not to use instances to render the mesh
  47743. * @param emissiveTexture the associated emissive texture used to generate the glow
  47744. * @return true if ready otherwise, false
  47745. */
  47746. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  47747. /**
  47748. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  47749. */
  47750. render(): void;
  47751. /**
  47752. * Determine if a given mesh will be used in the current effect.
  47753. * @param mesh mesh to test
  47754. * @returns true if the mesh will be used
  47755. */
  47756. hasMesh(mesh: AbstractMesh): boolean;
  47757. /**
  47758. * Returns true if the layer contains information to display, otherwise false.
  47759. * @returns true if the glow layer should be rendered
  47760. */
  47761. shouldRender(): boolean;
  47762. /**
  47763. * Returns true if the mesh should render, otherwise false.
  47764. * @param mesh The mesh to render
  47765. * @returns true if it should render otherwise false
  47766. */
  47767. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  47768. /**
  47769. * Returns true if the mesh can be rendered, otherwise false.
  47770. * @param mesh The mesh to render
  47771. * @param material The material used on the mesh
  47772. * @returns true if it can be rendered otherwise false
  47773. */
  47774. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  47775. /**
  47776. * Returns true if the mesh should render, otherwise false.
  47777. * @param mesh The mesh to render
  47778. * @returns true if it should render otherwise false
  47779. */
  47780. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  47781. /**
  47782. * Renders the submesh passed in parameter to the generation map.
  47783. */
  47784. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  47785. /**
  47786. * Rebuild the required buffers.
  47787. * @hidden Internal use only.
  47788. */ private _rebuild(): void;
  47789. /**
  47790. * Dispose only the render target textures and post process.
  47791. */
  47792. private _disposeTextureAndPostProcesses;
  47793. /**
  47794. * Dispose the highlight layer and free resources.
  47795. */
  47796. dispose(): void;
  47797. /**
  47798. * Gets the class name of the effect layer
  47799. * @returns the string with the class name of the effect layer
  47800. */
  47801. getClassName(): string;
  47802. /**
  47803. * Creates an effect layer from parsed effect layer data
  47804. * @param parsedEffectLayer defines effect layer data
  47805. * @param scene defines the current scene
  47806. * @param rootUrl defines the root URL containing the effect layer information
  47807. * @returns a parsed effect Layer
  47808. */
  47809. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  47810. }
  47811. }
  47812. declare module BABYLON {
  47813. interface AbstractScene {
  47814. /**
  47815. * The list of effect layers (highlights/glow) added to the scene
  47816. * @see http://doc.babylonjs.com/how_to/highlight_layer
  47817. * @see http://doc.babylonjs.com/how_to/glow_layer
  47818. */
  47819. effectLayers: Array<EffectLayer>;
  47820. /**
  47821. * Removes the given effect layer from this scene.
  47822. * @param toRemove defines the effect layer to remove
  47823. * @returns the index of the removed effect layer
  47824. */
  47825. removeEffectLayer(toRemove: EffectLayer): number;
  47826. /**
  47827. * Adds the given effect layer to this scene
  47828. * @param newEffectLayer defines the effect layer to add
  47829. */
  47830. addEffectLayer(newEffectLayer: EffectLayer): void;
  47831. }
  47832. /**
  47833. * Defines the layer scene component responsible to manage any effect layers
  47834. * in a given scene.
  47835. */
  47836. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  47837. /**
  47838. * The component name helpfull to identify the component in the list of scene components.
  47839. */
  47840. readonly name: string;
  47841. /**
  47842. * The scene the component belongs to.
  47843. */
  47844. scene: Scene;
  47845. private _engine;
  47846. private _renderEffects;
  47847. private _needStencil;
  47848. private _previousStencilState;
  47849. /**
  47850. * Creates a new instance of the component for the given scene
  47851. * @param scene Defines the scene to register the component in
  47852. */
  47853. constructor(scene: Scene);
  47854. /**
  47855. * Registers the component in a given scene
  47856. */
  47857. register(): void;
  47858. /**
  47859. * Rebuilds the elements related to this component in case of
  47860. * context lost for instance.
  47861. */
  47862. rebuild(): void;
  47863. /**
  47864. * Serializes the component data to the specified json object
  47865. * @param serializationObject The object to serialize to
  47866. */
  47867. serialize(serializationObject: any): void;
  47868. /**
  47869. * Adds all the elements from the container to the scene
  47870. * @param container the container holding the elements
  47871. */
  47872. addFromContainer(container: AbstractScene): void;
  47873. /**
  47874. * Removes all the elements in the container from the scene
  47875. * @param container contains the elements to remove
  47876. * @param dispose if the removed element should be disposed (default: false)
  47877. */
  47878. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  47879. /**
  47880. * Disposes the component and the associated ressources.
  47881. */
  47882. dispose(): void;
  47883. private _isReadyForMesh;
  47884. private _renderMainTexture;
  47885. private _setStencil;
  47886. private _setStencilBack;
  47887. private _draw;
  47888. private _drawCamera;
  47889. private _drawRenderingGroup;
  47890. }
  47891. }
  47892. declare module BABYLON {
  47893. /** @hidden */
  47894. export var glowMapMergePixelShader: {
  47895. name: string;
  47896. shader: string;
  47897. };
  47898. }
  47899. declare module BABYLON {
  47900. /** @hidden */
  47901. export var glowMapMergeVertexShader: {
  47902. name: string;
  47903. shader: string;
  47904. };
  47905. }
  47906. declare module BABYLON {
  47907. interface AbstractScene {
  47908. /**
  47909. * Return a the first highlight layer of the scene with a given name.
  47910. * @param name The name of the highlight layer to look for.
  47911. * @return The highlight layer if found otherwise null.
  47912. */
  47913. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  47914. }
  47915. /**
  47916. * Glow layer options. This helps customizing the behaviour
  47917. * of the glow layer.
  47918. */
  47919. export interface IGlowLayerOptions {
  47920. /**
  47921. * Multiplication factor apply to the canvas size to compute the render target size
  47922. * used to generated the glowing objects (the smaller the faster).
  47923. */
  47924. mainTextureRatio: number;
  47925. /**
  47926. * Enforces a fixed size texture to ensure resize independant blur.
  47927. */
  47928. mainTextureFixedSize?: number;
  47929. /**
  47930. * How big is the kernel of the blur texture.
  47931. */
  47932. blurKernelSize: number;
  47933. /**
  47934. * The camera attached to the layer.
  47935. */
  47936. camera: Nullable<Camera>;
  47937. /**
  47938. * Enable MSAA by chosing the number of samples.
  47939. */
  47940. mainTextureSamples?: number;
  47941. /**
  47942. * The rendering group to draw the layer in.
  47943. */
  47944. renderingGroupId: number;
  47945. }
  47946. /**
  47947. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  47948. *
  47949. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  47950. * glowy meshes to your scene.
  47951. *
  47952. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  47953. */
  47954. export class GlowLayer extends EffectLayer {
  47955. /**
  47956. * Effect Name of the layer.
  47957. */
  47958. static readonly EffectName: string;
  47959. /**
  47960. * The default blur kernel size used for the glow.
  47961. */
  47962. static DefaultBlurKernelSize: number;
  47963. /**
  47964. * The default texture size ratio used for the glow.
  47965. */
  47966. static DefaultTextureRatio: number;
  47967. /**
  47968. * Sets the kernel size of the blur.
  47969. */
  47970. /**
  47971. * Gets the kernel size of the blur.
  47972. */
  47973. blurKernelSize: number;
  47974. /**
  47975. * Sets the glow intensity.
  47976. */
  47977. /**
  47978. * Gets the glow intensity.
  47979. */
  47980. intensity: number;
  47981. private _options;
  47982. private _intensity;
  47983. private _horizontalBlurPostprocess1;
  47984. private _verticalBlurPostprocess1;
  47985. private _horizontalBlurPostprocess2;
  47986. private _verticalBlurPostprocess2;
  47987. private _blurTexture1;
  47988. private _blurTexture2;
  47989. private _postProcesses1;
  47990. private _postProcesses2;
  47991. private _includedOnlyMeshes;
  47992. private _excludedMeshes;
  47993. /**
  47994. * Callback used to let the user override the color selection on a per mesh basis
  47995. */
  47996. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  47997. /**
  47998. * Callback used to let the user override the texture selection on a per mesh basis
  47999. */
  48000. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48001. /**
  48002. * Instantiates a new glow Layer and references it to the scene.
  48003. * @param name The name of the layer
  48004. * @param scene The scene to use the layer in
  48005. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48006. */
  48007. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48008. /**
  48009. * Get the effect name of the layer.
  48010. * @return The effect name
  48011. */
  48012. getEffectName(): string;
  48013. /**
  48014. * Create the merge effect. This is the shader use to blit the information back
  48015. * to the main canvas at the end of the scene rendering.
  48016. */
  48017. protected _createMergeEffect(): Effect;
  48018. /**
  48019. * Creates the render target textures and post processes used in the glow layer.
  48020. */
  48021. protected _createTextureAndPostProcesses(): void;
  48022. /**
  48023. * Checks for the readiness of the element composing the layer.
  48024. * @param subMesh the mesh to check for
  48025. * @param useInstances specify wether or not to use instances to render the mesh
  48026. * @param emissiveTexture the associated emissive texture used to generate the glow
  48027. * @return true if ready otherwise, false
  48028. */
  48029. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48030. /**
  48031. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48032. */
  48033. needStencil(): boolean;
  48034. /**
  48035. * Returns true if the mesh can be rendered, otherwise false.
  48036. * @param mesh The mesh to render
  48037. * @param material The material used on the mesh
  48038. * @returns true if it can be rendered otherwise false
  48039. */
  48040. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48041. /**
  48042. * Implementation specific of rendering the generating effect on the main canvas.
  48043. * @param effect The effect used to render through
  48044. */
  48045. protected _internalRender(effect: Effect): void;
  48046. /**
  48047. * Sets the required values for both the emissive texture and and the main color.
  48048. */
  48049. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48050. /**
  48051. * Returns true if the mesh should render, otherwise false.
  48052. * @param mesh The mesh to render
  48053. * @returns true if it should render otherwise false
  48054. */
  48055. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48056. /**
  48057. * Adds specific effects defines.
  48058. * @param defines The defines to add specifics to.
  48059. */
  48060. protected _addCustomEffectDefines(defines: string[]): void;
  48061. /**
  48062. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48063. * @param mesh The mesh to exclude from the glow layer
  48064. */
  48065. addExcludedMesh(mesh: Mesh): void;
  48066. /**
  48067. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48068. * @param mesh The mesh to remove
  48069. */
  48070. removeExcludedMesh(mesh: Mesh): void;
  48071. /**
  48072. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48073. * @param mesh The mesh to include in the glow layer
  48074. */
  48075. addIncludedOnlyMesh(mesh: Mesh): void;
  48076. /**
  48077. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48078. * @param mesh The mesh to remove
  48079. */
  48080. removeIncludedOnlyMesh(mesh: Mesh): void;
  48081. /**
  48082. * Determine if a given mesh will be used in the glow layer
  48083. * @param mesh The mesh to test
  48084. * @returns true if the mesh will be highlighted by the current glow layer
  48085. */
  48086. hasMesh(mesh: AbstractMesh): boolean;
  48087. /**
  48088. * Free any resources and references associated to a mesh.
  48089. * Internal use
  48090. * @param mesh The mesh to free.
  48091. * @hidden
  48092. */ private _disposeMesh(mesh: Mesh): void;
  48093. /**
  48094. * Gets the class name of the effect layer
  48095. * @returns the string with the class name of the effect layer
  48096. */
  48097. getClassName(): string;
  48098. /**
  48099. * Serializes this glow layer
  48100. * @returns a serialized glow layer object
  48101. */
  48102. serialize(): any;
  48103. /**
  48104. * Creates a Glow Layer from parsed glow layer data
  48105. * @param parsedGlowLayer defines glow layer data
  48106. * @param scene defines the current scene
  48107. * @param rootUrl defines the root URL containing the glow layer information
  48108. * @returns a parsed Glow Layer
  48109. */
  48110. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48111. }
  48112. }
  48113. declare module BABYLON {
  48114. /** @hidden */
  48115. export var glowBlurPostProcessPixelShader: {
  48116. name: string;
  48117. shader: string;
  48118. };
  48119. }
  48120. declare module BABYLON {
  48121. interface AbstractScene {
  48122. /**
  48123. * Return a the first highlight layer of the scene with a given name.
  48124. * @param name The name of the highlight layer to look for.
  48125. * @return The highlight layer if found otherwise null.
  48126. */
  48127. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  48128. }
  48129. /**
  48130. * Highlight layer options. This helps customizing the behaviour
  48131. * of the highlight layer.
  48132. */
  48133. export interface IHighlightLayerOptions {
  48134. /**
  48135. * Multiplication factor apply to the canvas size to compute the render target size
  48136. * used to generated the glowing objects (the smaller the faster).
  48137. */
  48138. mainTextureRatio: number;
  48139. /**
  48140. * Enforces a fixed size texture to ensure resize independant blur.
  48141. */
  48142. mainTextureFixedSize?: number;
  48143. /**
  48144. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  48145. * of the picture to blur (the smaller the faster).
  48146. */
  48147. blurTextureSizeRatio: number;
  48148. /**
  48149. * How big in texel of the blur texture is the vertical blur.
  48150. */
  48151. blurVerticalSize: number;
  48152. /**
  48153. * How big in texel of the blur texture is the horizontal blur.
  48154. */
  48155. blurHorizontalSize: number;
  48156. /**
  48157. * Alpha blending mode used to apply the blur. Default is combine.
  48158. */
  48159. alphaBlendingMode: number;
  48160. /**
  48161. * The camera attached to the layer.
  48162. */
  48163. camera: Nullable<Camera>;
  48164. /**
  48165. * Should we display highlight as a solid stroke?
  48166. */
  48167. isStroke?: boolean;
  48168. /**
  48169. * The rendering group to draw the layer in.
  48170. */
  48171. renderingGroupId: number;
  48172. }
  48173. /**
  48174. * The highlight layer Helps adding a glow effect around a mesh.
  48175. *
  48176. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48177. * glowy meshes to your scene.
  48178. *
  48179. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  48180. */
  48181. export class HighlightLayer extends EffectLayer {
  48182. name: string;
  48183. /**
  48184. * Effect Name of the highlight layer.
  48185. */
  48186. static readonly EffectName: string;
  48187. /**
  48188. * The neutral color used during the preparation of the glow effect.
  48189. * This is black by default as the blend operation is a blend operation.
  48190. */
  48191. static NeutralColor: Color4;
  48192. /**
  48193. * Stencil value used for glowing meshes.
  48194. */
  48195. static GlowingMeshStencilReference: number;
  48196. /**
  48197. * Stencil value used for the other meshes in the scene.
  48198. */
  48199. static NormalMeshStencilReference: number;
  48200. /**
  48201. * Specifies whether or not the inner glow is ACTIVE in the layer.
  48202. */
  48203. innerGlow: boolean;
  48204. /**
  48205. * Specifies whether or not the outer glow is ACTIVE in the layer.
  48206. */
  48207. outerGlow: boolean;
  48208. /**
  48209. * Specifies the horizontal size of the blur.
  48210. */
  48211. /**
  48212. * Gets the horizontal size of the blur.
  48213. */
  48214. blurHorizontalSize: number;
  48215. /**
  48216. * Specifies the vertical size of the blur.
  48217. */
  48218. /**
  48219. * Gets the vertical size of the blur.
  48220. */
  48221. blurVerticalSize: number;
  48222. /**
  48223. * An event triggered when the highlight layer is being blurred.
  48224. */
  48225. onBeforeBlurObservable: Observable<HighlightLayer>;
  48226. /**
  48227. * An event triggered when the highlight layer has been blurred.
  48228. */
  48229. onAfterBlurObservable: Observable<HighlightLayer>;
  48230. private _instanceGlowingMeshStencilReference;
  48231. private _options;
  48232. private _downSamplePostprocess;
  48233. private _horizontalBlurPostprocess;
  48234. private _verticalBlurPostprocess;
  48235. private _blurTexture;
  48236. private _meshes;
  48237. private _excludedMeshes;
  48238. /**
  48239. * Instantiates a new highlight Layer and references it to the scene..
  48240. * @param name The name of the layer
  48241. * @param scene The scene to use the layer in
  48242. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  48243. */
  48244. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  48245. /**
  48246. * Get the effect name of the layer.
  48247. * @return The effect name
  48248. */
  48249. getEffectName(): string;
  48250. /**
  48251. * Create the merge effect. This is the shader use to blit the information back
  48252. * to the main canvas at the end of the scene rendering.
  48253. */
  48254. protected _createMergeEffect(): Effect;
  48255. /**
  48256. * Creates the render target textures and post processes used in the highlight layer.
  48257. */
  48258. protected _createTextureAndPostProcesses(): void;
  48259. /**
  48260. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48261. */
  48262. needStencil(): boolean;
  48263. /**
  48264. * Checks for the readiness of the element composing the layer.
  48265. * @param subMesh the mesh to check for
  48266. * @param useInstances specify wether or not to use instances to render the mesh
  48267. * @param emissiveTexture the associated emissive texture used to generate the glow
  48268. * @return true if ready otherwise, false
  48269. */
  48270. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48271. /**
  48272. * Implementation specific of rendering the generating effect on the main canvas.
  48273. * @param effect The effect used to render through
  48274. */
  48275. protected _internalRender(effect: Effect): void;
  48276. /**
  48277. * Returns true if the layer contains information to display, otherwise false.
  48278. */
  48279. shouldRender(): boolean;
  48280. /**
  48281. * Returns true if the mesh should render, otherwise false.
  48282. * @param mesh The mesh to render
  48283. * @returns true if it should render otherwise false
  48284. */
  48285. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48286. /**
  48287. * Sets the required values for both the emissive texture and and the main color.
  48288. */
  48289. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48290. /**
  48291. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  48292. * @param mesh The mesh to exclude from the highlight layer
  48293. */
  48294. addExcludedMesh(mesh: Mesh): void;
  48295. /**
  48296. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  48297. * @param mesh The mesh to highlight
  48298. */
  48299. removeExcludedMesh(mesh: Mesh): void;
  48300. /**
  48301. * Determine if a given mesh will be highlighted by the current HighlightLayer
  48302. * @param mesh mesh to test
  48303. * @returns true if the mesh will be highlighted by the current HighlightLayer
  48304. */
  48305. hasMesh(mesh: AbstractMesh): boolean;
  48306. /**
  48307. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  48308. * @param mesh The mesh to highlight
  48309. * @param color The color of the highlight
  48310. * @param glowEmissiveOnly Extract the glow from the emissive texture
  48311. */
  48312. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  48313. /**
  48314. * Remove a mesh from the highlight layer in order to make it stop glowing.
  48315. * @param mesh The mesh to highlight
  48316. */
  48317. removeMesh(mesh: Mesh): void;
  48318. /**
  48319. * Force the stencil to the normal expected value for none glowing parts
  48320. */
  48321. private _defaultStencilReference;
  48322. /**
  48323. * Free any resources and references associated to a mesh.
  48324. * Internal use
  48325. * @param mesh The mesh to free.
  48326. * @hidden
  48327. */ private _disposeMesh(mesh: Mesh): void;
  48328. /**
  48329. * Dispose the highlight layer and free resources.
  48330. */
  48331. dispose(): void;
  48332. /**
  48333. * Gets the class name of the effect layer
  48334. * @returns the string with the class name of the effect layer
  48335. */
  48336. getClassName(): string;
  48337. /**
  48338. * Serializes this Highlight layer
  48339. * @returns a serialized Highlight layer object
  48340. */
  48341. serialize(): any;
  48342. /**
  48343. * Creates a Highlight layer from parsed Highlight layer data
  48344. * @param parsedHightlightLayer defines the Highlight layer data
  48345. * @param scene defines the current scene
  48346. * @param rootUrl defines the root URL containing the Highlight layer information
  48347. * @returns a parsed Highlight layer
  48348. */
  48349. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  48350. }
  48351. }
  48352. declare module BABYLON {
  48353. interface AbstractScene {
  48354. /**
  48355. * The list of layers (background and foreground) of the scene
  48356. */
  48357. layers: Array<Layer>;
  48358. }
  48359. /**
  48360. * Defines the layer scene component responsible to manage any layers
  48361. * in a given scene.
  48362. */
  48363. export class LayerSceneComponent implements ISceneComponent {
  48364. /**
  48365. * The component name helpfull to identify the component in the list of scene components.
  48366. */
  48367. readonly name: string;
  48368. /**
  48369. * The scene the component belongs to.
  48370. */
  48371. scene: Scene;
  48372. private _engine;
  48373. /**
  48374. * Creates a new instance of the component for the given scene
  48375. * @param scene Defines the scene to register the component in
  48376. */
  48377. constructor(scene: Scene);
  48378. /**
  48379. * Registers the component in a given scene
  48380. */
  48381. register(): void;
  48382. /**
  48383. * Rebuilds the elements related to this component in case of
  48384. * context lost for instance.
  48385. */
  48386. rebuild(): void;
  48387. /**
  48388. * Disposes the component and the associated ressources.
  48389. */
  48390. dispose(): void;
  48391. private _draw;
  48392. private _drawCameraPredicate;
  48393. private _drawCameraBackground;
  48394. private _drawCameraForeground;
  48395. private _drawRenderTargetPredicate;
  48396. private _drawRenderTargetBackground;
  48397. private _drawRenderTargetForeground;
  48398. /**
  48399. * Adds all the elements from the container to the scene
  48400. * @param container the container holding the elements
  48401. */
  48402. addFromContainer(container: AbstractScene): void;
  48403. /**
  48404. * Removes all the elements in the container from the scene
  48405. * @param container contains the elements to remove
  48406. * @param dispose if the removed element should be disposed (default: false)
  48407. */
  48408. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48409. }
  48410. }
  48411. declare module BABYLON {
  48412. /** @hidden */
  48413. export var layerPixelShader: {
  48414. name: string;
  48415. shader: string;
  48416. };
  48417. }
  48418. declare module BABYLON {
  48419. /** @hidden */
  48420. export var layerVertexShader: {
  48421. name: string;
  48422. shader: string;
  48423. };
  48424. }
  48425. declare module BABYLON {
  48426. /**
  48427. * This represents a full screen 2d layer.
  48428. * This can be useful to display a picture in the background of your scene for instance.
  48429. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48430. */
  48431. export class Layer {
  48432. /**
  48433. * Define the name of the layer.
  48434. */
  48435. name: string;
  48436. /**
  48437. * Define the texture the layer should display.
  48438. */
  48439. texture: Nullable<Texture>;
  48440. /**
  48441. * Is the layer in background or foreground.
  48442. */
  48443. isBackground: boolean;
  48444. /**
  48445. * Define the color of the layer (instead of texture).
  48446. */
  48447. color: Color4;
  48448. /**
  48449. * Define the scale of the layer in order to zoom in out of the texture.
  48450. */
  48451. scale: Vector2;
  48452. /**
  48453. * Define an offset for the layer in order to shift the texture.
  48454. */
  48455. offset: Vector2;
  48456. /**
  48457. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  48458. */
  48459. alphaBlendingMode: number;
  48460. /**
  48461. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  48462. * Alpha test will not mix with the background color in case of transparency.
  48463. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  48464. */
  48465. alphaTest: boolean;
  48466. /**
  48467. * Define a mask to restrict the layer to only some of the scene cameras.
  48468. */
  48469. layerMask: number;
  48470. /**
  48471. * Define the list of render target the layer is visible into.
  48472. */
  48473. renderTargetTextures: RenderTargetTexture[];
  48474. /**
  48475. * Define if the layer is only used in renderTarget or if it also
  48476. * renders in the main frame buffer of the canvas.
  48477. */
  48478. renderOnlyInRenderTargetTextures: boolean;
  48479. private _scene;
  48480. private _vertexBuffers;
  48481. private _indexBuffer;
  48482. private _effect;
  48483. private _alphaTestEffect;
  48484. /**
  48485. * An event triggered when the layer is disposed.
  48486. */
  48487. onDisposeObservable: Observable<Layer>;
  48488. private _onDisposeObserver;
  48489. /**
  48490. * Back compatibility with callback before the onDisposeObservable existed.
  48491. * The set callback will be triggered when the layer has been disposed.
  48492. */
  48493. onDispose: () => void;
  48494. /**
  48495. * An event triggered before rendering the scene
  48496. */
  48497. onBeforeRenderObservable: Observable<Layer>;
  48498. private _onBeforeRenderObserver;
  48499. /**
  48500. * Back compatibility with callback before the onBeforeRenderObservable existed.
  48501. * The set callback will be triggered just before rendering the layer.
  48502. */
  48503. onBeforeRender: () => void;
  48504. /**
  48505. * An event triggered after rendering the scene
  48506. */
  48507. onAfterRenderObservable: Observable<Layer>;
  48508. private _onAfterRenderObserver;
  48509. /**
  48510. * Back compatibility with callback before the onAfterRenderObservable existed.
  48511. * The set callback will be triggered just after rendering the layer.
  48512. */
  48513. onAfterRender: () => void;
  48514. /**
  48515. * Instantiates a new layer.
  48516. * This represents a full screen 2d layer.
  48517. * This can be useful to display a picture in the background of your scene for instance.
  48518. * @see https://www.babylonjs-playground.com/#08A2BS#1
  48519. * @param name Define the name of the layer in the scene
  48520. * @param imgUrl Define the url of the texture to display in the layer
  48521. * @param scene Define the scene the layer belongs to
  48522. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  48523. * @param color Defines a color for the layer
  48524. */
  48525. constructor(
  48526. /**
  48527. * Define the name of the layer.
  48528. */
  48529. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  48530. private _createIndexBuffer;
  48531. /** @hidden */ private _rebuild(): void;
  48532. /**
  48533. * Renders the layer in the scene.
  48534. */
  48535. render(): void;
  48536. /**
  48537. * Disposes and releases the associated ressources.
  48538. */
  48539. dispose(): void;
  48540. }
  48541. }
  48542. declare module BABYLON {
  48543. /** @hidden */
  48544. export var lensFlarePixelShader: {
  48545. name: string;
  48546. shader: string;
  48547. };
  48548. }
  48549. declare module BABYLON {
  48550. /** @hidden */
  48551. export var lensFlareVertexShader: {
  48552. name: string;
  48553. shader: string;
  48554. };
  48555. }
  48556. declare module BABYLON {
  48557. /**
  48558. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48559. * It is usually composed of several `lensFlare`.
  48560. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48561. */
  48562. export class LensFlareSystem {
  48563. /**
  48564. * Define the name of the lens flare system
  48565. */
  48566. name: string;
  48567. /**
  48568. * List of lens flares used in this system.
  48569. */
  48570. lensFlares: LensFlare[];
  48571. /**
  48572. * Define a limit from the border the lens flare can be visible.
  48573. */
  48574. borderLimit: number;
  48575. /**
  48576. * Define a viewport border we do not want to see the lens flare in.
  48577. */
  48578. viewportBorder: number;
  48579. /**
  48580. * Define a predicate which could limit the list of meshes able to occlude the effect.
  48581. */
  48582. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  48583. /**
  48584. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  48585. */
  48586. layerMask: number;
  48587. /**
  48588. * Define the id of the lens flare system in the scene.
  48589. * (equal to name by default)
  48590. */
  48591. id: string;
  48592. private _scene;
  48593. private _emitter;
  48594. private _vertexBuffers;
  48595. private _indexBuffer;
  48596. private _effect;
  48597. private _positionX;
  48598. private _positionY;
  48599. private _isEnabled;
  48600. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  48601. /**
  48602. * Instantiates a lens flare system.
  48603. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  48604. * It is usually composed of several `lensFlare`.
  48605. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48606. * @param name Define the name of the lens flare system in the scene
  48607. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  48608. * @param scene Define the scene the lens flare system belongs to
  48609. */
  48610. constructor(
  48611. /**
  48612. * Define the name of the lens flare system
  48613. */
  48614. name: string, emitter: any, scene: Scene);
  48615. /**
  48616. * Define if the lens flare system is enabled.
  48617. */
  48618. isEnabled: boolean;
  48619. /**
  48620. * Get the scene the effects belongs to.
  48621. * @returns the scene holding the lens flare system
  48622. */
  48623. getScene(): Scene;
  48624. /**
  48625. * Get the emitter of the lens flare system.
  48626. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48627. * @returns the emitter of the lens flare system
  48628. */
  48629. getEmitter(): any;
  48630. /**
  48631. * Set the emitter of the lens flare system.
  48632. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  48633. * @param newEmitter Define the new emitter of the system
  48634. */
  48635. setEmitter(newEmitter: any): void;
  48636. /**
  48637. * Get the lens flare system emitter position.
  48638. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  48639. * @returns the position
  48640. */
  48641. getEmitterPosition(): Vector3;
  48642. /**
  48643. * @hidden
  48644. */
  48645. computeEffectivePosition(globalViewport: Viewport): boolean;
  48646. /** @hidden */ private _isVisible(): boolean;
  48647. /**
  48648. * @hidden
  48649. */
  48650. render(): boolean;
  48651. /**
  48652. * Dispose and release the lens flare with its associated resources.
  48653. */
  48654. dispose(): void;
  48655. /**
  48656. * Parse a lens flare system from a JSON repressentation
  48657. * @param parsedLensFlareSystem Define the JSON to parse
  48658. * @param scene Define the scene the parsed system should be instantiated in
  48659. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  48660. * @returns the parsed system
  48661. */
  48662. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  48663. /**
  48664. * Serialize the current Lens Flare System into a JSON representation.
  48665. * @returns the serialized JSON
  48666. */
  48667. serialize(): any;
  48668. }
  48669. }
  48670. declare module BABYLON {
  48671. /**
  48672. * This represents one of the lens effect in a `lensFlareSystem`.
  48673. * It controls one of the indiviual texture used in the effect.
  48674. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48675. */
  48676. export class LensFlare {
  48677. /**
  48678. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48679. */
  48680. size: number;
  48681. /**
  48682. * 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.
  48683. */
  48684. position: number;
  48685. /**
  48686. * Define the lens color.
  48687. */
  48688. color: Color3;
  48689. /**
  48690. * Define the lens texture.
  48691. */
  48692. texture: Nullable<Texture>;
  48693. /**
  48694. * Define the alpha mode to render this particular lens.
  48695. */
  48696. alphaMode: number;
  48697. private _system;
  48698. /**
  48699. * Creates a new Lens Flare.
  48700. * This represents one of the lens effect in a `lensFlareSystem`.
  48701. * It controls one of the indiviual texture used in the effect.
  48702. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48703. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  48704. * @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.
  48705. * @param color Define the lens color
  48706. * @param imgUrl Define the lens texture url
  48707. * @param system Define the `lensFlareSystem` this flare is part of
  48708. * @returns The newly created Lens Flare
  48709. */
  48710. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  48711. /**
  48712. * Instantiates a new Lens Flare.
  48713. * This represents one of the lens effect in a `lensFlareSystem`.
  48714. * It controls one of the indiviual texture used in the effect.
  48715. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48716. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  48717. * @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.
  48718. * @param color Define the lens color
  48719. * @param imgUrl Define the lens texture url
  48720. * @param system Define the `lensFlareSystem` this flare is part of
  48721. */
  48722. constructor(
  48723. /**
  48724. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  48725. */
  48726. size: number,
  48727. /**
  48728. * 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.
  48729. */
  48730. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  48731. /**
  48732. * Dispose and release the lens flare with its associated resources.
  48733. */
  48734. dispose(): void;
  48735. }
  48736. }
  48737. declare module BABYLON {
  48738. interface AbstractScene {
  48739. /**
  48740. * The list of lens flare system added to the scene
  48741. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  48742. */
  48743. lensFlareSystems: Array<LensFlareSystem>;
  48744. /**
  48745. * Removes the given lens flare system from this scene.
  48746. * @param toRemove The lens flare system to remove
  48747. * @returns The index of the removed lens flare system
  48748. */
  48749. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  48750. /**
  48751. * Adds the given lens flare system to this scene
  48752. * @param newLensFlareSystem The lens flare system to add
  48753. */
  48754. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  48755. /**
  48756. * Gets a lens flare system using its name
  48757. * @param name defines the name to look for
  48758. * @returns the lens flare system or null if not found
  48759. */
  48760. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  48761. /**
  48762. * Gets a lens flare system using its id
  48763. * @param id defines the id to look for
  48764. * @returns the lens flare system or null if not found
  48765. */
  48766. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  48767. }
  48768. /**
  48769. * Defines the lens flare scene component responsible to manage any lens flares
  48770. * in a given scene.
  48771. */
  48772. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  48773. /**
  48774. * The component name helpfull to identify the component in the list of scene components.
  48775. */
  48776. readonly name: string;
  48777. /**
  48778. * The scene the component belongs to.
  48779. */
  48780. scene: Scene;
  48781. /**
  48782. * Creates a new instance of the component for the given scene
  48783. * @param scene Defines the scene to register the component in
  48784. */
  48785. constructor(scene: Scene);
  48786. /**
  48787. * Registers the component in a given scene
  48788. */
  48789. register(): void;
  48790. /**
  48791. * Rebuilds the elements related to this component in case of
  48792. * context lost for instance.
  48793. */
  48794. rebuild(): void;
  48795. /**
  48796. * Adds all the elements from the container to the scene
  48797. * @param container the container holding the elements
  48798. */
  48799. addFromContainer(container: AbstractScene): void;
  48800. /**
  48801. * Removes all the elements in the container from the scene
  48802. * @param container contains the elements to remove
  48803. * @param dispose if the removed element should be disposed (default: false)
  48804. */
  48805. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48806. /**
  48807. * Serializes the component data to the specified json object
  48808. * @param serializationObject The object to serialize to
  48809. */
  48810. serialize(serializationObject: any): void;
  48811. /**
  48812. * Disposes the component and the associated ressources.
  48813. */
  48814. dispose(): void;
  48815. private _draw;
  48816. }
  48817. }
  48818. declare module BABYLON {
  48819. /**
  48820. * Defines the shadow generator component responsible to manage any shadow generators
  48821. * in a given scene.
  48822. */
  48823. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  48824. /**
  48825. * The component name helpfull to identify the component in the list of scene components.
  48826. */
  48827. readonly name: string;
  48828. /**
  48829. * The scene the component belongs to.
  48830. */
  48831. scene: Scene;
  48832. /**
  48833. * Creates a new instance of the component for the given scene
  48834. * @param scene Defines the scene to register the component in
  48835. */
  48836. constructor(scene: Scene);
  48837. /**
  48838. * Registers the component in a given scene
  48839. */
  48840. register(): void;
  48841. /**
  48842. * Rebuilds the elements related to this component in case of
  48843. * context lost for instance.
  48844. */
  48845. rebuild(): void;
  48846. /**
  48847. * Serializes the component data to the specified json object
  48848. * @param serializationObject The object to serialize to
  48849. */
  48850. serialize(serializationObject: any): void;
  48851. /**
  48852. * Adds all the elements from the container to the scene
  48853. * @param container the container holding the elements
  48854. */
  48855. addFromContainer(container: AbstractScene): void;
  48856. /**
  48857. * Removes all the elements in the container from the scene
  48858. * @param container contains the elements to remove
  48859. * @param dispose if the removed element should be disposed (default: false)
  48860. */
  48861. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48862. /**
  48863. * Rebuilds the elements related to this component in case of
  48864. * context lost for instance.
  48865. */
  48866. dispose(): void;
  48867. private _gatherRenderTargets;
  48868. }
  48869. }
  48870. declare module BABYLON {
  48871. /**
  48872. * A point light is a light defined by an unique point in world space.
  48873. * The light is emitted in every direction from this point.
  48874. * A good example of a point light is a standard light bulb.
  48875. * Documentation: https://doc.babylonjs.com/babylon101/lights
  48876. */
  48877. export class PointLight extends ShadowLight {
  48878. private _shadowAngle;
  48879. /**
  48880. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48881. * This specifies what angle the shadow will use to be created.
  48882. *
  48883. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48884. */
  48885. /**
  48886. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48887. * This specifies what angle the shadow will use to be created.
  48888. *
  48889. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  48890. */
  48891. shadowAngle: number;
  48892. /**
  48893. * Gets the direction if it has been set.
  48894. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48895. */
  48896. /**
  48897. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  48898. */
  48899. direction: Vector3;
  48900. /**
  48901. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  48902. * A PointLight emits the light in every direction.
  48903. * It can cast shadows.
  48904. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  48905. * ```javascript
  48906. * var pointLight = new PointLight("pl", camera.position, scene);
  48907. * ```
  48908. * Documentation : https://doc.babylonjs.com/babylon101/lights
  48909. * @param name The light friendly name
  48910. * @param position The position of the point light in the scene
  48911. * @param scene The scene the lights belongs to
  48912. */
  48913. constructor(name: string, position: Vector3, scene: Scene);
  48914. /**
  48915. * Returns the string "PointLight"
  48916. * @returns the class name
  48917. */
  48918. getClassName(): string;
  48919. /**
  48920. * Returns the integer 0.
  48921. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  48922. */
  48923. getTypeID(): number;
  48924. /**
  48925. * Specifies wether or not the shadowmap should be a cube texture.
  48926. * @returns true if the shadowmap needs to be a cube texture.
  48927. */
  48928. needCube(): boolean;
  48929. /**
  48930. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  48931. * @param faceIndex The index of the face we are computed the direction to generate shadow
  48932. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  48933. */
  48934. getShadowDirection(faceIndex?: number): Vector3;
  48935. /**
  48936. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  48937. * - fov = PI / 2
  48938. * - aspect ratio : 1.0
  48939. * - z-near and far equal to the active camera minZ and maxZ.
  48940. * Returns the PointLight.
  48941. */
  48942. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  48943. protected _buildUniformLayout(): void;
  48944. /**
  48945. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  48946. * @param effect The effect to update
  48947. * @param lightIndex The index of the light in the effect to update
  48948. * @returns The point light
  48949. */
  48950. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  48951. /**
  48952. * Prepares the list of defines specific to the light type.
  48953. * @param defines the list of defines
  48954. * @param lightIndex defines the index of the light for the effect
  48955. */
  48956. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  48957. }
  48958. }
  48959. declare module BABYLON {
  48960. /**
  48961. * Header information of HDR texture files.
  48962. */
  48963. export interface HDRInfo {
  48964. /**
  48965. * The height of the texture in pixels.
  48966. */
  48967. height: number;
  48968. /**
  48969. * The width of the texture in pixels.
  48970. */
  48971. width: number;
  48972. /**
  48973. * The index of the beginning of the data in the binary file.
  48974. */
  48975. dataPosition: number;
  48976. }
  48977. /**
  48978. * This groups tools to convert HDR texture to native colors array.
  48979. */
  48980. export class HDRTools {
  48981. private static Ldexp;
  48982. private static Rgbe2float;
  48983. private static readStringLine;
  48984. /**
  48985. * Reads header information from an RGBE texture stored in a native array.
  48986. * More information on this format are available here:
  48987. * https://en.wikipedia.org/wiki/RGBE_image_format
  48988. *
  48989. * @param uint8array The binary file stored in native array.
  48990. * @return The header information.
  48991. */
  48992. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  48993. /**
  48994. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  48995. * This RGBE texture needs to store the information as a panorama.
  48996. *
  48997. * More information on this format are available here:
  48998. * https://en.wikipedia.org/wiki/RGBE_image_format
  48999. *
  49000. * @param buffer The binary file stored in an array buffer.
  49001. * @param size The expected size of the extracted cubemap.
  49002. * @return The Cube Map information.
  49003. */
  49004. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49005. /**
  49006. * Returns the pixels data extracted from an RGBE texture.
  49007. * This pixels will be stored left to right up to down in the R G B order in one array.
  49008. *
  49009. * More information on this format are available here:
  49010. * https://en.wikipedia.org/wiki/RGBE_image_format
  49011. *
  49012. * @param uint8array The binary file stored in an array buffer.
  49013. * @param hdrInfo The header information of the file.
  49014. * @return The pixels data in RGB right to left up to down order.
  49015. */
  49016. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49017. private static RGBE_ReadPixels_RLE;
  49018. }
  49019. }
  49020. declare module BABYLON {
  49021. /**
  49022. * This represents a texture coming from an HDR input.
  49023. *
  49024. * The only supported format is currently panorama picture stored in RGBE format.
  49025. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49026. */
  49027. export class HDRCubeTexture extends BaseTexture {
  49028. private static _facesMapping;
  49029. private _generateHarmonics;
  49030. private _noMipmap;
  49031. private _textureMatrix;
  49032. private _size;
  49033. private _onLoad;
  49034. private _onError;
  49035. /**
  49036. * The texture URL.
  49037. */
  49038. url: string;
  49039. /**
  49040. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49041. */
  49042. coordinatesMode: number;
  49043. protected _isBlocking: boolean;
  49044. /**
  49045. * Sets wether or not the texture is blocking during loading.
  49046. */
  49047. /**
  49048. * Gets wether or not the texture is blocking during loading.
  49049. */
  49050. isBlocking: boolean;
  49051. protected _rotationY: number;
  49052. /**
  49053. * Sets texture matrix rotation angle around Y axis in radians.
  49054. */
  49055. /**
  49056. * Gets texture matrix rotation angle around Y axis radians.
  49057. */
  49058. rotationY: number;
  49059. /**
  49060. * Gets or sets the center of the bounding box associated with the cube texture
  49061. * It must define where the camera used to render the texture was set
  49062. */
  49063. boundingBoxPosition: Vector3;
  49064. private _boundingBoxSize;
  49065. /**
  49066. * Gets or sets the size of the bounding box associated with the cube texture
  49067. * When defined, the cubemap will switch to local mode
  49068. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49069. * @example https://www.babylonjs-playground.com/#RNASML
  49070. */
  49071. boundingBoxSize: Vector3;
  49072. /**
  49073. * Instantiates an HDRTexture from the following parameters.
  49074. *
  49075. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49076. * @param scene The scene the texture will be used in
  49077. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49078. * @param noMipmap Forces to not generate the mipmap if true
  49079. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49080. * @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)
  49081. * @param reserved Reserved flag for internal use.
  49082. */
  49083. 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>);
  49084. /**
  49085. * Get the current class name of the texture useful for serialization or dynamic coding.
  49086. * @returns "HDRCubeTexture"
  49087. */
  49088. getClassName(): string;
  49089. /**
  49090. * Occurs when the file is raw .hdr file.
  49091. */
  49092. private loadTexture;
  49093. clone(): HDRCubeTexture;
  49094. delayLoad(): void;
  49095. /**
  49096. * Get the texture reflection matrix used to rotate/transform the reflection.
  49097. * @returns the reflection matrix
  49098. */
  49099. getReflectionTextureMatrix(): Matrix;
  49100. /**
  49101. * Set the texture reflection matrix used to rotate/transform the reflection.
  49102. * @param value Define the reflection matrix to set
  49103. */
  49104. setReflectionTextureMatrix(value: Matrix): void;
  49105. /**
  49106. * Parses a JSON representation of an HDR Texture in order to create the texture
  49107. * @param parsedTexture Define the JSON representation
  49108. * @param scene Define the scene the texture should be created in
  49109. * @param rootUrl Define the root url in case we need to load relative dependencies
  49110. * @returns the newly created texture after parsing
  49111. */
  49112. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49113. serialize(): any;
  49114. }
  49115. }
  49116. declare module BABYLON {
  49117. /**
  49118. * Class used to control physics engine
  49119. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49120. */
  49121. export class PhysicsEngine implements IPhysicsEngine {
  49122. private _physicsPlugin;
  49123. /**
  49124. * Global value used to control the smallest number supported by the simulation
  49125. */
  49126. static Epsilon: number;
  49127. private _impostors;
  49128. private _joints;
  49129. /**
  49130. * Gets the gravity vector used by the simulation
  49131. */
  49132. gravity: Vector3;
  49133. /**
  49134. * Factory used to create the default physics plugin.
  49135. * @returns The default physics plugin
  49136. */
  49137. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49138. /**
  49139. * Creates a new Physics Engine
  49140. * @param gravity defines the gravity vector used by the simulation
  49141. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49142. */
  49143. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49144. /**
  49145. * Sets the gravity vector used by the simulation
  49146. * @param gravity defines the gravity vector to use
  49147. */
  49148. setGravity(gravity: Vector3): void;
  49149. /**
  49150. * Set the time step of the physics engine.
  49151. * Default is 1/60.
  49152. * To slow it down, enter 1/600 for example.
  49153. * To speed it up, 1/30
  49154. * @param newTimeStep defines the new timestep to apply to this world.
  49155. */
  49156. setTimeStep(newTimeStep?: number): void;
  49157. /**
  49158. * Get the time step of the physics engine.
  49159. * @returns the current time step
  49160. */
  49161. getTimeStep(): number;
  49162. /**
  49163. * Release all resources
  49164. */
  49165. dispose(): void;
  49166. /**
  49167. * Gets the name of the current physics plugin
  49168. * @returns the name of the plugin
  49169. */
  49170. getPhysicsPluginName(): string;
  49171. /**
  49172. * Adding a new impostor for the impostor tracking.
  49173. * This will be done by the impostor itself.
  49174. * @param impostor the impostor to add
  49175. */
  49176. addImpostor(impostor: PhysicsImpostor): void;
  49177. /**
  49178. * Remove an impostor from the engine.
  49179. * This impostor and its mesh will not longer be updated by the physics engine.
  49180. * @param impostor the impostor to remove
  49181. */
  49182. removeImpostor(impostor: PhysicsImpostor): void;
  49183. /**
  49184. * Add a joint to the physics engine
  49185. * @param mainImpostor defines the main impostor to which the joint is added.
  49186. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49187. * @param joint defines the joint that will connect both impostors.
  49188. */
  49189. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49190. /**
  49191. * Removes a joint from the simulation
  49192. * @param mainImpostor defines the impostor used with the joint
  49193. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49194. * @param joint defines the joint to remove
  49195. */
  49196. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49197. /**
  49198. * Called by the scene. No need to call it.
  49199. * @param delta defines the timespam between frames
  49200. */ private _step(delta: number): void;
  49201. /**
  49202. * Gets the current plugin used to run the simulation
  49203. * @returns current plugin
  49204. */
  49205. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49206. /**
  49207. * Gets the list of physic impostors
  49208. * @returns an array of PhysicsImpostor
  49209. */
  49210. getImpostors(): Array<PhysicsImpostor>;
  49211. /**
  49212. * Gets the impostor for a physics enabled object
  49213. * @param object defines the object impersonated by the impostor
  49214. * @returns the PhysicsImpostor or null if not found
  49215. */
  49216. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49217. /**
  49218. * Gets the impostor for a physics body object
  49219. * @param body defines physics body used by the impostor
  49220. * @returns the PhysicsImpostor or null if not found
  49221. */
  49222. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49223. /**
  49224. * Does a raycast in the physics world
  49225. * @param from when should the ray start?
  49226. * @param to when should the ray end?
  49227. * @returns PhysicsRaycastResult
  49228. */
  49229. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49230. }
  49231. }
  49232. declare module BABYLON {
  49233. /** @hidden */
  49234. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49235. private _useDeltaForWorldStep;
  49236. world: any;
  49237. name: string;
  49238. private _physicsMaterials;
  49239. private _fixedTimeStep;
  49240. private _cannonRaycastResult;
  49241. private _raycastResult;
  49242. private _physicsBodysToRemoveAfterStep;
  49243. BJSCANNON: any;
  49244. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  49245. setGravity(gravity: Vector3): void;
  49246. setTimeStep(timeStep: number): void;
  49247. getTimeStep(): number;
  49248. executeStep(delta: number): void;
  49249. private _removeMarkedPhysicsBodiesFromWorld;
  49250. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49251. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49252. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49253. private _processChildMeshes;
  49254. removePhysicsBody(impostor: PhysicsImpostor): void;
  49255. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49256. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49257. private _addMaterial;
  49258. private _checkWithEpsilon;
  49259. private _createShape;
  49260. private _createHeightmap;
  49261. private _minus90X;
  49262. private _plus90X;
  49263. private _tmpPosition;
  49264. private _tmpDeltaPosition;
  49265. private _tmpUnityRotation;
  49266. private _updatePhysicsBodyTransformation;
  49267. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49268. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49269. isSupported(): boolean;
  49270. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49271. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49272. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49273. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49274. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49275. getBodyMass(impostor: PhysicsImpostor): number;
  49276. getBodyFriction(impostor: PhysicsImpostor): number;
  49277. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49278. getBodyRestitution(impostor: PhysicsImpostor): number;
  49279. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49280. sleepBody(impostor: PhysicsImpostor): void;
  49281. wakeUpBody(impostor: PhysicsImpostor): void;
  49282. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  49283. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49284. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49285. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49286. getRadius(impostor: PhysicsImpostor): number;
  49287. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49288. dispose(): void;
  49289. private _extendNamespace;
  49290. /**
  49291. * Does a raycast in the physics world
  49292. * @param from when should the ray start?
  49293. * @param to when should the ray end?
  49294. * @returns PhysicsRaycastResult
  49295. */
  49296. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49297. }
  49298. }
  49299. declare module BABYLON {
  49300. /** @hidden */
  49301. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  49302. world: any;
  49303. name: string;
  49304. BJSOIMO: any;
  49305. private _raycastResult;
  49306. constructor(iterations?: number, oimoInjection?: any);
  49307. setGravity(gravity: Vector3): void;
  49308. setTimeStep(timeStep: number): void;
  49309. getTimeStep(): number;
  49310. private _tmpImpostorsArray;
  49311. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49312. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49313. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49314. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49315. private _tmpPositionVector;
  49316. removePhysicsBody(impostor: PhysicsImpostor): void;
  49317. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49318. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49319. isSupported(): boolean;
  49320. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49321. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49322. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49323. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49324. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49325. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49326. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49327. getBodyMass(impostor: PhysicsImpostor): number;
  49328. getBodyFriction(impostor: PhysicsImpostor): number;
  49329. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49330. getBodyRestitution(impostor: PhysicsImpostor): number;
  49331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49332. sleepBody(impostor: PhysicsImpostor): void;
  49333. wakeUpBody(impostor: PhysicsImpostor): void;
  49334. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49335. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  49336. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  49337. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49338. getRadius(impostor: PhysicsImpostor): number;
  49339. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49340. dispose(): void;
  49341. /**
  49342. * Does a raycast in the physics world
  49343. * @param from when should the ray start?
  49344. * @param to when should the ray end?
  49345. * @returns PhysicsRaycastResult
  49346. */
  49347. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49348. }
  49349. }
  49350. declare module BABYLON {
  49351. /**
  49352. * Class containing static functions to help procedurally build meshes
  49353. */
  49354. export class RibbonBuilder {
  49355. /**
  49356. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  49357. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  49358. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  49359. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  49360. * * 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
  49361. * * 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
  49362. * * 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
  49363. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49364. * * 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
  49365. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49366. * * 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
  49367. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  49368. * * 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
  49369. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  49370. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49371. * @param name defines the name of the mesh
  49372. * @param options defines the options used to create the mesh
  49373. * @param scene defines the hosting scene
  49374. * @returns the ribbon mesh
  49375. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  49376. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49377. */
  49378. static CreateRibbon(name: string, options: {
  49379. pathArray: Vector3[][];
  49380. closeArray?: boolean;
  49381. closePath?: boolean;
  49382. offset?: number;
  49383. updatable?: boolean;
  49384. sideOrientation?: number;
  49385. frontUVs?: Vector4;
  49386. backUVs?: Vector4;
  49387. instance?: Mesh;
  49388. invertUV?: boolean;
  49389. uvs?: Vector2[];
  49390. colors?: Color4[];
  49391. }, scene?: Nullable<Scene>): Mesh;
  49392. }
  49393. }
  49394. declare module BABYLON {
  49395. /**
  49396. * Class containing static functions to help procedurally build meshes
  49397. */
  49398. export class ShapeBuilder {
  49399. /**
  49400. * 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.
  49401. * * 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.
  49402. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49403. * * 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.
  49404. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  49405. * * 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
  49406. * * 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
  49407. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  49408. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49409. * * 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
  49410. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  49411. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  49412. * @param name defines the name of the mesh
  49413. * @param options defines the options used to create the mesh
  49414. * @param scene defines the hosting scene
  49415. * @returns the extruded shape mesh
  49416. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49418. */
  49419. static ExtrudeShape(name: string, options: {
  49420. shape: Vector3[];
  49421. path: Vector3[];
  49422. scale?: number;
  49423. rotation?: number;
  49424. cap?: number;
  49425. updatable?: boolean;
  49426. sideOrientation?: number;
  49427. frontUVs?: Vector4;
  49428. backUVs?: Vector4;
  49429. instance?: Mesh;
  49430. invertUV?: boolean;
  49431. }, scene?: Nullable<Scene>): Mesh;
  49432. /**
  49433. * Creates an custom extruded shape mesh.
  49434. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  49435. * * 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.
  49436. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  49437. * * 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
  49438. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  49439. * * 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
  49440. * * It must returns a float value that will be the scale value applied to the shape on each path point
  49441. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  49442. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  49443. * * 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
  49444. * * 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
  49445. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  49446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  49447. * * 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
  49448. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  49449. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  49450. * @param name defines the name of the mesh
  49451. * @param options defines the options used to create the mesh
  49452. * @param scene defines the hosting scene
  49453. * @returns the custom extruded shape mesh
  49454. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  49455. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  49456. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  49457. */
  49458. static ExtrudeShapeCustom(name: string, options: {
  49459. shape: Vector3[];
  49460. path: Vector3[];
  49461. scaleFunction?: any;
  49462. rotationFunction?: any;
  49463. ribbonCloseArray?: boolean;
  49464. ribbonClosePath?: boolean;
  49465. cap?: number;
  49466. updatable?: boolean;
  49467. sideOrientation?: number;
  49468. frontUVs?: Vector4;
  49469. backUVs?: Vector4;
  49470. instance?: Mesh;
  49471. invertUV?: boolean;
  49472. }, scene?: Nullable<Scene>): Mesh;
  49473. private static _ExtrudeShapeGeneric;
  49474. }
  49475. }
  49476. declare module BABYLON {
  49477. /**
  49478. * AmmoJS Physics plugin
  49479. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  49480. * @see https://github.com/kripken/ammo.js/
  49481. */
  49482. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  49483. private _useDeltaForWorldStep;
  49484. /**
  49485. * Reference to the Ammo library
  49486. */
  49487. bjsAMMO: any;
  49488. /**
  49489. * Created ammoJS world which physics bodies are added to
  49490. */
  49491. world: any;
  49492. /**
  49493. * Name of the plugin
  49494. */
  49495. name: string;
  49496. private _timeStep;
  49497. private _fixedTimeStep;
  49498. private _maxSteps;
  49499. private _tmpQuaternion;
  49500. private _tmpAmmoTransform;
  49501. private _tmpAmmoQuaternion;
  49502. private _tmpAmmoConcreteContactResultCallback;
  49503. private _collisionConfiguration;
  49504. private _dispatcher;
  49505. private _overlappingPairCache;
  49506. private _solver;
  49507. private _softBodySolver;
  49508. private _tmpAmmoVectorA;
  49509. private _tmpAmmoVectorB;
  49510. private _tmpAmmoVectorC;
  49511. private _tmpAmmoVectorD;
  49512. private _tmpContactCallbackResult;
  49513. private _tmpAmmoVectorRCA;
  49514. private _tmpAmmoVectorRCB;
  49515. private _raycastResult;
  49516. private static readonly DISABLE_COLLISION_FLAG;
  49517. private static readonly KINEMATIC_FLAG;
  49518. private static readonly DISABLE_DEACTIVATION_FLAG;
  49519. /**
  49520. * Initializes the ammoJS plugin
  49521. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  49522. * @param ammoInjection can be used to inject your own ammo reference
  49523. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  49524. */
  49525. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  49526. /**
  49527. * Sets the gravity of the physics world (m/(s^2))
  49528. * @param gravity Gravity to set
  49529. */
  49530. setGravity(gravity: Vector3): void;
  49531. /**
  49532. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  49533. * @param timeStep timestep to use in seconds
  49534. */
  49535. setTimeStep(timeStep: number): void;
  49536. /**
  49537. * 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)
  49538. * @param fixedTimeStep fixedTimeStep to use in seconds
  49539. */
  49540. setFixedTimeStep(fixedTimeStep: number): void;
  49541. /**
  49542. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  49543. * @param maxSteps the maximum number of steps by the physics engine per frame
  49544. */
  49545. setMaxSteps(maxSteps: number): void;
  49546. /**
  49547. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  49548. * @returns the current timestep in seconds
  49549. */
  49550. getTimeStep(): number;
  49551. private _isImpostorInContact;
  49552. private _isImpostorPairInContact;
  49553. private _stepSimulation;
  49554. /**
  49555. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  49556. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  49557. * After the step the babylon meshes are set to the position of the physics imposters
  49558. * @param delta amount of time to step forward
  49559. * @param impostors array of imposters to update before/after the step
  49560. */
  49561. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  49562. /**
  49563. * Update babylon mesh to match physics world object
  49564. * @param impostor imposter to match
  49565. */
  49566. private _afterSoftStep;
  49567. /**
  49568. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49569. * @param impostor imposter to match
  49570. */
  49571. private _ropeStep;
  49572. /**
  49573. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  49574. * @param impostor imposter to match
  49575. */
  49576. private _softbodyOrClothStep;
  49577. private _tmpVector;
  49578. private _tmpMatrix;
  49579. /**
  49580. * Applies an impulse on the imposter
  49581. * @param impostor imposter to apply impulse to
  49582. * @param force amount of force to be applied to the imposter
  49583. * @param contactPoint the location to apply the impulse on the imposter
  49584. */
  49585. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49586. /**
  49587. * Applies a force on the imposter
  49588. * @param impostor imposter to apply force
  49589. * @param force amount of force to be applied to the imposter
  49590. * @param contactPoint the location to apply the force on the imposter
  49591. */
  49592. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  49593. /**
  49594. * Creates a physics body using the plugin
  49595. * @param impostor the imposter to create the physics body on
  49596. */
  49597. generatePhysicsBody(impostor: PhysicsImpostor): void;
  49598. /**
  49599. * Removes the physics body from the imposter and disposes of the body's memory
  49600. * @param impostor imposter to remove the physics body from
  49601. */
  49602. removePhysicsBody(impostor: PhysicsImpostor): void;
  49603. /**
  49604. * Generates a joint
  49605. * @param impostorJoint the imposter joint to create the joint with
  49606. */
  49607. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  49608. /**
  49609. * Removes a joint
  49610. * @param impostorJoint the imposter joint to remove the joint from
  49611. */
  49612. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  49613. private _addMeshVerts;
  49614. /**
  49615. * Initialise the soft body vertices to match its object's (mesh) vertices
  49616. * Softbody vertices (nodes) are in world space and to match this
  49617. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  49618. * @param impostor to create the softbody for
  49619. */
  49620. private _softVertexData;
  49621. /**
  49622. * Create an impostor's soft body
  49623. * @param impostor to create the softbody for
  49624. */
  49625. private _createSoftbody;
  49626. /**
  49627. * Create cloth for an impostor
  49628. * @param impostor to create the softbody for
  49629. */
  49630. private _createCloth;
  49631. /**
  49632. * Create rope for an impostor
  49633. * @param impostor to create the softbody for
  49634. */
  49635. private _createRope;
  49636. private _addHullVerts;
  49637. private _createShape;
  49638. /**
  49639. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  49640. * @param impostor imposter containing the physics body and babylon object
  49641. */
  49642. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  49643. /**
  49644. * Sets the babylon object's position/rotation from the physics body's position/rotation
  49645. * @param impostor imposter containing the physics body and babylon object
  49646. * @param newPosition new position
  49647. * @param newRotation new rotation
  49648. */
  49649. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  49650. /**
  49651. * If this plugin is supported
  49652. * @returns true if its supported
  49653. */
  49654. isSupported(): boolean;
  49655. /**
  49656. * Sets the linear velocity of the physics body
  49657. * @param impostor imposter to set the velocity on
  49658. * @param velocity velocity to set
  49659. */
  49660. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49661. /**
  49662. * Sets the angular velocity of the physics body
  49663. * @param impostor imposter to set the velocity on
  49664. * @param velocity velocity to set
  49665. */
  49666. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  49667. /**
  49668. * gets the linear velocity
  49669. * @param impostor imposter to get linear velocity from
  49670. * @returns linear velocity
  49671. */
  49672. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49673. /**
  49674. * gets the angular velocity
  49675. * @param impostor imposter to get angular velocity from
  49676. * @returns angular velocity
  49677. */
  49678. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  49679. /**
  49680. * Sets the mass of physics body
  49681. * @param impostor imposter to set the mass on
  49682. * @param mass mass to set
  49683. */
  49684. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  49685. /**
  49686. * Gets the mass of the physics body
  49687. * @param impostor imposter to get the mass from
  49688. * @returns mass
  49689. */
  49690. getBodyMass(impostor: PhysicsImpostor): number;
  49691. /**
  49692. * Gets friction of the impostor
  49693. * @param impostor impostor to get friction from
  49694. * @returns friction value
  49695. */
  49696. getBodyFriction(impostor: PhysicsImpostor): number;
  49697. /**
  49698. * Sets friction of the impostor
  49699. * @param impostor impostor to set friction on
  49700. * @param friction friction value
  49701. */
  49702. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  49703. /**
  49704. * Gets restitution of the impostor
  49705. * @param impostor impostor to get restitution from
  49706. * @returns restitution value
  49707. */
  49708. getBodyRestitution(impostor: PhysicsImpostor): number;
  49709. /**
  49710. * Sets resitution of the impostor
  49711. * @param impostor impostor to set resitution on
  49712. * @param restitution resitution value
  49713. */
  49714. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  49715. /**
  49716. * Gets pressure inside the impostor
  49717. * @param impostor impostor to get pressure from
  49718. * @returns pressure value
  49719. */
  49720. getBodyPressure(impostor: PhysicsImpostor): number;
  49721. /**
  49722. * Sets pressure inside a soft body impostor
  49723. * Cloth and rope must remain 0 pressure
  49724. * @param impostor impostor to set pressure on
  49725. * @param pressure pressure value
  49726. */
  49727. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  49728. /**
  49729. * Gets stiffness of the impostor
  49730. * @param impostor impostor to get stiffness from
  49731. * @returns pressure value
  49732. */
  49733. getBodyStiffness(impostor: PhysicsImpostor): number;
  49734. /**
  49735. * Sets stiffness of the impostor
  49736. * @param impostor impostor to set stiffness on
  49737. * @param stiffness stiffness value from 0 to 1
  49738. */
  49739. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  49740. /**
  49741. * Gets velocityIterations of the impostor
  49742. * @param impostor impostor to get velocity iterations from
  49743. * @returns velocityIterations value
  49744. */
  49745. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  49746. /**
  49747. * Sets velocityIterations of the impostor
  49748. * @param impostor impostor to set velocity iterations on
  49749. * @param velocityIterations velocityIterations value
  49750. */
  49751. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  49752. /**
  49753. * Gets positionIterations of the impostor
  49754. * @param impostor impostor to get position iterations from
  49755. * @returns positionIterations value
  49756. */
  49757. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  49758. /**
  49759. * Sets positionIterations of the impostor
  49760. * @param impostor impostor to set position on
  49761. * @param positionIterations positionIterations value
  49762. */
  49763. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  49764. /**
  49765. * Append an anchor to a cloth object
  49766. * @param impostor is the cloth impostor to add anchor to
  49767. * @param otherImpostor is the rigid impostor to anchor to
  49768. * @param width ratio across width from 0 to 1
  49769. * @param height ratio up height from 0 to 1
  49770. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  49771. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49772. */
  49773. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49774. /**
  49775. * Append an hook to a rope object
  49776. * @param impostor is the rope impostor to add hook to
  49777. * @param otherImpostor is the rigid impostor to hook to
  49778. * @param length ratio along the rope from 0 to 1
  49779. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  49780. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  49781. */
  49782. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  49783. /**
  49784. * Sleeps the physics body and stops it from being active
  49785. * @param impostor impostor to sleep
  49786. */
  49787. sleepBody(impostor: PhysicsImpostor): void;
  49788. /**
  49789. * Activates the physics body
  49790. * @param impostor impostor to activate
  49791. */
  49792. wakeUpBody(impostor: PhysicsImpostor): void;
  49793. /**
  49794. * Updates the distance parameters of the joint
  49795. * @param joint joint to update
  49796. * @param maxDistance maximum distance of the joint
  49797. * @param minDistance minimum distance of the joint
  49798. */
  49799. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  49800. /**
  49801. * Sets a motor on the joint
  49802. * @param joint joint to set motor on
  49803. * @param speed speed of the motor
  49804. * @param maxForce maximum force of the motor
  49805. * @param motorIndex index of the motor
  49806. */
  49807. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  49808. /**
  49809. * Sets the motors limit
  49810. * @param joint joint to set limit on
  49811. * @param upperLimit upper limit
  49812. * @param lowerLimit lower limit
  49813. */
  49814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  49815. /**
  49816. * Syncs the position and rotation of a mesh with the impostor
  49817. * @param mesh mesh to sync
  49818. * @param impostor impostor to update the mesh with
  49819. */
  49820. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  49821. /**
  49822. * Gets the radius of the impostor
  49823. * @param impostor impostor to get radius from
  49824. * @returns the radius
  49825. */
  49826. getRadius(impostor: PhysicsImpostor): number;
  49827. /**
  49828. * Gets the box size of the impostor
  49829. * @param impostor impostor to get box size from
  49830. * @param result the resulting box size
  49831. */
  49832. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  49833. /**
  49834. * Disposes of the impostor
  49835. */
  49836. dispose(): void;
  49837. /**
  49838. * Does a raycast in the physics world
  49839. * @param from when should the ray start?
  49840. * @param to when should the ray end?
  49841. * @returns PhysicsRaycastResult
  49842. */
  49843. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49844. }
  49845. }
  49846. declare module BABYLON {
  49847. interface AbstractScene {
  49848. /**
  49849. * The list of reflection probes added to the scene
  49850. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49851. */
  49852. reflectionProbes: Array<ReflectionProbe>;
  49853. /**
  49854. * Removes the given reflection probe from this scene.
  49855. * @param toRemove The reflection probe to remove
  49856. * @returns The index of the removed reflection probe
  49857. */
  49858. removeReflectionProbe(toRemove: ReflectionProbe): number;
  49859. /**
  49860. * Adds the given reflection probe to this scene.
  49861. * @param newReflectionProbe The reflection probe to add
  49862. */
  49863. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  49864. }
  49865. /**
  49866. * Class used to generate realtime reflection / refraction cube textures
  49867. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  49868. */
  49869. export class ReflectionProbe {
  49870. /** defines the name of the probe */
  49871. name: string;
  49872. private _scene;
  49873. private _renderTargetTexture;
  49874. private _projectionMatrix;
  49875. private _viewMatrix;
  49876. private _target;
  49877. private _add;
  49878. private _attachedMesh;
  49879. private _invertYAxis;
  49880. /** Gets or sets probe position (center of the cube map) */
  49881. position: Vector3;
  49882. /**
  49883. * Creates a new reflection probe
  49884. * @param name defines the name of the probe
  49885. * @param size defines the texture resolution (for each face)
  49886. * @param scene defines the hosting scene
  49887. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  49888. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  49889. */
  49890. constructor(
  49891. /** defines the name of the probe */
  49892. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  49893. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  49894. samples: number;
  49895. /** Gets or sets the refresh rate to use (on every frame by default) */
  49896. refreshRate: number;
  49897. /**
  49898. * Gets the hosting scene
  49899. * @returns a Scene
  49900. */
  49901. getScene(): Scene;
  49902. /** Gets the internal CubeTexture used to render to */
  49903. readonly cubeTexture: RenderTargetTexture;
  49904. /** Gets the list of meshes to render */
  49905. readonly renderList: Nullable<AbstractMesh[]>;
  49906. /**
  49907. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  49908. * @param mesh defines the mesh to attach to
  49909. */
  49910. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  49911. /**
  49912. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  49913. * @param renderingGroupId The rendering group id corresponding to its index
  49914. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  49915. */
  49916. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  49917. /**
  49918. * Clean all associated resources
  49919. */
  49920. dispose(): void;
  49921. /**
  49922. * Converts the reflection probe information to a readable string for debug purpose.
  49923. * @param fullDetails Supports for multiple levels of logging within scene loading
  49924. * @returns the human readable reflection probe info
  49925. */
  49926. toString(fullDetails?: boolean): string;
  49927. /**
  49928. * Get the class name of the relfection probe.
  49929. * @returns "ReflectionProbe"
  49930. */
  49931. getClassName(): string;
  49932. /**
  49933. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  49934. * @returns The JSON representation of the texture
  49935. */
  49936. serialize(): any;
  49937. /**
  49938. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  49939. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  49940. * @param scene Define the scene the parsed reflection probe should be instantiated in
  49941. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  49942. * @returns The parsed reflection probe if successful
  49943. */
  49944. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  49945. }
  49946. }
  49947. declare module BABYLON {
  49948. /** @hidden */
  49949. export var _BabylonLoaderRegistered: boolean;
  49950. }
  49951. declare module BABYLON {
  49952. /**
  49953. * The Physically based simple base material of BJS.
  49954. *
  49955. * This enables better naming and convention enforcements on top of the pbrMaterial.
  49956. * It is used as the base class for both the specGloss and metalRough conventions.
  49957. */
  49958. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  49959. /**
  49960. * Number of Simultaneous lights allowed on the material.
  49961. */
  49962. maxSimultaneousLights: number;
  49963. /**
  49964. * If sets to true, disables all the lights affecting the material.
  49965. */
  49966. disableLighting: boolean;
  49967. /**
  49968. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  49969. */
  49970. environmentTexture: BaseTexture;
  49971. /**
  49972. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  49973. */
  49974. invertNormalMapX: boolean;
  49975. /**
  49976. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  49977. */
  49978. invertNormalMapY: boolean;
  49979. /**
  49980. * Normal map used in the model.
  49981. */
  49982. normalTexture: BaseTexture;
  49983. /**
  49984. * Emissivie color used to self-illuminate the model.
  49985. */
  49986. emissiveColor: Color3;
  49987. /**
  49988. * Emissivie texture used to self-illuminate the model.
  49989. */
  49990. emissiveTexture: BaseTexture;
  49991. /**
  49992. * Occlusion Channel Strenght.
  49993. */
  49994. occlusionStrength: number;
  49995. /**
  49996. * Occlusion Texture of the material (adding extra occlusion effects).
  49997. */
  49998. occlusionTexture: BaseTexture;
  49999. /**
  50000. * Defines the alpha limits in alpha test mode.
  50001. */
  50002. alphaCutOff: number;
  50003. /**
  50004. * Gets the current double sided mode.
  50005. */
  50006. /**
  50007. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50008. */
  50009. doubleSided: boolean;
  50010. /**
  50011. * Stores the pre-calculated light information of a mesh in a texture.
  50012. */
  50013. lightmapTexture: BaseTexture;
  50014. /**
  50015. * If true, the light map contains occlusion information instead of lighting info.
  50016. */
  50017. useLightmapAsShadowmap: boolean;
  50018. /**
  50019. * Instantiates a new PBRMaterial instance.
  50020. *
  50021. * @param name The material name
  50022. * @param scene The scene the material will be use in.
  50023. */
  50024. constructor(name: string, scene: Scene);
  50025. getClassName(): string;
  50026. }
  50027. }
  50028. declare module BABYLON {
  50029. /**
  50030. * The PBR material of BJS following the metal roughness convention.
  50031. *
  50032. * This fits to the PBR convention in the GLTF definition:
  50033. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50034. */
  50035. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50036. /**
  50037. * The base color has two different interpretations depending on the value of metalness.
  50038. * When the material is a metal, the base color is the specific measured reflectance value
  50039. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50040. * of the material.
  50041. */
  50042. baseColor: Color3;
  50043. /**
  50044. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50045. * well as opacity information in the alpha channel.
  50046. */
  50047. baseTexture: BaseTexture;
  50048. /**
  50049. * Specifies the metallic scalar value of the material.
  50050. * Can also be used to scale the metalness values of the metallic texture.
  50051. */
  50052. metallic: number;
  50053. /**
  50054. * Specifies the roughness scalar value of the material.
  50055. * Can also be used to scale the roughness values of the metallic texture.
  50056. */
  50057. roughness: number;
  50058. /**
  50059. * Texture containing both the metallic value in the B channel and the
  50060. * roughness value in the G channel to keep better precision.
  50061. */
  50062. metallicRoughnessTexture: BaseTexture;
  50063. /**
  50064. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50065. *
  50066. * @param name The material name
  50067. * @param scene The scene the material will be use in.
  50068. */
  50069. constructor(name: string, scene: Scene);
  50070. /**
  50071. * Return the currrent class name of the material.
  50072. */
  50073. getClassName(): string;
  50074. /**
  50075. * Makes a duplicate of the current material.
  50076. * @param name - name to use for the new material.
  50077. */
  50078. clone(name: string): PBRMetallicRoughnessMaterial;
  50079. /**
  50080. * Serialize the material to a parsable JSON object.
  50081. */
  50082. serialize(): any;
  50083. /**
  50084. * Parses a JSON object correponding to the serialize function.
  50085. */
  50086. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50087. }
  50088. }
  50089. declare module BABYLON {
  50090. /**
  50091. * The PBR material of BJS following the specular glossiness convention.
  50092. *
  50093. * This fits to the PBR convention in the GLTF definition:
  50094. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50095. */
  50096. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50097. /**
  50098. * Specifies the diffuse color of the material.
  50099. */
  50100. diffuseColor: Color3;
  50101. /**
  50102. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50103. * channel.
  50104. */
  50105. diffuseTexture: BaseTexture;
  50106. /**
  50107. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50108. */
  50109. specularColor: Color3;
  50110. /**
  50111. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50112. */
  50113. glossiness: number;
  50114. /**
  50115. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50116. */
  50117. specularGlossinessTexture: BaseTexture;
  50118. /**
  50119. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50120. *
  50121. * @param name The material name
  50122. * @param scene The scene the material will be use in.
  50123. */
  50124. constructor(name: string, scene: Scene);
  50125. /**
  50126. * Return the currrent class name of the material.
  50127. */
  50128. getClassName(): string;
  50129. /**
  50130. * Makes a duplicate of the current material.
  50131. * @param name - name to use for the new material.
  50132. */
  50133. clone(name: string): PBRSpecularGlossinessMaterial;
  50134. /**
  50135. * Serialize the material to a parsable JSON object.
  50136. */
  50137. serialize(): any;
  50138. /**
  50139. * Parses a JSON object correponding to the serialize function.
  50140. */
  50141. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50142. }
  50143. }
  50144. declare module BABYLON {
  50145. /**
  50146. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50147. * It can help converting any input color in a desired output one. This can then be used to create effects
  50148. * from sepia, black and white to sixties or futuristic rendering...
  50149. *
  50150. * The only supported format is currently 3dl.
  50151. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50152. */
  50153. export class ColorGradingTexture extends BaseTexture {
  50154. /**
  50155. * The current texture matrix. (will always be identity in color grading texture)
  50156. */
  50157. private _textureMatrix;
  50158. /**
  50159. * The texture URL.
  50160. */
  50161. url: string;
  50162. /**
  50163. * Empty line regex stored for GC.
  50164. */
  50165. private static _noneEmptyLineRegex;
  50166. private _engine;
  50167. /**
  50168. * Instantiates a ColorGradingTexture from the following parameters.
  50169. *
  50170. * @param url The location of the color gradind data (currently only supporting 3dl)
  50171. * @param scene The scene the texture will be used in
  50172. */
  50173. constructor(url: string, scene: Scene);
  50174. /**
  50175. * Returns the texture matrix used in most of the material.
  50176. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50177. */
  50178. getTextureMatrix(): Matrix;
  50179. /**
  50180. * Occurs when the file being loaded is a .3dl LUT file.
  50181. */
  50182. private load3dlTexture;
  50183. /**
  50184. * Starts the loading process of the texture.
  50185. */
  50186. private loadTexture;
  50187. /**
  50188. * Clones the color gradind texture.
  50189. */
  50190. clone(): ColorGradingTexture;
  50191. /**
  50192. * Called during delayed load for textures.
  50193. */
  50194. delayLoad(): void;
  50195. /**
  50196. * Parses a color grading texture serialized by Babylon.
  50197. * @param parsedTexture The texture information being parsedTexture
  50198. * @param scene The scene to load the texture in
  50199. * @param rootUrl The root url of the data assets to load
  50200. * @return A color gradind texture
  50201. */
  50202. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  50203. /**
  50204. * Serializes the LUT texture to json format.
  50205. */
  50206. serialize(): any;
  50207. }
  50208. }
  50209. declare module BABYLON {
  50210. /**
  50211. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  50212. */
  50213. export class EquiRectangularCubeTexture extends BaseTexture {
  50214. /** The six faces of the cube. */
  50215. private static _FacesMapping;
  50216. private _noMipmap;
  50217. private _onLoad;
  50218. private _onError;
  50219. /** The size of the cubemap. */
  50220. private _size;
  50221. /** The buffer of the image. */
  50222. private _buffer;
  50223. /** The width of the input image. */
  50224. private _width;
  50225. /** The height of the input image. */
  50226. private _height;
  50227. /** The URL to the image. */
  50228. url: string;
  50229. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  50230. coordinatesMode: number;
  50231. /**
  50232. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  50233. * @param url The location of the image
  50234. * @param scene The scene the texture will be used in
  50235. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  50236. * @param noMipmap Forces to not generate the mipmap if true
  50237. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  50238. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  50239. * @param onLoad — defines a callback called when texture is loaded
  50240. * @param onError — defines a callback called if there is an error
  50241. */
  50242. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  50243. /**
  50244. * Load the image data, by putting the image on a canvas and extracting its buffer.
  50245. */
  50246. private loadImage;
  50247. /**
  50248. * Convert the image buffer into a cubemap and create a CubeTexture.
  50249. */
  50250. private loadTexture;
  50251. /**
  50252. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  50253. * @param buffer The ArrayBuffer that should be converted.
  50254. * @returns The buffer as Float32Array.
  50255. */
  50256. private getFloat32ArrayFromArrayBuffer;
  50257. /**
  50258. * Get the current class name of the texture useful for serialization or dynamic coding.
  50259. * @returns "EquiRectangularCubeTexture"
  50260. */
  50261. getClassName(): string;
  50262. /**
  50263. * Create a clone of the current EquiRectangularCubeTexture and return it.
  50264. * @returns A clone of the current EquiRectangularCubeTexture.
  50265. */
  50266. clone(): EquiRectangularCubeTexture;
  50267. }
  50268. }
  50269. declare module BABYLON {
  50270. /**
  50271. * Based on jsTGALoader - Javascript loader for TGA file
  50272. * By Vincent Thibault
  50273. * @see http://blog.robrowser.com/javascript-tga-loader.html
  50274. */
  50275. export class TGATools {
  50276. private static _TYPE_INDEXED;
  50277. private static _TYPE_RGB;
  50278. private static _TYPE_GREY;
  50279. private static _TYPE_RLE_INDEXED;
  50280. private static _TYPE_RLE_RGB;
  50281. private static _TYPE_RLE_GREY;
  50282. private static _ORIGIN_MASK;
  50283. private static _ORIGIN_SHIFT;
  50284. private static _ORIGIN_BL;
  50285. private static _ORIGIN_BR;
  50286. private static _ORIGIN_UL;
  50287. private static _ORIGIN_UR;
  50288. /**
  50289. * Gets the header of a TGA file
  50290. * @param data defines the TGA data
  50291. * @returns the header
  50292. */
  50293. static GetTGAHeader(data: Uint8Array): any;
  50294. /**
  50295. * Uploads TGA content to a Babylon Texture
  50296. * @hidden
  50297. */
  50298. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  50299. /** @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;
  50300. /** @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;
  50301. /** @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;
  50302. /** @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;
  50303. /** @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;
  50304. /** @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;
  50305. }
  50306. }
  50307. declare module BABYLON {
  50308. /**
  50309. * Implementation of the TGA Texture Loader.
  50310. * @hidden
  50311. */
  50312. export class _TGATextureLoader implements IInternalTextureLoader {
  50313. /**
  50314. * Defines wether the loader supports cascade loading the different faces.
  50315. */
  50316. readonly supportCascades: boolean;
  50317. /**
  50318. * This returns if the loader support the current file information.
  50319. * @param extension defines the file extension of the file being loaded
  50320. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50321. * @param fallback defines the fallback internal texture if any
  50322. * @param isBase64 defines whether the texture is encoded as a base64
  50323. * @param isBuffer defines whether the texture data are stored as a buffer
  50324. * @returns true if the loader can load the specified file
  50325. */
  50326. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50327. /**
  50328. * Transform the url before loading if required.
  50329. * @param rootUrl the url of the texture
  50330. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50331. * @returns the transformed texture
  50332. */
  50333. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50334. /**
  50335. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50336. * @param rootUrl the url of the texture
  50337. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50338. * @returns the fallback texture
  50339. */
  50340. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50341. /**
  50342. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50343. * @param data contains the texture data
  50344. * @param texture defines the BabylonJS internal texture
  50345. * @param createPolynomials will be true if polynomials have been requested
  50346. * @param onLoad defines the callback to trigger once the texture is ready
  50347. * @param onError defines the callback to trigger in case of error
  50348. */
  50349. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50350. /**
  50351. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50352. * @param data contains the texture data
  50353. * @param texture defines the BabylonJS internal texture
  50354. * @param callback defines the method to call once ready to upload
  50355. */
  50356. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50357. }
  50358. }
  50359. declare module BABYLON {
  50360. /**
  50361. * Info about the .basis files
  50362. */
  50363. class BasisFileInfo {
  50364. /**
  50365. * If the file has alpha
  50366. */
  50367. hasAlpha: boolean;
  50368. /**
  50369. * Info about each image of the basis file
  50370. */
  50371. images: Array<{
  50372. levels: Array<{
  50373. width: number;
  50374. height: number;
  50375. transcodedPixels: ArrayBufferView;
  50376. }>;
  50377. }>;
  50378. }
  50379. /**
  50380. * Result of transcoding a basis file
  50381. */
  50382. class TranscodeResult {
  50383. /**
  50384. * Info about the .basis file
  50385. */
  50386. fileInfo: BasisFileInfo;
  50387. /**
  50388. * Format to use when loading the file
  50389. */
  50390. format: number;
  50391. }
  50392. /**
  50393. * Configuration options for the Basis transcoder
  50394. */
  50395. export class BasisTranscodeConfiguration {
  50396. /**
  50397. * Supported compression formats used to determine the supported output format of the transcoder
  50398. */
  50399. supportedCompressionFormats?: {
  50400. /**
  50401. * etc1 compression format
  50402. */
  50403. etc1?: boolean;
  50404. /**
  50405. * s3tc compression format
  50406. */
  50407. s3tc?: boolean;
  50408. /**
  50409. * pvrtc compression format
  50410. */
  50411. pvrtc?: boolean;
  50412. /**
  50413. * etc2 compression format
  50414. */
  50415. etc2?: boolean;
  50416. };
  50417. /**
  50418. * If mipmap levels should be loaded for transcoded images (Default: true)
  50419. */
  50420. loadMipmapLevels?: boolean;
  50421. /**
  50422. * Index of a single image to load (Default: all images)
  50423. */
  50424. loadSingleImage?: number;
  50425. }
  50426. /**
  50427. * Used to load .Basis files
  50428. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  50429. */
  50430. export class BasisTools {
  50431. private static _IgnoreSupportedFormats;
  50432. /**
  50433. * URL to use when loading the basis transcoder
  50434. */
  50435. static JSModuleURL: string;
  50436. /**
  50437. * URL to use when loading the wasm module for the transcoder
  50438. */
  50439. static WasmModuleURL: string;
  50440. /**
  50441. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  50442. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  50443. * @returns internal format corresponding to the Basis format
  50444. */
  50445. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  50446. private static _WorkerPromise;
  50447. private static _Worker;
  50448. private static _actionId;
  50449. private static _CreateWorkerAsync;
  50450. /**
  50451. * Transcodes a loaded image file to compressed pixel data
  50452. * @param imageData image data to transcode
  50453. * @param config configuration options for the transcoding
  50454. * @returns a promise resulting in the transcoded image
  50455. */
  50456. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  50457. /**
  50458. * Loads a texture from the transcode result
  50459. * @param texture texture load to
  50460. * @param transcodeResult the result of transcoding the basis file to load from
  50461. */
  50462. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  50463. }
  50464. }
  50465. declare module BABYLON {
  50466. /**
  50467. * Loader for .basis file format
  50468. */
  50469. export class _BasisTextureLoader implements IInternalTextureLoader {
  50470. /**
  50471. * Defines whether the loader supports cascade loading the different faces.
  50472. */
  50473. readonly supportCascades: boolean;
  50474. /**
  50475. * This returns if the loader support the current file information.
  50476. * @param extension defines the file extension of the file being loaded
  50477. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50478. * @param fallback defines the fallback internal texture if any
  50479. * @param isBase64 defines whether the texture is encoded as a base64
  50480. * @param isBuffer defines whether the texture data are stored as a buffer
  50481. * @returns true if the loader can load the specified file
  50482. */
  50483. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50484. /**
  50485. * Transform the url before loading if required.
  50486. * @param rootUrl the url of the texture
  50487. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50488. * @returns the transformed texture
  50489. */
  50490. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50491. /**
  50492. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50493. * @param rootUrl the url of the texture
  50494. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50495. * @returns the fallback texture
  50496. */
  50497. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50498. /**
  50499. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  50500. * @param data contains the texture data
  50501. * @param texture defines the BabylonJS internal texture
  50502. * @param createPolynomials will be true if polynomials have been requested
  50503. * @param onLoad defines the callback to trigger once the texture is ready
  50504. * @param onError defines the callback to trigger in case of error
  50505. */
  50506. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50507. /**
  50508. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50509. * @param data contains the texture data
  50510. * @param texture defines the BabylonJS internal texture
  50511. * @param callback defines the method to call once ready to upload
  50512. */
  50513. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50514. }
  50515. }
  50516. declare module BABYLON {
  50517. /**
  50518. * 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.
  50519. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50520. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50521. */
  50522. export class CustomProceduralTexture extends ProceduralTexture {
  50523. private _animate;
  50524. private _time;
  50525. private _config;
  50526. private _texturePath;
  50527. /**
  50528. * Instantiates a new Custom Procedural Texture.
  50529. * 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.
  50530. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  50531. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  50532. * @param name Define the name of the texture
  50533. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  50534. * @param size Define the size of the texture to create
  50535. * @param scene Define the scene the texture belongs to
  50536. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  50537. * @param generateMipMaps Define if the texture should creates mip maps or not
  50538. */
  50539. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50540. private _loadJson;
  50541. /**
  50542. * Is the texture ready to be used ? (rendered at least once)
  50543. * @returns true if ready, otherwise, false.
  50544. */
  50545. isReady(): boolean;
  50546. /**
  50547. * Render the texture to its associated render target.
  50548. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  50549. */
  50550. render(useCameraPostProcess?: boolean): void;
  50551. /**
  50552. * Update the list of dependant textures samplers in the shader.
  50553. */
  50554. updateTextures(): void;
  50555. /**
  50556. * Update the uniform values of the procedural texture in the shader.
  50557. */
  50558. updateShaderUniforms(): void;
  50559. /**
  50560. * Define if the texture animates or not.
  50561. */
  50562. animate: boolean;
  50563. }
  50564. }
  50565. declare module BABYLON {
  50566. /** @hidden */
  50567. export var noisePixelShader: {
  50568. name: string;
  50569. shader: string;
  50570. };
  50571. }
  50572. declare module BABYLON {
  50573. /**
  50574. * Class used to generate noise procedural textures
  50575. */
  50576. export class NoiseProceduralTexture extends ProceduralTexture {
  50577. private _time;
  50578. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  50579. brightness: number;
  50580. /** Defines the number of octaves to process */
  50581. octaves: number;
  50582. /** Defines the level of persistence (0.8 by default) */
  50583. persistence: number;
  50584. /** Gets or sets animation speed factor (default is 1) */
  50585. animationSpeedFactor: number;
  50586. /**
  50587. * Creates a new NoiseProceduralTexture
  50588. * @param name defines the name fo the texture
  50589. * @param size defines the size of the texture (default is 256)
  50590. * @param scene defines the hosting scene
  50591. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  50592. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  50593. */
  50594. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  50595. private _updateShaderUniforms;
  50596. protected _getDefines(): string;
  50597. /** Generate the current state of the procedural texture */
  50598. render(useCameraPostProcess?: boolean): void;
  50599. /**
  50600. * Serializes this noise procedural texture
  50601. * @returns a serialized noise procedural texture object
  50602. */
  50603. serialize(): any;
  50604. /**
  50605. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  50606. * @param parsedTexture defines parsed texture data
  50607. * @param scene defines the current scene
  50608. * @param rootUrl defines the root URL containing noise procedural texture information
  50609. * @returns a parsed NoiseProceduralTexture
  50610. */
  50611. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  50612. }
  50613. }
  50614. declare module BABYLON {
  50615. /**
  50616. * Raw cube texture where the raw buffers are passed in
  50617. */
  50618. export class RawCubeTexture extends CubeTexture {
  50619. /**
  50620. * Creates a cube texture where the raw buffers are passed in.
  50621. * @param scene defines the scene the texture is attached to
  50622. * @param data defines the array of data to use to create each face
  50623. * @param size defines the size of the textures
  50624. * @param format defines the format of the data
  50625. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  50626. * @param generateMipMaps defines if the engine should generate the mip levels
  50627. * @param invertY defines if data must be stored with Y axis inverted
  50628. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  50629. * @param compression defines the compression used (null by default)
  50630. */
  50631. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  50632. /**
  50633. * Updates the raw cube texture.
  50634. * @param data defines the data to store
  50635. * @param format defines the data format
  50636. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  50637. * @param invertY defines if data must be stored with Y axis inverted
  50638. * @param compression defines the compression used (null by default)
  50639. * @param level defines which level of the texture to update
  50640. */
  50641. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  50642. /**
  50643. * Updates a raw cube texture with RGBD encoded data.
  50644. * @param data defines the array of data [mipmap][face] to use to create each face
  50645. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  50646. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50647. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50648. * @returns a promsie that resolves when the operation is complete
  50649. */
  50650. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  50651. /**
  50652. * Clones the raw cube texture.
  50653. * @return a new cube texture
  50654. */
  50655. clone(): CubeTexture;
  50656. /** @hidden */ private static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  50657. }
  50658. }
  50659. declare module BABYLON {
  50660. /**
  50661. * Class used to store 3D textures containing user data
  50662. */
  50663. export class RawTexture3D extends Texture {
  50664. /** Gets or sets the texture format to use */
  50665. format: number;
  50666. private _engine;
  50667. /**
  50668. * Create a new RawTexture3D
  50669. * @param data defines the data of the texture
  50670. * @param width defines the width of the texture
  50671. * @param height defines the height of the texture
  50672. * @param depth defines the depth of the texture
  50673. * @param format defines the texture format to use
  50674. * @param scene defines the hosting scene
  50675. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  50676. * @param invertY defines if texture must be stored with Y axis inverted
  50677. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  50678. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  50679. */
  50680. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  50681. /** Gets or sets the texture format to use */
  50682. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  50683. /**
  50684. * Update the texture with new data
  50685. * @param data defines the data to store in the texture
  50686. */
  50687. update(data: ArrayBufferView): void;
  50688. }
  50689. }
  50690. declare module BABYLON {
  50691. /**
  50692. * Creates a refraction texture used by refraction channel of the standard material.
  50693. * It is like a mirror but to see through a material.
  50694. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50695. */
  50696. export class RefractionTexture extends RenderTargetTexture {
  50697. /**
  50698. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  50699. * 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.
  50700. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50701. */
  50702. refractionPlane: Plane;
  50703. /**
  50704. * Define how deep under the surface we should see.
  50705. */
  50706. depth: number;
  50707. /**
  50708. * Creates a refraction texture used by refraction channel of the standard material.
  50709. * It is like a mirror but to see through a material.
  50710. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  50711. * @param name Define the texture name
  50712. * @param size Define the size of the underlying texture
  50713. * @param scene Define the scene the refraction belongs to
  50714. * @param generateMipMaps Define if we need to generate mips level for the refraction
  50715. */
  50716. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  50717. /**
  50718. * Clone the refraction texture.
  50719. * @returns the cloned texture
  50720. */
  50721. clone(): RefractionTexture;
  50722. /**
  50723. * Serialize the texture to a JSON representation you could use in Parse later on
  50724. * @returns the serialized JSON representation
  50725. */
  50726. serialize(): any;
  50727. }
  50728. }
  50729. declare module BABYLON {
  50730. /**
  50731. * Defines the options related to the creation of an HtmlElementTexture
  50732. */
  50733. export interface IHtmlElementTextureOptions {
  50734. /**
  50735. * Defines wether mip maps should be created or not.
  50736. */
  50737. generateMipMaps?: boolean;
  50738. /**
  50739. * Defines the sampling mode of the texture.
  50740. */
  50741. samplingMode?: number;
  50742. /**
  50743. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  50744. */
  50745. engine: Nullable<Engine>;
  50746. /**
  50747. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  50748. */
  50749. scene: Nullable<Scene>;
  50750. }
  50751. /**
  50752. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  50753. * To be as efficient as possible depending on your constraints nothing aside the first upload
  50754. * is automatically managed.
  50755. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  50756. * in your application.
  50757. *
  50758. * As the update is not automatic, you need to call them manually.
  50759. */
  50760. export class HtmlElementTexture extends BaseTexture {
  50761. /**
  50762. * The texture URL.
  50763. */
  50764. element: HTMLVideoElement | HTMLCanvasElement;
  50765. private static readonly DefaultOptions;
  50766. private _textureMatrix;
  50767. private _engine;
  50768. private _isVideo;
  50769. private _generateMipMaps;
  50770. private _samplingMode;
  50771. /**
  50772. * Instantiates a HtmlElementTexture from the following parameters.
  50773. *
  50774. * @param name Defines the name of the texture
  50775. * @param element Defines the video or canvas the texture is filled with
  50776. * @param options Defines the other none mandatory texture creation options
  50777. */
  50778. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  50779. private _createInternalTexture;
  50780. /**
  50781. * Returns the texture matrix used in most of the material.
  50782. */
  50783. getTextureMatrix(): Matrix;
  50784. /**
  50785. * Updates the content of the texture.
  50786. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  50787. */
  50788. update(invertY?: Nullable<boolean>): void;
  50789. }
  50790. }
  50791. declare module BABYLON {
  50792. /**
  50793. * Enum used to define the target of a block
  50794. */
  50795. export enum NodeMaterialBlockTargets {
  50796. /** Vertex shader */
  50797. Vertex = 1,
  50798. /** Fragment shader */
  50799. Fragment = 2,
  50800. /** Neutral */
  50801. Neutral = 4,
  50802. /** Vertex and Fragment */
  50803. VertexAndFragment = 3
  50804. }
  50805. }
  50806. declare module BABYLON {
  50807. /**
  50808. * Defines the kind of connection point for node based material
  50809. */
  50810. export enum NodeMaterialBlockConnectionPointTypes {
  50811. /** Float */
  50812. Float = 1,
  50813. /** Int */
  50814. Int = 2,
  50815. /** Vector2 */
  50816. Vector2 = 4,
  50817. /** Vector3 */
  50818. Vector3 = 8,
  50819. /** Vector4 */
  50820. Vector4 = 16,
  50821. /** Color3 */
  50822. Color3 = 32,
  50823. /** Color4 */
  50824. Color4 = 64,
  50825. /** Matrix */
  50826. Matrix = 128,
  50827. /** Detect type based on connection */
  50828. AutoDetect = 1024,
  50829. /** Output type that will be defined by input type */
  50830. BasedOnInput = 2048
  50831. }
  50832. }
  50833. declare module BABYLON {
  50834. /**
  50835. * Root class for all node material optimizers
  50836. */
  50837. export class NodeMaterialOptimizer {
  50838. /**
  50839. * Function used to optimize a NodeMaterial graph
  50840. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  50841. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  50842. */
  50843. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  50844. }
  50845. }
  50846. declare module BABYLON {
  50847. /**
  50848. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  50849. */
  50850. export class TransformBlock extends NodeMaterialBlock {
  50851. /**
  50852. * Defines the value to use to complement W value to transform it to a Vector4
  50853. */
  50854. complementW: number;
  50855. /**
  50856. * Defines the value to use to complement z value to transform it to a Vector4
  50857. */
  50858. complementZ: number;
  50859. /**
  50860. * Creates a new TransformBlock
  50861. * @param name defines the block name
  50862. */
  50863. constructor(name: string);
  50864. /**
  50865. * Gets the current class name
  50866. * @returns the class name
  50867. */
  50868. getClassName(): string;
  50869. /**
  50870. * Gets the vector input
  50871. */
  50872. readonly vector: NodeMaterialConnectionPoint;
  50873. /**
  50874. * Gets the output component
  50875. */
  50876. readonly output: NodeMaterialConnectionPoint;
  50877. /**
  50878. * Gets the matrix transform input
  50879. */
  50880. readonly transform: NodeMaterialConnectionPoint;
  50881. protected _buildBlock(state: NodeMaterialBuildState): this;
  50882. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  50883. }
  50884. }
  50885. declare module BABYLON {
  50886. /**
  50887. * Block used to output the vertex position
  50888. */
  50889. export class VertexOutputBlock extends NodeMaterialBlock {
  50890. /**
  50891. * Creates a new VertexOutputBlock
  50892. * @param name defines the block name
  50893. */
  50894. constructor(name: string);
  50895. /**
  50896. * Gets the current class name
  50897. * @returns the class name
  50898. */
  50899. getClassName(): string;
  50900. /**
  50901. * Gets the vector input component
  50902. */
  50903. readonly vector: NodeMaterialConnectionPoint;
  50904. protected _buildBlock(state: NodeMaterialBuildState): this;
  50905. }
  50906. }
  50907. declare module BABYLON {
  50908. /**
  50909. * Block used to output the final color
  50910. */
  50911. export class FragmentOutputBlock extends NodeMaterialBlock {
  50912. /**
  50913. * Create a new FragmentOutputBlock
  50914. * @param name defines the block name
  50915. */
  50916. constructor(name: string);
  50917. /**
  50918. * Gets the current class name
  50919. * @returns the class name
  50920. */
  50921. getClassName(): string;
  50922. /**
  50923. * Gets the rgba input component
  50924. */
  50925. readonly rgba: NodeMaterialConnectionPoint;
  50926. /**
  50927. * Gets the rgb input component
  50928. */
  50929. readonly rgb: NodeMaterialConnectionPoint;
  50930. /**
  50931. * Gets the a input component
  50932. */
  50933. readonly a: NodeMaterialConnectionPoint;
  50934. protected _buildBlock(state: NodeMaterialBuildState): this;
  50935. }
  50936. }
  50937. declare module BABYLON {
  50938. /**
  50939. * Interface used to configure the node material editor
  50940. */
  50941. export interface INodeMaterialEditorOptions {
  50942. /** Define the URl to load node editor script */
  50943. editorURL?: string;
  50944. }
  50945. /** @hidden */
  50946. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  50947. /** BONES */
  50948. NUM_BONE_INFLUENCERS: number;
  50949. BonesPerMesh: number;
  50950. BONETEXTURE: boolean;
  50951. /** MORPH TARGETS */
  50952. MORPHTARGETS: boolean;
  50953. MORPHTARGETS_NORMAL: boolean;
  50954. MORPHTARGETS_TANGENT: boolean;
  50955. MORPHTARGETS_UV: boolean;
  50956. NUM_MORPH_INFLUENCERS: number;
  50957. /** IMAGE PROCESSING */
  50958. IMAGEPROCESSING: boolean;
  50959. VIGNETTE: boolean;
  50960. VIGNETTEBLENDMODEMULTIPLY: boolean;
  50961. VIGNETTEBLENDMODEOPAQUE: boolean;
  50962. TONEMAPPING: boolean;
  50963. TONEMAPPING_ACES: boolean;
  50964. CONTRAST: boolean;
  50965. EXPOSURE: boolean;
  50966. COLORCURVES: boolean;
  50967. COLORGRADING: boolean;
  50968. COLORGRADING3D: boolean;
  50969. SAMPLER3DGREENDEPTH: boolean;
  50970. SAMPLER3DBGRMAP: boolean;
  50971. IMAGEPROCESSINGPOSTPROCESS: boolean;
  50972. constructor();
  50973. setValue(name: string, value: boolean): void;
  50974. }
  50975. /**
  50976. * Class used to configure NodeMaterial
  50977. */
  50978. export interface INodeMaterialOptions {
  50979. /**
  50980. * Defines if blocks should emit comments
  50981. */
  50982. emitComments: boolean;
  50983. }
  50984. /**
  50985. * Class used to create a node based material built by assembling shader blocks
  50986. */
  50987. export class NodeMaterial extends PushMaterial {
  50988. private static _BuildIdGenerator;
  50989. private _options;
  50990. private _vertexCompilationState;
  50991. private _fragmentCompilationState;
  50992. private _sharedData;
  50993. private _buildId;
  50994. private _buildWasSuccessful;
  50995. private _cachedWorldViewMatrix;
  50996. private _cachedWorldViewProjectionMatrix;
  50997. private _optimizers;
  50998. private _animationFrame;
  50999. /** Define the URl to load node editor script */
  51000. static EditorURL: string;
  51001. private BJSNODEMATERIALEDITOR;
  51002. /** Get the inspector from bundle or global */
  51003. private _getGlobalNodeMaterialEditor;
  51004. /**
  51005. * 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)
  51006. */
  51007. ignoreAlpha: boolean;
  51008. /**
  51009. * Defines the maximum number of lights that can be used in the material
  51010. */
  51011. maxSimultaneousLights: number;
  51012. /**
  51013. * Observable raised when the material is built
  51014. */
  51015. onBuildObservable: Observable<NodeMaterial>;
  51016. /**
  51017. * Gets or sets the root nodes of the material vertex shader
  51018. */ private _vertexOutputNodes: NodeMaterialBlock[];
  51019. /**
  51020. * Gets or sets the root nodes of the material fragment (pixel) shader
  51021. */ private _fragmentOutputNodes: NodeMaterialBlock[];
  51022. /** Gets or sets options to control the node material overall behavior */
  51023. options: INodeMaterialOptions;
  51024. /**
  51025. * Default configuration related to image processing available in the standard Material.
  51026. */
  51027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51028. /**
  51029. * Gets the image processing configuration used either in this material.
  51030. */
  51031. /**
  51032. * Sets the Default image processing configuration used either in the this material.
  51033. *
  51034. * If sets to null, the scene one is in use.
  51035. */
  51036. imageProcessingConfiguration: ImageProcessingConfiguration;
  51037. /**
  51038. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  51039. */
  51040. attachedBlocks: NodeMaterialBlock[];
  51041. /**
  51042. * Create a new node based material
  51043. * @param name defines the material name
  51044. * @param scene defines the hosting scene
  51045. * @param options defines creation option
  51046. */
  51047. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  51048. /**
  51049. * Gets the current class name of the material e.g. "NodeMaterial"
  51050. * @returns the class name
  51051. */
  51052. getClassName(): string;
  51053. /**
  51054. * Keep track of the image processing observer to allow dispose and replace.
  51055. */
  51056. private _imageProcessingObserver;
  51057. /**
  51058. * Attaches a new image processing configuration to the Standard Material.
  51059. * @param configuration
  51060. */
  51061. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51062. /**
  51063. * Adds a new optimizer to the list of optimizers
  51064. * @param optimizer defines the optimizers to add
  51065. * @returns the current material
  51066. */
  51067. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51068. /**
  51069. * Remove an optimizer from the list of optimizers
  51070. * @param optimizer defines the optimizers to remove
  51071. * @returns the current material
  51072. */
  51073. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  51074. /**
  51075. * Add a new block to the list of output nodes
  51076. * @param node defines the node to add
  51077. * @returns the current material
  51078. */
  51079. addOutputNode(node: NodeMaterialBlock): this;
  51080. /**
  51081. * Remove a block from the list of root nodes
  51082. * @param node defines the node to remove
  51083. * @returns the current material
  51084. */
  51085. removeOutputNode(node: NodeMaterialBlock): this;
  51086. private _addVertexOutputNode;
  51087. private _removeVertexOutputNode;
  51088. private _addFragmentOutputNode;
  51089. private _removeFragmentOutputNode;
  51090. /**
  51091. * Specifies if the material will require alpha blending
  51092. * @returns a boolean specifying if alpha blending is needed
  51093. */
  51094. needAlphaBlending(): boolean;
  51095. /**
  51096. * Specifies if this material should be rendered in alpha test mode
  51097. * @returns a boolean specifying if an alpha test is needed.
  51098. */
  51099. needAlphaTesting(): boolean;
  51100. private _initializeBlock;
  51101. private _resetDualBlocks;
  51102. /**
  51103. * Build the material and generates the inner effect
  51104. * @param verbose defines if the build should log activity
  51105. */
  51106. build(verbose?: boolean): void;
  51107. /**
  51108. * Runs an otpimization phase to try to improve the shader code
  51109. */
  51110. optimize(): void;
  51111. private _prepareDefinesForAttributes;
  51112. /**
  51113. * Get if the submesh is ready to be used and all its information available.
  51114. * Child classes can use it to update shaders
  51115. * @param mesh defines the mesh to check
  51116. * @param subMesh defines which submesh to check
  51117. * @param useInstances specifies that instances should be used
  51118. * @returns a boolean indicating that the submesh is ready or not
  51119. */
  51120. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51121. /**
  51122. * Get a string representing the shaders built by the current node graph
  51123. */
  51124. readonly compiledShaders: string;
  51125. /**
  51126. * Binds the world matrix to the material
  51127. * @param world defines the world transformation matrix
  51128. */
  51129. bindOnlyWorldMatrix(world: Matrix): void;
  51130. /**
  51131. * Binds the submesh to this material by preparing the effect and shader to draw
  51132. * @param world defines the world transformation matrix
  51133. * @param mesh defines the mesh containing the submesh
  51134. * @param subMesh defines the submesh to bind the material to
  51135. */
  51136. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51137. /**
  51138. * Gets the active textures from the material
  51139. * @returns an array of textures
  51140. */
  51141. getActiveTextures(): BaseTexture[];
  51142. /**
  51143. * Specifies if the material uses a texture
  51144. * @param texture defines the texture to check against the material
  51145. * @returns a boolean specifying if the material uses the texture
  51146. */
  51147. hasTexture(texture: BaseTexture): boolean;
  51148. /**
  51149. * Disposes the material
  51150. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  51151. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  51152. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  51153. */
  51154. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  51155. /** Creates the node editor window. */
  51156. private _createNodeEditor;
  51157. /**
  51158. * Launch the node material editor
  51159. * @param config Define the configuration of the editor
  51160. * @return a promise fulfilled when the node editor is visible
  51161. */
  51162. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  51163. /**
  51164. * Clear the current material
  51165. */
  51166. clear(): void;
  51167. /**
  51168. * Clear the current material and set it to a default state
  51169. */
  51170. setToDefault(): void;
  51171. private _gatherBlocks;
  51172. /**
  51173. * Serializes this material in a JSON representation
  51174. * @returns the serialized material object
  51175. */
  51176. serialize(): any;
  51177. /**
  51178. * Clear the current graph and load a new one from a serialization object
  51179. * @param source defines the JSON representation of the material
  51180. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51181. */
  51182. loadFromSerialization(source: any, rootUrl?: string): void;
  51183. /**
  51184. * Creates a node material from parsed material data
  51185. * @param source defines the JSON representation of the material
  51186. * @param scene defines the hosting scene
  51187. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51188. * @returns a new node material
  51189. */
  51190. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  51191. }
  51192. }
  51193. declare module BABYLON {
  51194. /**
  51195. * Block used to read a texture from a sampler
  51196. */
  51197. export class TextureBlock extends NodeMaterialBlock {
  51198. private _defineName;
  51199. private _samplerName;
  51200. private _transformedUVName;
  51201. private _textureTransformName;
  51202. private _textureInfoName;
  51203. private _mainUVName;
  51204. private _mainUVDefineName;
  51205. /**
  51206. * Gets or sets the texture associated with the node
  51207. */
  51208. texture: Nullable<BaseTexture>;
  51209. /**
  51210. * Create a new TextureBlock
  51211. * @param name defines the block name
  51212. */
  51213. constructor(name: string);
  51214. /**
  51215. * Gets the current class name
  51216. * @returns the class name
  51217. */
  51218. getClassName(): string;
  51219. /**
  51220. * Gets the uv input component
  51221. */
  51222. readonly uv: NodeMaterialConnectionPoint;
  51223. /**
  51224. * Gets the rgba output component
  51225. */
  51226. readonly rgba: NodeMaterialConnectionPoint;
  51227. /**
  51228. * Gets the rgb output component
  51229. */
  51230. readonly rgb: NodeMaterialConnectionPoint;
  51231. /**
  51232. * Gets the r output component
  51233. */
  51234. readonly r: NodeMaterialConnectionPoint;
  51235. /**
  51236. * Gets the g output component
  51237. */
  51238. readonly g: NodeMaterialConnectionPoint;
  51239. /**
  51240. * Gets the b output component
  51241. */
  51242. readonly b: NodeMaterialConnectionPoint;
  51243. /**
  51244. * Gets the a output component
  51245. */
  51246. readonly a: NodeMaterialConnectionPoint;
  51247. autoConfigure(): void;
  51248. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51249. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51250. isReady(): boolean;
  51251. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51252. private _injectVertexCode;
  51253. private _writeOutput;
  51254. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51255. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51256. }
  51257. }
  51258. declare module BABYLON {
  51259. /**
  51260. * Enum used to define well known values e.g. values automatically provided by the system
  51261. */
  51262. export enum NodeMaterialWellKnownValues {
  51263. /** World */
  51264. World = 1,
  51265. /** View */
  51266. View = 2,
  51267. /** Projection */
  51268. Projection = 3,
  51269. /** ViewProjection */
  51270. ViewProjection = 4,
  51271. /** WorldView */
  51272. WorldView = 5,
  51273. /** WorldViewProjection */
  51274. WorldViewProjection = 6,
  51275. /** CameraPosition */
  51276. CameraPosition = 7,
  51277. /** Fog Color */
  51278. FogColor = 8
  51279. }
  51280. }
  51281. declare module BABYLON {
  51282. /**
  51283. * Block used to read a reflection texture from a sampler
  51284. */
  51285. export class ReflectionTextureBlock extends NodeMaterialBlock {
  51286. private _define3DName;
  51287. private _defineCubicName;
  51288. private _defineExplicitName;
  51289. private _defineProjectionName;
  51290. private _defineLocalCubicName;
  51291. private _defineSphericalName;
  51292. private _definePlanarName;
  51293. private _defineEquirectangularName;
  51294. private _defineMirroredEquirectangularFixedName;
  51295. private _defineEquirectangularFixedName;
  51296. private _defineSkyboxName;
  51297. private _cubeSamplerName;
  51298. private _2DSamplerName;
  51299. private _positionUVWName;
  51300. private _directionWName;
  51301. private _reflectionCoordsName;
  51302. private _reflection2DCoordsName;
  51303. private _reflectionColorName;
  51304. private _reflectionMatrixName;
  51305. /**
  51306. * Gets or sets the texture associated with the node
  51307. */
  51308. texture: Nullable<BaseTexture>;
  51309. /**
  51310. * Create a new TextureBlock
  51311. * @param name defines the block name
  51312. */
  51313. constructor(name: string);
  51314. /**
  51315. * Gets the current class name
  51316. * @returns the class name
  51317. */
  51318. getClassName(): string;
  51319. /**
  51320. * Gets the world position input component
  51321. */
  51322. readonly position: NodeMaterialConnectionPoint;
  51323. /**
  51324. * Gets the world position input component
  51325. */
  51326. readonly worldPosition: NodeMaterialConnectionPoint;
  51327. /**
  51328. * Gets the world normal input component
  51329. */
  51330. readonly worldNormal: NodeMaterialConnectionPoint;
  51331. /**
  51332. * Gets the world input component
  51333. */
  51334. readonly world: NodeMaterialConnectionPoint;
  51335. /**
  51336. * Gets the camera (or eye) position component
  51337. */
  51338. readonly cameraPosition: NodeMaterialConnectionPoint;
  51339. /**
  51340. * Gets the view input component
  51341. */
  51342. readonly view: NodeMaterialConnectionPoint;
  51343. /**
  51344. * Gets the rgb output component
  51345. */
  51346. readonly rgb: NodeMaterialConnectionPoint;
  51347. /**
  51348. * Gets the r output component
  51349. */
  51350. readonly r: NodeMaterialConnectionPoint;
  51351. /**
  51352. * Gets the g output component
  51353. */
  51354. readonly g: NodeMaterialConnectionPoint;
  51355. /**
  51356. * Gets the b output component
  51357. */
  51358. readonly b: NodeMaterialConnectionPoint;
  51359. autoConfigure(): void;
  51360. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51361. isReady(): boolean;
  51362. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51363. private _injectVertexCode;
  51364. private _writeOutput;
  51365. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  51366. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51367. }
  51368. }
  51369. declare module BABYLON {
  51370. /**
  51371. * Class used to store shared data between 2 NodeMaterialBuildState
  51372. */
  51373. export class NodeMaterialBuildStateSharedData {
  51374. /**
  51375. * Gets the list of emitted varyings
  51376. */
  51377. varyings: string[];
  51378. /**
  51379. * Gets the varying declaration string
  51380. */
  51381. varyingDeclaration: string;
  51382. /**
  51383. * Input blocks
  51384. */
  51385. inputBlocks: InputBlock[];
  51386. /**
  51387. * Input blocks
  51388. */
  51389. textureBlocks: (TextureBlock | ReflectionTextureBlock)[];
  51390. /**
  51391. * Bindable blocks (Blocks that need to set data to the effect)
  51392. */
  51393. bindableBlocks: NodeMaterialBlock[];
  51394. /**
  51395. * List of blocks that can provide a compilation fallback
  51396. */
  51397. blocksWithFallbacks: NodeMaterialBlock[];
  51398. /**
  51399. * List of blocks that can provide a define update
  51400. */
  51401. blocksWithDefines: NodeMaterialBlock[];
  51402. /**
  51403. * List of blocks that can provide a repeatable content
  51404. */
  51405. repeatableContentBlocks: NodeMaterialBlock[];
  51406. /**
  51407. * List of blocks that can provide a dynamic list of uniforms
  51408. */
  51409. dynamicUniformBlocks: NodeMaterialBlock[];
  51410. /**
  51411. * List of blocks that can block the isReady function for the material
  51412. */
  51413. blockingBlocks: NodeMaterialBlock[];
  51414. /**
  51415. * Gets the list of animated inputs
  51416. */
  51417. animatedInputs: InputBlock[];
  51418. /**
  51419. * Build Id used to avoid multiple recompilations
  51420. */
  51421. buildId: number;
  51422. /** List of emitted variables */
  51423. variableNames: {
  51424. [key: string]: number;
  51425. };
  51426. /** List of emitted defines */
  51427. defineNames: {
  51428. [key: string]: number;
  51429. };
  51430. /** Should emit comments? */
  51431. emitComments: boolean;
  51432. /** Emit build activity */
  51433. verbose: boolean;
  51434. /**
  51435. * Gets the compilation hints emitted at compilation time
  51436. */
  51437. hints: {
  51438. needWorldViewMatrix: boolean;
  51439. needWorldViewProjectionMatrix: boolean;
  51440. needAlphaBlending: boolean;
  51441. needAlphaTesting: boolean;
  51442. };
  51443. /**
  51444. * List of compilation checks
  51445. */
  51446. checks: {
  51447. emitVertex: boolean;
  51448. emitFragment: boolean;
  51449. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  51450. };
  51451. /** Creates a new shared data */
  51452. constructor();
  51453. /**
  51454. * Emits console errors and exceptions if there is a failing check
  51455. */
  51456. emitErrors(): void;
  51457. }
  51458. }
  51459. declare module BABYLON {
  51460. /**
  51461. * Class used to store node based material build state
  51462. */
  51463. export class NodeMaterialBuildState {
  51464. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  51465. supportUniformBuffers: boolean;
  51466. /**
  51467. * Gets the list of emitted attributes
  51468. */
  51469. attributes: string[];
  51470. /**
  51471. * Gets the list of emitted uniforms
  51472. */
  51473. uniforms: string[];
  51474. /**
  51475. * Gets the list of emitted uniform buffers
  51476. */
  51477. uniformBuffers: string[];
  51478. /**
  51479. * Gets the list of emitted samplers
  51480. */
  51481. samplers: string[];
  51482. /**
  51483. * Gets the list of emitted functions
  51484. */
  51485. functions: {
  51486. [key: string]: string;
  51487. };
  51488. /**
  51489. * Gets the target of the compilation state
  51490. */
  51491. target: NodeMaterialBlockTargets;
  51492. /**
  51493. * Gets the list of emitted counters
  51494. */
  51495. counters: {
  51496. [key: string]: number;
  51497. };
  51498. /**
  51499. * Shared data between multiple NodeMaterialBuildState instances
  51500. */
  51501. sharedData: NodeMaterialBuildStateSharedData;
  51502. /** @hidden */ private _vertexState: NodeMaterialBuildState;
  51503. /** @hidden */ private _attributeDeclaration: string;
  51504. /** @hidden */ private _uniformDeclaration: string;
  51505. /** @hidden */ private _samplerDeclaration: string;
  51506. /** @hidden */ private _varyingTransfer: string;
  51507. private _repeatableContentAnchorIndex;
  51508. /** @hidden */ private _builtCompilationString: string;
  51509. /**
  51510. * Gets the emitted compilation strings
  51511. */
  51512. compilationString: string;
  51513. /**
  51514. * Finalize the compilation strings
  51515. * @param state defines the current compilation state
  51516. */
  51517. finalize(state: NodeMaterialBuildState): void;
  51518. /** @hidden */ protected readonly _repeatableContentAnchor: string;
  51519. /** @hidden */ private _getFreeVariableName(prefix: string): string;
  51520. /** @hidden */ private _getFreeDefineName(prefix: string): string;
  51521. /** @hidden */ private _excludeVariableName(name: string): void;
  51522. /** @hidden */ private _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  51523. /** @hidden */ private _emitFunction(name: string, code: string, comments: string): void;
  51524. /** @hidden */ private _emitCodeFromInclude(includeName: string, comments: string, options?: {
  51525. replaceStrings?: {
  51526. search: RegExp;
  51527. replace: string;
  51528. }[];
  51529. repeatKey?: string;
  51530. }): string;
  51531. /** @hidden */ private _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  51532. repeatKey?: string;
  51533. removeAttributes?: boolean;
  51534. removeUniforms?: boolean;
  51535. removeVaryings?: boolean;
  51536. removeIfDef?: boolean;
  51537. replaceStrings?: {
  51538. search: RegExp;
  51539. replace: string;
  51540. }[];
  51541. }, storeKey?: string): void;
  51542. /** @hidden */ private _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  51543. /** @hidden */ private _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  51544. }
  51545. }
  51546. declare module BABYLON {
  51547. /**
  51548. * Defines a block that can be used inside a node based material
  51549. */
  51550. export class NodeMaterialBlock {
  51551. private _buildId;
  51552. private _buildTarget;
  51553. private _target;
  51554. private _isFinalMerger;
  51555. private _isInput;
  51556. /** @hidden */ private _inputs: NodeMaterialConnectionPoint[];
  51557. /** @hidden */ private _outputs: NodeMaterialConnectionPoint[];
  51558. /**
  51559. * Gets or sets the name of the block
  51560. */
  51561. name: string;
  51562. /**
  51563. * Gets or sets the unique id of the node
  51564. */
  51565. uniqueId: number;
  51566. /**
  51567. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  51568. */
  51569. readonly isFinalMerger: boolean;
  51570. /**
  51571. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  51572. */
  51573. readonly isInput: boolean;
  51574. /**
  51575. * Gets or sets the build Id
  51576. */
  51577. buildId: number;
  51578. /**
  51579. * Gets or sets the target of the block
  51580. */
  51581. target: NodeMaterialBlockTargets;
  51582. /**
  51583. * Gets the list of input points
  51584. */
  51585. readonly inputs: NodeMaterialConnectionPoint[];
  51586. /** Gets the list of output points */
  51587. readonly outputs: NodeMaterialConnectionPoint[];
  51588. /**
  51589. * Find an input by its name
  51590. * @param name defines the name of the input to look for
  51591. * @returns the input or null if not found
  51592. */
  51593. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51594. /**
  51595. * Find an output by its name
  51596. * @param name defines the name of the outputto look for
  51597. * @returns the output or null if not found
  51598. */
  51599. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  51600. /**
  51601. * Creates a new NodeMaterialBlock
  51602. * @param name defines the block name
  51603. * @param target defines the target of that block (Vertex by default)
  51604. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  51605. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  51606. */
  51607. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  51608. /**
  51609. * Initialize the block and prepare the context for build
  51610. * @param state defines the state that will be used for the build
  51611. */
  51612. initialize(state: NodeMaterialBuildState): void;
  51613. /**
  51614. * Bind data to effect. Will only be called for blocks with isBindable === true
  51615. * @param effect defines the effect to bind data to
  51616. * @param nodeMaterial defines the hosting NodeMaterial
  51617. * @param mesh defines the mesh that will be rendered
  51618. */
  51619. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  51620. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  51621. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  51622. protected _writeFloat(value: number): string;
  51623. /**
  51624. * Gets the current class name e.g. "NodeMaterialBlock"
  51625. * @returns the class name
  51626. */
  51627. getClassName(): string;
  51628. /**
  51629. * Register a new input. Must be called inside a block constructor
  51630. * @param name defines the connection point name
  51631. * @param type defines the connection point type
  51632. * @param isOptional defines a boolean indicating that this input can be omitted
  51633. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51634. * @returns the current block
  51635. */
  51636. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  51637. /**
  51638. * Register a new output. Must be called inside a block constructor
  51639. * @param name defines the connection point name
  51640. * @param type defines the connection point type
  51641. * @param target defines the target to use to limit the connection point (will be VetexAndFragment by default)
  51642. * @returns the current block
  51643. */
  51644. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  51645. /**
  51646. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  51647. * @param forOutput defines an optional connection point to check compatibility with
  51648. * @returns the first available input or null
  51649. */
  51650. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  51651. /**
  51652. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  51653. * @param forBlock defines an optional block to check compatibility with
  51654. * @returns the first available input or null
  51655. */
  51656. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  51657. /**
  51658. * Gets the sibling of the given output
  51659. * @param current defines the current output
  51660. * @returns the next output in the list or null
  51661. */
  51662. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  51663. /**
  51664. * Connect current block with another block
  51665. * @param other defines the block to connect with
  51666. * @param options define the various options to help pick the right connections
  51667. * @returns the current block
  51668. */
  51669. connectTo(other: NodeMaterialBlock, options?: {
  51670. input?: string;
  51671. output?: string;
  51672. outputSwizzle?: string;
  51673. }): this | undefined;
  51674. protected _buildBlock(state: NodeMaterialBuildState): void;
  51675. /**
  51676. * Add uniforms, samplers and uniform buffers at compilation time
  51677. * @param state defines the state to update
  51678. * @param nodeMaterial defines the node material requesting the update
  51679. * @param defines defines the material defines to update
  51680. */
  51681. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  51682. /**
  51683. * Add potential fallbacks if shader compilation fails
  51684. * @param mesh defines the mesh to be rendered
  51685. * @param fallbacks defines the current prioritized list of fallbacks
  51686. */
  51687. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  51688. /**
  51689. * Update defines for shader compilation
  51690. * @param mesh defines the mesh to be rendered
  51691. * @param nodeMaterial defines the node material requesting the update
  51692. * @param defines defines the material defines to update
  51693. * @param useInstances specifies that instances should be used
  51694. */
  51695. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51696. /**
  51697. * Initialize defines for shader compilation
  51698. * @param mesh defines the mesh to be rendered
  51699. * @param nodeMaterial defines the node material requesting the update
  51700. * @param defines defines the material defines to be prepared
  51701. * @param useInstances specifies that instances should be used
  51702. */
  51703. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  51704. /**
  51705. * Lets the block try to connect some inputs automatically
  51706. */
  51707. autoConfigure(): void;
  51708. /**
  51709. * Function called when a block is declared as repeatable content generator
  51710. * @param vertexShaderState defines the current compilation state for the vertex shader
  51711. * @param fragmentShaderState defines the current compilation state for the fragment shader
  51712. * @param mesh defines the mesh to be rendered
  51713. * @param defines defines the material defines to update
  51714. */
  51715. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  51716. /**
  51717. * Checks if the block is ready
  51718. * @param mesh defines the mesh to be rendered
  51719. * @param nodeMaterial defines the node material requesting the update
  51720. * @param defines defines the material defines to update
  51721. * @param useInstances specifies that instances should be used
  51722. * @returns true if the block is ready
  51723. */
  51724. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  51725. private _processBuild;
  51726. /**
  51727. * Compile the current node and generate the shader code
  51728. * @param state defines the current compilation state (uniforms, samplers, current string)
  51729. * @param contextSwitched indicates that the previous block was built for a different context (vertex vs. fragment)
  51730. * @returns true if already built
  51731. */
  51732. build(state: NodeMaterialBuildState, contextSwitched?: boolean): boolean;
  51733. /**
  51734. * Clone the current block to a new identical block
  51735. * @param scene defines the hosting scene
  51736. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  51737. * @returns a copy of the current block
  51738. */
  51739. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  51740. /**
  51741. * Serializes this block in a JSON representation
  51742. * @returns the serialized block object
  51743. */
  51744. serialize(): any;
  51745. /** @hidden */ private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51746. }
  51747. }
  51748. declare module BABYLON {
  51749. /**
  51750. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  51751. */
  51752. export enum NodeMaterialBlockConnectionPointMode {
  51753. /** Value is an uniform */
  51754. Uniform = 0,
  51755. /** Value is a mesh attribute */
  51756. Attribute = 1,
  51757. /** Value is a varying between vertex and fragment shaders */
  51758. Varying = 2,
  51759. /** Mode is undefined */
  51760. Undefined = 3
  51761. }
  51762. }
  51763. declare module BABYLON {
  51764. /**
  51765. * Enum defining the type of animations supported by InputBlock
  51766. */
  51767. export enum AnimatedInputBlockTypes {
  51768. /** No animation */
  51769. None = 0,
  51770. /** Time based animation. Will only work for floats */
  51771. Time = 1
  51772. }
  51773. }
  51774. declare module BABYLON {
  51775. /**
  51776. * Block used to expose an input value
  51777. */
  51778. export class InputBlock extends NodeMaterialBlock {
  51779. private _mode;
  51780. private _associatedVariableName;
  51781. private _storedValue;
  51782. private _valueCallback;
  51783. private _type;
  51784. private _animationType;
  51785. /** @hidden */ private _wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51786. /**
  51787. * Gets or sets the connection point type (default is float)
  51788. */
  51789. readonly type: NodeMaterialBlockConnectionPointTypes;
  51790. /**
  51791. * Creates a new InputBlock
  51792. * @param name defines the block name
  51793. * @param target defines the target of that block (Vertex by default)
  51794. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  51795. */
  51796. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  51797. /**
  51798. * Gets the output component
  51799. */
  51800. readonly output: NodeMaterialConnectionPoint;
  51801. /**
  51802. * Set the source of this connection point to a vertex attribute
  51803. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  51804. * @returns the current connection point
  51805. */
  51806. setAsAttribute(attributeName?: string): InputBlock;
  51807. /**
  51808. * Set the source of this connection point to a well known value
  51809. * @param value define the well known value to use (world, view, etc...) or null to switch to manual value
  51810. * @returns the current connection point
  51811. */
  51812. setAsWellKnownValue(value: Nullable<NodeMaterialWellKnownValues>): InputBlock;
  51813. /**
  51814. * Gets or sets the value of that point.
  51815. * Please note that this value will be ignored if valueCallback is defined
  51816. */
  51817. value: any;
  51818. /**
  51819. * Gets or sets a callback used to get the value of that point.
  51820. * Please note that setting this value will force the connection point to ignore the value property
  51821. */
  51822. valueCallback: () => any;
  51823. /**
  51824. * Gets or sets the associated variable name in the shader
  51825. */
  51826. associatedVariableName: string;
  51827. /** Gets or sets the type of animation applied to the input */
  51828. animationType: AnimatedInputBlockTypes;
  51829. /**
  51830. * Gets a boolean indicating that this connection point not defined yet
  51831. */
  51832. readonly isUndefined: boolean;
  51833. /**
  51834. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  51835. * In this case the connection point name must be the name of the uniform to use.
  51836. * Can only be set on inputs
  51837. */
  51838. isUniform: boolean;
  51839. /**
  51840. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  51841. * In this case the connection point name must be the name of the attribute to use
  51842. * Can only be set on inputs
  51843. */
  51844. isAttribute: boolean;
  51845. /**
  51846. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  51847. * Can only be set on exit points
  51848. */
  51849. isVarying: boolean;
  51850. /**
  51851. * Gets a boolean indicating that the current connection point is a well known value
  51852. */
  51853. readonly isWellKnownValue: boolean;
  51854. /**
  51855. * Gets or sets the current well known value or null if not defined as well know value
  51856. */
  51857. wellKnownValue: Nullable<NodeMaterialWellKnownValues>;
  51858. /**
  51859. * Gets the current class name
  51860. * @returns the class name
  51861. */
  51862. getClassName(): string;
  51863. /**
  51864. * Animate the input if animationType !== None
  51865. * @param scene defines the rendering scene
  51866. */
  51867. animate(scene: Scene): void;
  51868. private _emitDefine;
  51869. /**
  51870. * Set the input block to its default value (based on its type)
  51871. */
  51872. setDefaultValue(): void;
  51873. private _emit;
  51874. /** @hidden */ private _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  51875. /** @hidden */ private _transmit(effect: Effect, scene: Scene): void;
  51876. protected _buildBlock(state: NodeMaterialBuildState): void;
  51877. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  51878. }
  51879. }
  51880. declare module BABYLON {
  51881. /**
  51882. * Defines a connection point for a block
  51883. */
  51884. export class NodeMaterialConnectionPoint {
  51885. /** @hidden */ private _ownerBlock: NodeMaterialBlock;
  51886. /** @hidden */ private _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51887. private _endpoints;
  51888. private _associatedVariableName;
  51889. /** @hidden */ private _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  51890. private _type;
  51891. /** @hidden */ private _enforceAssociatedVariableName: boolean;
  51892. /**
  51893. * Gets or sets the additional types supported byt this connection point
  51894. */
  51895. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  51896. /**
  51897. * Gets or sets the associated variable name in the shader
  51898. */
  51899. associatedVariableName: string;
  51900. /**
  51901. * Gets or sets the connection point type (default is float)
  51902. */
  51903. type: NodeMaterialBlockConnectionPointTypes;
  51904. /**
  51905. * Gets or sets the connection point name
  51906. */
  51907. name: string;
  51908. /**
  51909. * Gets or sets a boolean indicating that this connection point can be omitted
  51910. */
  51911. isOptional: boolean;
  51912. /**
  51913. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  51914. */
  51915. define: string;
  51916. /** Gets or sets the target of that connection point */
  51917. target: NodeMaterialBlockTargets;
  51918. /**
  51919. * Gets a boolean indicating that the current point is connected
  51920. */
  51921. readonly isConnected: boolean;
  51922. /**
  51923. * Gets a boolean indicating that the current point is connected to an input block
  51924. */
  51925. readonly isConnectedToInput: boolean;
  51926. /**
  51927. * Gets a the connected input block (if any)
  51928. */
  51929. readonly connectInputBlock: Nullable<InputBlock>;
  51930. /** Get the other side of the connection (if any) */
  51931. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  51932. /** Get the block that owns this connection point */
  51933. readonly ownerBlock: NodeMaterialBlock;
  51934. /** Get the block connected on the other side of this connection (if any) */
  51935. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  51936. /** Get the block connected on the endpoints of this connection (if any) */
  51937. readonly connectedBlocks: Array<NodeMaterialBlock>;
  51938. /** Gets the list of connected endpoints */
  51939. readonly endpoints: NodeMaterialConnectionPoint[];
  51940. /**
  51941. * Creates a new connection point
  51942. * @param name defines the connection point name
  51943. * @param ownerBlock defines the block hosting this connection point
  51944. */
  51945. constructor(name: string, ownerBlock: NodeMaterialBlock);
  51946. /**
  51947. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  51948. * @returns the class name
  51949. */
  51950. getClassName(): string;
  51951. /**
  51952. * Gets an boolean indicating if the current point can be connected to another point
  51953. * @param connectionPoint defines the other connection point
  51954. * @returns true if the connection is possible
  51955. */
  51956. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  51957. /**
  51958. * Connect this point to another connection point
  51959. * @param connectionPoint defines the other connection point
  51960. * @returns the current connection point
  51961. */
  51962. connectTo(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51963. /**
  51964. * Disconnect this point from one of his endpoint
  51965. * @param endpoint defines the other connection point
  51966. * @returns the current connection point
  51967. */
  51968. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  51969. /**
  51970. * Serializes this point in a JSON representation
  51971. * @returns the serialized point object
  51972. */
  51973. serialize(): any;
  51974. }
  51975. }
  51976. declare module BABYLON {
  51977. /**
  51978. * Block used to add support for vertex skinning (bones)
  51979. */
  51980. export class BonesBlock extends NodeMaterialBlock {
  51981. /**
  51982. * Creates a new BonesBlock
  51983. * @param name defines the block name
  51984. */
  51985. constructor(name: string);
  51986. /**
  51987. * Initialize the block and prepare the context for build
  51988. * @param state defines the state that will be used for the build
  51989. */
  51990. initialize(state: NodeMaterialBuildState): void;
  51991. /**
  51992. * Gets the current class name
  51993. * @returns the class name
  51994. */
  51995. getClassName(): string;
  51996. /**
  51997. * Gets the matrix indices input component
  51998. */
  51999. readonly matricesIndices: NodeMaterialConnectionPoint;
  52000. /**
  52001. * Gets the matrix weights input component
  52002. */
  52003. readonly matricesWeights: NodeMaterialConnectionPoint;
  52004. /**
  52005. * Gets the extra matrix indices input component
  52006. */
  52007. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  52008. /**
  52009. * Gets the extra matrix weights input component
  52010. */
  52011. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  52012. /**
  52013. * Gets the world input component
  52014. */
  52015. readonly world: NodeMaterialConnectionPoint;
  52016. /**
  52017. * Gets the output component
  52018. */
  52019. readonly output: NodeMaterialConnectionPoint;
  52020. autoConfigure(): void;
  52021. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  52022. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52023. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52024. protected _buildBlock(state: NodeMaterialBuildState): this;
  52025. }
  52026. }
  52027. declare module BABYLON {
  52028. /**
  52029. * Block used to add support for instances
  52030. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  52031. */
  52032. export class InstancesBlock extends NodeMaterialBlock {
  52033. /**
  52034. * Creates a new InstancesBlock
  52035. * @param name defines the block name
  52036. */
  52037. constructor(name: string);
  52038. /**
  52039. * Gets the current class name
  52040. * @returns the class name
  52041. */
  52042. getClassName(): string;
  52043. /**
  52044. * Gets the first world row input component
  52045. */
  52046. readonly world0: NodeMaterialConnectionPoint;
  52047. /**
  52048. * Gets the second world row input component
  52049. */
  52050. readonly world1: NodeMaterialConnectionPoint;
  52051. /**
  52052. * Gets the third world row input component
  52053. */
  52054. readonly world2: NodeMaterialConnectionPoint;
  52055. /**
  52056. * Gets the forth world row input component
  52057. */
  52058. readonly world3: NodeMaterialConnectionPoint;
  52059. /**
  52060. * Gets the world input component
  52061. */
  52062. readonly world: NodeMaterialConnectionPoint;
  52063. /**
  52064. * Gets the output component
  52065. */
  52066. readonly output: NodeMaterialConnectionPoint;
  52067. autoConfigure(): void;
  52068. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  52069. protected _buildBlock(state: NodeMaterialBuildState): this;
  52070. }
  52071. }
  52072. declare module BABYLON {
  52073. /**
  52074. * Block used to add morph targets support to vertex shader
  52075. */
  52076. export class MorphTargetsBlock extends NodeMaterialBlock {
  52077. private _repeatableContentAnchor;
  52078. private _repeatebleContentGenerated;
  52079. /**
  52080. * Create a new MorphTargetsBlock
  52081. * @param name defines the block name
  52082. */
  52083. constructor(name: string);
  52084. /**
  52085. * Gets the current class name
  52086. * @returns the class name
  52087. */
  52088. getClassName(): string;
  52089. /**
  52090. * Gets the position input component
  52091. */
  52092. readonly position: NodeMaterialConnectionPoint;
  52093. /**
  52094. * Gets the normal input component
  52095. */
  52096. readonly normal: NodeMaterialConnectionPoint;
  52097. /**
  52098. * Gets the tangent input component
  52099. */
  52100. readonly tangent: NodeMaterialConnectionPoint;
  52101. /**
  52102. * Gets the tangent input component
  52103. */
  52104. readonly uv: NodeMaterialConnectionPoint;
  52105. /**
  52106. * Gets the position output component
  52107. */
  52108. readonly positionOutput: NodeMaterialConnectionPoint;
  52109. /**
  52110. * Gets the normal output component
  52111. */
  52112. readonly normalOutput: NodeMaterialConnectionPoint;
  52113. /**
  52114. * Gets the tangent output component
  52115. */
  52116. readonly tangentOutput: NodeMaterialConnectionPoint;
  52117. /**
  52118. * Gets the tangent output component
  52119. */
  52120. readonly uvOutput: NodeMaterialConnectionPoint;
  52121. initialize(state: NodeMaterialBuildState): void;
  52122. autoConfigure(): void;
  52123. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52124. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52125. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  52126. protected _buildBlock(state: NodeMaterialBuildState): this;
  52127. }
  52128. }
  52129. declare module BABYLON {
  52130. /**
  52131. * Block used to add an alpha test in the fragment shader
  52132. */
  52133. export class AlphaTestBlock extends NodeMaterialBlock {
  52134. /**
  52135. * Gets or sets the alpha value where alpha testing happens
  52136. */
  52137. alphaCutOff: number;
  52138. /**
  52139. * Create a new AlphaTestBlock
  52140. * @param name defines the block name
  52141. */
  52142. constructor(name: string);
  52143. /**
  52144. * Gets the current class name
  52145. * @returns the class name
  52146. */
  52147. getClassName(): string;
  52148. /**
  52149. * Gets the color input component
  52150. */
  52151. readonly color: NodeMaterialConnectionPoint;
  52152. /**
  52153. * Gets the alpha input component
  52154. */
  52155. readonly alpha: NodeMaterialConnectionPoint;
  52156. protected _buildBlock(state: NodeMaterialBuildState): this;
  52157. }
  52158. }
  52159. declare module BABYLON {
  52160. /**
  52161. * Block used to create a Color3/4 out of individual inputs (one for each component)
  52162. */
  52163. export class ColorMergerBlock extends NodeMaterialBlock {
  52164. /**
  52165. * Create a new ColorMergerBlock
  52166. * @param name defines the block name
  52167. */
  52168. constructor(name: string);
  52169. /**
  52170. * Gets the current class name
  52171. * @returns the class name
  52172. */
  52173. getClassName(): string;
  52174. /**
  52175. * Gets the r component (input)
  52176. */
  52177. readonly r: NodeMaterialConnectionPoint;
  52178. /**
  52179. * Gets the g component (input)
  52180. */
  52181. readonly g: NodeMaterialConnectionPoint;
  52182. /**
  52183. * Gets the b component (input)
  52184. */
  52185. readonly b: NodeMaterialConnectionPoint;
  52186. /**
  52187. * Gets the a component (input)
  52188. */
  52189. readonly a: NodeMaterialConnectionPoint;
  52190. /**
  52191. * Gets the rgba component (output)
  52192. */
  52193. readonly rgba: NodeMaterialConnectionPoint;
  52194. /**
  52195. * Gets the rgb component (output)
  52196. */
  52197. readonly rgb: NodeMaterialConnectionPoint;
  52198. protected _buildBlock(state: NodeMaterialBuildState): this;
  52199. }
  52200. }
  52201. declare module BABYLON {
  52202. /**
  52203. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  52204. */
  52205. export class VectorMergerBlock extends NodeMaterialBlock {
  52206. /**
  52207. * Create a new VectorMergerBlock
  52208. * @param name defines the block name
  52209. */
  52210. constructor(name: string);
  52211. /**
  52212. * Gets the current class name
  52213. * @returns the class name
  52214. */
  52215. getClassName(): string;
  52216. /**
  52217. * Gets the x component (input)
  52218. */
  52219. readonly x: NodeMaterialConnectionPoint;
  52220. /**
  52221. * Gets the y component (input)
  52222. */
  52223. readonly y: NodeMaterialConnectionPoint;
  52224. /**
  52225. * Gets the z component (input)
  52226. */
  52227. readonly z: NodeMaterialConnectionPoint;
  52228. /**
  52229. * Gets the w component (input)
  52230. */
  52231. readonly w: NodeMaterialConnectionPoint;
  52232. /**
  52233. * Gets the xyzw component (output)
  52234. */
  52235. readonly xyzw: NodeMaterialConnectionPoint;
  52236. /**
  52237. * Gets the xyz component (output)
  52238. */
  52239. readonly xyz: NodeMaterialConnectionPoint;
  52240. /**
  52241. * Gets the xy component (output)
  52242. */
  52243. readonly xy: NodeMaterialConnectionPoint;
  52244. protected _buildBlock(state: NodeMaterialBuildState): this;
  52245. }
  52246. }
  52247. declare module BABYLON {
  52248. /**
  52249. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  52250. */
  52251. export class ColorSplitterBlock extends NodeMaterialBlock {
  52252. /**
  52253. * Create a new ColorSplitterBlock
  52254. * @param name defines the block name
  52255. */
  52256. constructor(name: string);
  52257. /**
  52258. * Gets the current class name
  52259. * @returns the class name
  52260. */
  52261. getClassName(): string;
  52262. /**
  52263. * Gets the rgba component (input)
  52264. */
  52265. readonly rgba: NodeMaterialConnectionPoint;
  52266. /**
  52267. * Gets the rgb component (input)
  52268. */
  52269. readonly rgbIn: NodeMaterialConnectionPoint;
  52270. /**
  52271. * Gets the rgb component (output)
  52272. */
  52273. readonly rgbOut: NodeMaterialConnectionPoint;
  52274. /**
  52275. * Gets the r component (output)
  52276. */
  52277. readonly r: NodeMaterialConnectionPoint;
  52278. /**
  52279. * Gets the g component (output)
  52280. */
  52281. readonly g: NodeMaterialConnectionPoint;
  52282. /**
  52283. * Gets the b component (output)
  52284. */
  52285. readonly b: NodeMaterialConnectionPoint;
  52286. /**
  52287. * Gets the a component (output)
  52288. */
  52289. readonly a: NodeMaterialConnectionPoint;
  52290. protected _buildBlock(state: NodeMaterialBuildState): this;
  52291. }
  52292. }
  52293. declare module BABYLON {
  52294. /**
  52295. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  52296. */
  52297. export class VectorSplitterBlock extends NodeMaterialBlock {
  52298. /**
  52299. * Create a new VectorSplitterBlock
  52300. * @param name defines the block name
  52301. */
  52302. constructor(name: string);
  52303. /**
  52304. * Gets the current class name
  52305. * @returns the class name
  52306. */
  52307. getClassName(): string;
  52308. /**
  52309. * Gets the xyzw component (input)
  52310. */
  52311. readonly xyzw: NodeMaterialConnectionPoint;
  52312. /**
  52313. * Gets the xyz component (input)
  52314. */
  52315. readonly xyzIn: NodeMaterialConnectionPoint;
  52316. /**
  52317. * Gets the xy component (input)
  52318. */
  52319. readonly xyIn: NodeMaterialConnectionPoint;
  52320. /**
  52321. * Gets the xyz component (output)
  52322. */
  52323. readonly xyzOut: NodeMaterialConnectionPoint;
  52324. /**
  52325. * Gets the xy component (output)
  52326. */
  52327. readonly xyOut: NodeMaterialConnectionPoint;
  52328. /**
  52329. * Gets the x component (output)
  52330. */
  52331. readonly x: NodeMaterialConnectionPoint;
  52332. /**
  52333. * Gets the y component (output)
  52334. */
  52335. readonly y: NodeMaterialConnectionPoint;
  52336. /**
  52337. * Gets the z component (output)
  52338. */
  52339. readonly z: NodeMaterialConnectionPoint;
  52340. /**
  52341. * Gets the w component (output)
  52342. */
  52343. readonly w: NodeMaterialConnectionPoint;
  52344. protected _buildBlock(state: NodeMaterialBuildState): this;
  52345. }
  52346. }
  52347. declare module BABYLON {
  52348. /**
  52349. * Block used to add image processing support to fragment shader
  52350. */
  52351. export class ImageProcessingBlock extends NodeMaterialBlock {
  52352. /**
  52353. * Create a new ImageProcessingBlock
  52354. * @param name defines the block name
  52355. */
  52356. constructor(name: string);
  52357. /**
  52358. * Gets the current class name
  52359. * @returns the class name
  52360. */
  52361. getClassName(): string;
  52362. /**
  52363. * Gets the color input component
  52364. */
  52365. readonly color: NodeMaterialConnectionPoint;
  52366. /**
  52367. * Gets the output component
  52368. */
  52369. readonly output: NodeMaterialConnectionPoint;
  52370. /**
  52371. * Initialize the block and prepare the context for build
  52372. * @param state defines the state that will be used for the build
  52373. */
  52374. initialize(state: NodeMaterialBuildState): void;
  52375. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  52376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52378. protected _buildBlock(state: NodeMaterialBuildState): this;
  52379. }
  52380. }
  52381. declare module BABYLON {
  52382. /**
  52383. * Block used to add support for scene fog
  52384. */
  52385. export class FogBlock extends NodeMaterialBlock {
  52386. private _fogDistanceName;
  52387. private _fogParameters;
  52388. /**
  52389. * Create a new FogBlock
  52390. * @param name defines the block name
  52391. */
  52392. constructor(name: string);
  52393. /**
  52394. * Gets the current class name
  52395. * @returns the class name
  52396. */
  52397. getClassName(): string;
  52398. /**
  52399. * Gets the world position input component
  52400. */
  52401. readonly worldPosition: NodeMaterialConnectionPoint;
  52402. /**
  52403. * Gets the view input component
  52404. */
  52405. readonly view: NodeMaterialConnectionPoint;
  52406. /**
  52407. * Gets the color input component
  52408. */
  52409. readonly color: NodeMaterialConnectionPoint;
  52410. /**
  52411. * Gets the fog color input component
  52412. */
  52413. readonly fogColor: NodeMaterialConnectionPoint;
  52414. /**
  52415. * Gets the output component
  52416. */
  52417. readonly output: NodeMaterialConnectionPoint;
  52418. autoConfigure(): void;
  52419. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52420. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52421. protected _buildBlock(state: NodeMaterialBuildState): this;
  52422. }
  52423. }
  52424. declare module BABYLON {
  52425. /**
  52426. * Block used to add light in the fragment shader
  52427. */
  52428. export class LightBlock extends NodeMaterialBlock {
  52429. private _lightId;
  52430. /**
  52431. * Gets or sets the light associated with this block
  52432. */
  52433. light: Nullable<Light>;
  52434. /**
  52435. * Create a new LightBlock
  52436. * @param name defines the block name
  52437. */
  52438. constructor(name: string);
  52439. /**
  52440. * Gets the current class name
  52441. * @returns the class name
  52442. */
  52443. getClassName(): string;
  52444. /**
  52445. * Gets the world position input component
  52446. */
  52447. readonly worldPosition: NodeMaterialConnectionPoint;
  52448. /**
  52449. * Gets the world normal input component
  52450. */
  52451. readonly worldNormal: NodeMaterialConnectionPoint;
  52452. /**
  52453. * Gets the camera (or eye) position component
  52454. */
  52455. readonly cameraPosition: NodeMaterialConnectionPoint;
  52456. /**
  52457. * Gets the diffuse output component
  52458. */
  52459. readonly diffuseOutput: NodeMaterialConnectionPoint;
  52460. /**
  52461. * Gets the specular output component
  52462. */
  52463. readonly specularOutput: NodeMaterialConnectionPoint;
  52464. autoConfigure(): void;
  52465. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52466. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  52467. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  52468. private _injectVertexCode;
  52469. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  52470. serialize(): any; private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  52471. }
  52472. }
  52473. declare module BABYLON {
  52474. /**
  52475. * Block used to multiply 2 values
  52476. */
  52477. export class MultiplyBlock extends NodeMaterialBlock {
  52478. /**
  52479. * Creates a new MultiplyBlock
  52480. * @param name defines the block name
  52481. */
  52482. constructor(name: string);
  52483. /**
  52484. * Gets the current class name
  52485. * @returns the class name
  52486. */
  52487. getClassName(): string;
  52488. /**
  52489. * Gets the left operand input component
  52490. */
  52491. readonly left: NodeMaterialConnectionPoint;
  52492. /**
  52493. * Gets the right operand input component
  52494. */
  52495. readonly right: NodeMaterialConnectionPoint;
  52496. /**
  52497. * Gets the output component
  52498. */
  52499. readonly output: NodeMaterialConnectionPoint;
  52500. protected _buildBlock(state: NodeMaterialBuildState): this;
  52501. }
  52502. }
  52503. declare module BABYLON {
  52504. /**
  52505. * Block used to add 2 vectors
  52506. */
  52507. export class AddBlock extends NodeMaterialBlock {
  52508. /**
  52509. * Creates a new AddBlock
  52510. * @param name defines the block name
  52511. */
  52512. constructor(name: string);
  52513. /**
  52514. * Gets the current class name
  52515. * @returns the class name
  52516. */
  52517. getClassName(): string;
  52518. /**
  52519. * Gets the left operand input component
  52520. */
  52521. readonly left: NodeMaterialConnectionPoint;
  52522. /**
  52523. * Gets the right operand input component
  52524. */
  52525. readonly right: NodeMaterialConnectionPoint;
  52526. /**
  52527. * Gets the output component
  52528. */
  52529. readonly output: NodeMaterialConnectionPoint;
  52530. protected _buildBlock(state: NodeMaterialBuildState): this;
  52531. }
  52532. }
  52533. declare module BABYLON {
  52534. /**
  52535. * Block used to scale a vector by a float
  52536. */
  52537. export class ScaleBlock extends NodeMaterialBlock {
  52538. /**
  52539. * Creates a new ScaleBlock
  52540. * @param name defines the block name
  52541. */
  52542. constructor(name: string);
  52543. /**
  52544. * Gets the current class name
  52545. * @returns the class name
  52546. */
  52547. getClassName(): string;
  52548. /**
  52549. * Gets the input component
  52550. */
  52551. readonly input: NodeMaterialConnectionPoint;
  52552. /**
  52553. * Gets the factor input component
  52554. */
  52555. readonly factor: NodeMaterialConnectionPoint;
  52556. /**
  52557. * Gets the output component
  52558. */
  52559. readonly output: NodeMaterialConnectionPoint;
  52560. protected _buildBlock(state: NodeMaterialBuildState): this;
  52561. }
  52562. }
  52563. declare module BABYLON {
  52564. /**
  52565. * Block used to clamp a float
  52566. */
  52567. export class ClampBlock extends NodeMaterialBlock {
  52568. /** Gets or sets the minimum range */
  52569. minimum: number;
  52570. /** Gets or sets the maximum range */
  52571. maximum: number;
  52572. /**
  52573. * Creates a new ClampBlock
  52574. * @param name defines the block name
  52575. */
  52576. constructor(name: string);
  52577. /**
  52578. * Gets the current class name
  52579. * @returns the class name
  52580. */
  52581. getClassName(): string;
  52582. /**
  52583. * Gets the value input component
  52584. */
  52585. readonly value: NodeMaterialConnectionPoint;
  52586. /**
  52587. * Gets the output component
  52588. */
  52589. readonly output: NodeMaterialConnectionPoint;
  52590. protected _buildBlock(state: NodeMaterialBuildState): this;
  52591. }
  52592. }
  52593. declare module BABYLON {
  52594. /**
  52595. * Block used to apply a cross product between 2 vectors
  52596. */
  52597. export class CrossBlock extends NodeMaterialBlock {
  52598. /**
  52599. * Creates a new CrossBlock
  52600. * @param name defines the block name
  52601. */
  52602. constructor(name: string);
  52603. /**
  52604. * Gets the current class name
  52605. * @returns the class name
  52606. */
  52607. getClassName(): string;
  52608. /**
  52609. * Gets the left operand input component
  52610. */
  52611. readonly left: NodeMaterialConnectionPoint;
  52612. /**
  52613. * Gets the right operand input component
  52614. */
  52615. readonly right: NodeMaterialConnectionPoint;
  52616. /**
  52617. * Gets the output component
  52618. */
  52619. readonly output: NodeMaterialConnectionPoint;
  52620. protected _buildBlock(state: NodeMaterialBuildState): this;
  52621. }
  52622. }
  52623. declare module BABYLON {
  52624. /**
  52625. * Block used to apply a dot product between 2 vectors
  52626. */
  52627. export class DotBlock extends NodeMaterialBlock {
  52628. /**
  52629. * Creates a new DotBlock
  52630. * @param name defines the block name
  52631. */
  52632. constructor(name: string);
  52633. /**
  52634. * Gets the current class name
  52635. * @returns the class name
  52636. */
  52637. getClassName(): string;
  52638. /**
  52639. * Gets the left operand input component
  52640. */
  52641. readonly left: NodeMaterialConnectionPoint;
  52642. /**
  52643. * Gets the right operand input component
  52644. */
  52645. readonly right: NodeMaterialConnectionPoint;
  52646. /**
  52647. * Gets the output component
  52648. */
  52649. readonly output: NodeMaterialConnectionPoint;
  52650. protected _buildBlock(state: NodeMaterialBuildState): this;
  52651. }
  52652. }
  52653. declare module BABYLON {
  52654. /**
  52655. * Block used to remap a float from a range to a new one
  52656. */
  52657. export class RemapBlock extends NodeMaterialBlock {
  52658. /**
  52659. * Gets or sets the source range
  52660. */
  52661. sourceRange: Vector2;
  52662. /**
  52663. * Gets or sets the target range
  52664. */
  52665. targetRange: Vector2;
  52666. /**
  52667. * Creates a new RemapBlock
  52668. * @param name defines the block name
  52669. */
  52670. constructor(name: string);
  52671. /**
  52672. * Gets the current class name
  52673. * @returns the class name
  52674. */
  52675. getClassName(): string;
  52676. /**
  52677. * Gets the input component
  52678. */
  52679. readonly input: NodeMaterialConnectionPoint;
  52680. /**
  52681. * Gets the output component
  52682. */
  52683. readonly output: NodeMaterialConnectionPoint;
  52684. protected _buildBlock(state: NodeMaterialBuildState): this;
  52685. }
  52686. }
  52687. declare module BABYLON {
  52688. /**
  52689. * Block used to normalize a vector
  52690. */
  52691. export class NormalizeBlock extends NodeMaterialBlock {
  52692. /**
  52693. * Creates a new NormalizeBlock
  52694. * @param name defines the block name
  52695. */
  52696. constructor(name: string);
  52697. /**
  52698. * Gets the current class name
  52699. * @returns the class name
  52700. */
  52701. getClassName(): string;
  52702. /**
  52703. * Gets the input component
  52704. */
  52705. readonly input: NodeMaterialConnectionPoint;
  52706. /**
  52707. * Gets the output component
  52708. */
  52709. readonly output: NodeMaterialConnectionPoint;
  52710. protected _buildBlock(state: NodeMaterialBuildState): this;
  52711. }
  52712. }
  52713. declare module BABYLON {
  52714. /**
  52715. * Operations supported by the Trigonometry block
  52716. */
  52717. export enum TrigonometryBlockOperations {
  52718. /** Cos */
  52719. Cos = 0,
  52720. /** Sin */
  52721. Sin = 1,
  52722. /** Abs */
  52723. Abs = 2
  52724. }
  52725. /**
  52726. * Block used to apply trigonometry operation to floats
  52727. */
  52728. export class TrigonometryBlock extends NodeMaterialBlock {
  52729. /**
  52730. * Gets or sets the operation applied by the block
  52731. */
  52732. operation: TrigonometryBlockOperations;
  52733. /**
  52734. * Creates a new TrigonometryBlock
  52735. * @param name defines the block name
  52736. */
  52737. constructor(name: string);
  52738. /**
  52739. * Gets the current class name
  52740. * @returns the class name
  52741. */
  52742. getClassName(): string;
  52743. /**
  52744. * Gets the input component
  52745. */
  52746. readonly input: NodeMaterialConnectionPoint;
  52747. /**
  52748. * Gets the output component
  52749. */
  52750. readonly output: NodeMaterialConnectionPoint;
  52751. protected _buildBlock(state: NodeMaterialBuildState): this;
  52752. }
  52753. }
  52754. declare module BABYLON {
  52755. /**
  52756. * Effect Render Options
  52757. */
  52758. export interface IEffectRendererOptions {
  52759. /**
  52760. * Defines the vertices positions.
  52761. */
  52762. positions?: number[];
  52763. /**
  52764. * Defines the indices.
  52765. */
  52766. indices?: number[];
  52767. }
  52768. /**
  52769. * Helper class to render one or more effects
  52770. */
  52771. export class EffectRenderer {
  52772. private engine;
  52773. private static _DefaultOptions;
  52774. private _vertexBuffers;
  52775. private _indexBuffer;
  52776. private _ringBufferIndex;
  52777. private _ringScreenBuffer;
  52778. private _fullscreenViewport;
  52779. private _getNextFrameBuffer;
  52780. /**
  52781. * Creates an effect renderer
  52782. * @param engine the engine to use for rendering
  52783. * @param options defines the options of the effect renderer
  52784. */
  52785. constructor(engine: Engine, options?: IEffectRendererOptions);
  52786. /**
  52787. * Sets the current viewport in normalized coordinates 0-1
  52788. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  52789. */
  52790. setViewport(viewport?: Viewport): void;
  52791. /**
  52792. * Sets the current effect wrapper to use during draw.
  52793. * The effect needs to be ready before calling this api.
  52794. * This also sets the default full screen position attribute.
  52795. * @param effectWrapper Defines the effect to draw with
  52796. */
  52797. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  52798. /**
  52799. * Draws a full screen quad.
  52800. */
  52801. draw(): void;
  52802. /**
  52803. * renders one or more effects to a specified texture
  52804. * @param effectWrappers list of effects to renderer
  52805. * @param outputTexture texture to draw to, if null it will render to the screen
  52806. */
  52807. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  52808. /**
  52809. * Disposes of the effect renderer
  52810. */
  52811. dispose(): void;
  52812. }
  52813. /**
  52814. * Options to create an EffectWrapper
  52815. */
  52816. interface EffectWrapperCreationOptions {
  52817. /**
  52818. * Engine to use to create the effect
  52819. */
  52820. engine: Engine;
  52821. /**
  52822. * Fragment shader for the effect
  52823. */
  52824. fragmentShader: string;
  52825. /**
  52826. * Vertex shader for the effect
  52827. */
  52828. vertexShader?: string;
  52829. /**
  52830. * Attributes to use in the shader
  52831. */
  52832. attributeNames?: Array<string>;
  52833. /**
  52834. * Uniforms to use in the shader
  52835. */
  52836. uniformNames?: Array<string>;
  52837. /**
  52838. * Texture sampler names to use in the shader
  52839. */
  52840. samplerNames?: Array<string>;
  52841. /**
  52842. * The friendly name of the effect displayed in Spector.
  52843. */
  52844. name?: string;
  52845. }
  52846. /**
  52847. * Wraps an effect to be used for rendering
  52848. */
  52849. export class EffectWrapper {
  52850. /**
  52851. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  52852. */
  52853. onApplyObservable: Observable<{}>;
  52854. /**
  52855. * The underlying effect
  52856. */
  52857. effect: Effect;
  52858. /**
  52859. * Creates an effect to be renderer
  52860. * @param creationOptions options to create the effect
  52861. */
  52862. constructor(creationOptions: EffectWrapperCreationOptions);
  52863. /**
  52864. * Disposes of the effect wrapper
  52865. */
  52866. dispose(): void;
  52867. }
  52868. }
  52869. declare module BABYLON {
  52870. /**
  52871. * Helper class to push actions to a pool of workers.
  52872. */
  52873. export class WorkerPool implements IDisposable {
  52874. private _workerInfos;
  52875. private _pendingActions;
  52876. /**
  52877. * Constructor
  52878. * @param workers Array of workers to use for actions
  52879. */
  52880. constructor(workers: Array<Worker>);
  52881. /**
  52882. * Terminates all workers and clears any pending actions.
  52883. */
  52884. dispose(): void;
  52885. /**
  52886. * Pushes an action to the worker pool. If all the workers are active, the action will be
  52887. * pended until a worker has completed its action.
  52888. * @param action The action to perform. Call onComplete when the action is complete.
  52889. */
  52890. push(action: (worker: Worker, onComplete: () => void) => void): void;
  52891. private _execute;
  52892. }
  52893. }
  52894. declare module BABYLON {
  52895. /**
  52896. * Configuration for Draco compression
  52897. */
  52898. export interface IDracoCompressionConfiguration {
  52899. /**
  52900. * Configuration for the decoder.
  52901. */
  52902. decoder: {
  52903. /**
  52904. * The url to the WebAssembly module.
  52905. */
  52906. wasmUrl?: string;
  52907. /**
  52908. * The url to the WebAssembly binary.
  52909. */
  52910. wasmBinaryUrl?: string;
  52911. /**
  52912. * The url to the fallback JavaScript module.
  52913. */
  52914. fallbackUrl?: string;
  52915. };
  52916. }
  52917. /**
  52918. * Draco compression (https://google.github.io/draco/)
  52919. *
  52920. * This class wraps the Draco module.
  52921. *
  52922. * **Encoder**
  52923. *
  52924. * The encoder is not currently implemented.
  52925. *
  52926. * **Decoder**
  52927. *
  52928. * 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.
  52929. *
  52930. * To update the configuration, use the following code:
  52931. * ```javascript
  52932. * DracoCompression.Configuration = {
  52933. * decoder: {
  52934. * wasmUrl: "<url to the WebAssembly library>",
  52935. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  52936. * fallbackUrl: "<url to the fallback JavaScript library>",
  52937. * }
  52938. * };
  52939. * ```
  52940. *
  52941. * 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.
  52942. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  52943. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  52944. *
  52945. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  52946. * ```javascript
  52947. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  52948. * ```
  52949. *
  52950. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  52951. */
  52952. export class DracoCompression implements IDisposable {
  52953. private _workerPoolPromise?;
  52954. private _decoderModulePromise?;
  52955. /**
  52956. * The configuration. Defaults to the following urls:
  52957. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  52958. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  52959. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  52960. */
  52961. static Configuration: IDracoCompressionConfiguration;
  52962. /**
  52963. * Returns true if the decoder configuration is available.
  52964. */
  52965. static readonly DecoderAvailable: boolean;
  52966. /**
  52967. * Default number of workers to create when creating the draco compression object.
  52968. */
  52969. static DefaultNumWorkers: number;
  52970. private static GetDefaultNumWorkers;
  52971. private static _Default;
  52972. /**
  52973. * Default instance for the draco compression object.
  52974. */
  52975. static readonly Default: DracoCompression;
  52976. /**
  52977. * Constructor
  52978. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  52979. */
  52980. constructor(numWorkers?: number);
  52981. /**
  52982. * Stop all async operations and release resources.
  52983. */
  52984. dispose(): void;
  52985. /**
  52986. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  52987. * @returns a promise that resolves when ready
  52988. */
  52989. whenReadyAsync(): Promise<void>;
  52990. /**
  52991. * Decode Draco compressed mesh data to vertex data.
  52992. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  52993. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  52994. * @returns A promise that resolves with the decoded vertex data
  52995. */
  52996. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  52997. [kind: string]: number;
  52998. }): Promise<VertexData>;
  52999. }
  53000. }
  53001. declare module BABYLON {
  53002. /**
  53003. * Class for building Constructive Solid Geometry
  53004. */
  53005. export class CSG {
  53006. private polygons;
  53007. /**
  53008. * The world matrix
  53009. */
  53010. matrix: Matrix;
  53011. /**
  53012. * Stores the position
  53013. */
  53014. position: Vector3;
  53015. /**
  53016. * Stores the rotation
  53017. */
  53018. rotation: Vector3;
  53019. /**
  53020. * Stores the rotation quaternion
  53021. */
  53022. rotationQuaternion: Nullable<Quaternion>;
  53023. /**
  53024. * Stores the scaling vector
  53025. */
  53026. scaling: Vector3;
  53027. /**
  53028. * Convert the Mesh to CSG
  53029. * @param mesh The Mesh to convert to CSG
  53030. * @returns A new CSG from the Mesh
  53031. */
  53032. static FromMesh(mesh: Mesh): CSG;
  53033. /**
  53034. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  53035. * @param polygons Polygons used to construct a CSG solid
  53036. */
  53037. private static FromPolygons;
  53038. /**
  53039. * Clones, or makes a deep copy, of the CSG
  53040. * @returns A new CSG
  53041. */
  53042. clone(): CSG;
  53043. /**
  53044. * Unions this CSG with another CSG
  53045. * @param csg The CSG to union against this CSG
  53046. * @returns The unioned CSG
  53047. */
  53048. union(csg: CSG): CSG;
  53049. /**
  53050. * Unions this CSG with another CSG in place
  53051. * @param csg The CSG to union against this CSG
  53052. */
  53053. unionInPlace(csg: CSG): void;
  53054. /**
  53055. * Subtracts this CSG with another CSG
  53056. * @param csg The CSG to subtract against this CSG
  53057. * @returns A new CSG
  53058. */
  53059. subtract(csg: CSG): CSG;
  53060. /**
  53061. * Subtracts this CSG with another CSG in place
  53062. * @param csg The CSG to subtact against this CSG
  53063. */
  53064. subtractInPlace(csg: CSG): void;
  53065. /**
  53066. * Intersect this CSG with another CSG
  53067. * @param csg The CSG to intersect against this CSG
  53068. * @returns A new CSG
  53069. */
  53070. intersect(csg: CSG): CSG;
  53071. /**
  53072. * Intersects this CSG with another CSG in place
  53073. * @param csg The CSG to intersect against this CSG
  53074. */
  53075. intersectInPlace(csg: CSG): void;
  53076. /**
  53077. * Return a new CSG solid with solid and empty space switched. This solid is
  53078. * not modified.
  53079. * @returns A new CSG solid with solid and empty space switched
  53080. */
  53081. inverse(): CSG;
  53082. /**
  53083. * Inverses the CSG in place
  53084. */
  53085. inverseInPlace(): void;
  53086. /**
  53087. * This is used to keep meshes transformations so they can be restored
  53088. * when we build back a Babylon Mesh
  53089. * NB : All CSG operations are performed in world coordinates
  53090. * @param csg The CSG to copy the transform attributes from
  53091. * @returns This CSG
  53092. */
  53093. copyTransformAttributes(csg: CSG): CSG;
  53094. /**
  53095. * Build Raw mesh from CSG
  53096. * Coordinates here are in world space
  53097. * @param name The name of the mesh geometry
  53098. * @param scene The Scene
  53099. * @param keepSubMeshes Specifies if the submeshes should be kept
  53100. * @returns A new Mesh
  53101. */
  53102. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  53103. /**
  53104. * Build Mesh from CSG taking material and transforms into account
  53105. * @param name The name of the Mesh
  53106. * @param material The material of the Mesh
  53107. * @param scene The Scene
  53108. * @param keepSubMeshes Specifies if submeshes should be kept
  53109. * @returns The new Mesh
  53110. */
  53111. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  53112. }
  53113. }
  53114. declare module BABYLON {
  53115. /**
  53116. * Class used to create a trail following a mesh
  53117. */
  53118. export class TrailMesh extends Mesh {
  53119. private _generator;
  53120. private _autoStart;
  53121. private _running;
  53122. private _diameter;
  53123. private _length;
  53124. private _sectionPolygonPointsCount;
  53125. private _sectionVectors;
  53126. private _sectionNormalVectors;
  53127. private _beforeRenderObserver;
  53128. /**
  53129. * @constructor
  53130. * @param name The value used by scene.getMeshByName() to do a lookup.
  53131. * @param generator The mesh to generate a trail.
  53132. * @param scene The scene to add this mesh to.
  53133. * @param diameter Diameter of trailing mesh. Default is 1.
  53134. * @param length Length of trailing mesh. Default is 60.
  53135. * @param autoStart Automatically start trailing mesh. Default true.
  53136. */
  53137. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  53138. /**
  53139. * "TrailMesh"
  53140. * @returns "TrailMesh"
  53141. */
  53142. getClassName(): string;
  53143. private _createMesh;
  53144. /**
  53145. * Start trailing mesh.
  53146. */
  53147. start(): void;
  53148. /**
  53149. * Stop trailing mesh.
  53150. */
  53151. stop(): void;
  53152. /**
  53153. * Update trailing mesh geometry.
  53154. */
  53155. update(): void;
  53156. /**
  53157. * Returns a new TrailMesh object.
  53158. * @param name is a string, the name given to the new mesh
  53159. * @param newGenerator use new generator object for cloned trail mesh
  53160. * @returns a new mesh
  53161. */
  53162. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  53163. /**
  53164. * Serializes this trail mesh
  53165. * @param serializationObject object to write serialization to
  53166. */
  53167. serialize(serializationObject: any): void;
  53168. /**
  53169. * Parses a serialized trail mesh
  53170. * @param parsedMesh the serialized mesh
  53171. * @param scene the scene to create the trail mesh in
  53172. * @returns the created trail mesh
  53173. */
  53174. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  53175. }
  53176. }
  53177. declare module BABYLON {
  53178. /**
  53179. * Class containing static functions to help procedurally build meshes
  53180. */
  53181. export class TiledBoxBuilder {
  53182. /**
  53183. * Creates a box mesh
  53184. * 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)
  53185. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53186. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53187. * * 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
  53188. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53189. * @param name defines the name of the mesh
  53190. * @param options defines the options used to create the mesh
  53191. * @param scene defines the hosting scene
  53192. * @returns the box mesh
  53193. */
  53194. static CreateTiledBox(name: string, options: {
  53195. pattern?: number;
  53196. width?: number;
  53197. height?: number;
  53198. depth?: number;
  53199. tileSize?: number;
  53200. tileWidth?: number;
  53201. tileHeight?: number;
  53202. alignHorizontal?: number;
  53203. alignVertical?: number;
  53204. faceUV?: Vector4[];
  53205. faceColors?: Color4[];
  53206. sideOrientation?: number;
  53207. updatable?: boolean;
  53208. }, scene?: Nullable<Scene>): Mesh;
  53209. }
  53210. }
  53211. declare module BABYLON {
  53212. /**
  53213. * Class containing static functions to help procedurally build meshes
  53214. */
  53215. export class TorusKnotBuilder {
  53216. /**
  53217. * Creates a torus knot mesh
  53218. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53219. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53220. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53221. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53222. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53223. * * 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
  53224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53225. * @param name defines the name of the mesh
  53226. * @param options defines the options used to create the mesh
  53227. * @param scene defines the hosting scene
  53228. * @returns the torus knot mesh
  53229. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53230. */
  53231. static CreateTorusKnot(name: string, options: {
  53232. radius?: number;
  53233. tube?: number;
  53234. radialSegments?: number;
  53235. tubularSegments?: number;
  53236. p?: number;
  53237. q?: number;
  53238. updatable?: boolean;
  53239. sideOrientation?: number;
  53240. frontUVs?: Vector4;
  53241. backUVs?: Vector4;
  53242. }, scene: any): Mesh;
  53243. }
  53244. }
  53245. declare module BABYLON {
  53246. /**
  53247. * Polygon
  53248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  53249. */
  53250. export class Polygon {
  53251. /**
  53252. * Creates a rectangle
  53253. * @param xmin bottom X coord
  53254. * @param ymin bottom Y coord
  53255. * @param xmax top X coord
  53256. * @param ymax top Y coord
  53257. * @returns points that make the resulting rectation
  53258. */
  53259. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  53260. /**
  53261. * Creates a circle
  53262. * @param radius radius of circle
  53263. * @param cx scale in x
  53264. * @param cy scale in y
  53265. * @param numberOfSides number of sides that make up the circle
  53266. * @returns points that make the resulting circle
  53267. */
  53268. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  53269. /**
  53270. * Creates a polygon from input string
  53271. * @param input Input polygon data
  53272. * @returns the parsed points
  53273. */
  53274. static Parse(input: string): Vector2[];
  53275. /**
  53276. * Starts building a polygon from x and y coordinates
  53277. * @param x x coordinate
  53278. * @param y y coordinate
  53279. * @returns the started path2
  53280. */
  53281. static StartingAt(x: number, y: number): Path2;
  53282. }
  53283. /**
  53284. * Builds a polygon
  53285. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  53286. */
  53287. export class PolygonMeshBuilder {
  53288. private _points;
  53289. private _outlinepoints;
  53290. private _holes;
  53291. private _name;
  53292. private _scene;
  53293. private _epoints;
  53294. private _eholes;
  53295. private _addToepoint;
  53296. /**
  53297. * Babylon reference to the earcut plugin.
  53298. */
  53299. bjsEarcut: any;
  53300. /**
  53301. * Creates a PolygonMeshBuilder
  53302. * @param name name of the builder
  53303. * @param contours Path of the polygon
  53304. * @param scene scene to add to when creating the mesh
  53305. * @param earcutInjection can be used to inject your own earcut reference
  53306. */
  53307. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  53308. /**
  53309. * Adds a whole within the polygon
  53310. * @param hole Array of points defining the hole
  53311. * @returns this
  53312. */
  53313. addHole(hole: Vector2[]): PolygonMeshBuilder;
  53314. /**
  53315. * Creates the polygon
  53316. * @param updatable If the mesh should be updatable
  53317. * @param depth The depth of the mesh created
  53318. * @returns the created mesh
  53319. */
  53320. build(updatable?: boolean, depth?: number): Mesh;
  53321. /**
  53322. * Creates the polygon
  53323. * @param depth The depth of the mesh created
  53324. * @returns the created VertexData
  53325. */
  53326. buildVertexData(depth?: number): VertexData;
  53327. /**
  53328. * Adds a side to the polygon
  53329. * @param positions points that make the polygon
  53330. * @param normals normals of the polygon
  53331. * @param uvs uvs of the polygon
  53332. * @param indices indices of the polygon
  53333. * @param bounds bounds of the polygon
  53334. * @param points points of the polygon
  53335. * @param depth depth of the polygon
  53336. * @param flip flip of the polygon
  53337. */
  53338. private addSide;
  53339. }
  53340. }
  53341. declare module BABYLON {
  53342. /**
  53343. * Class containing static functions to help procedurally build meshes
  53344. */
  53345. export class PolygonBuilder {
  53346. /**
  53347. * Creates a polygon mesh
  53348. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  53349. * * 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
  53350. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53351. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53352. * * 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)
  53353. * * Remember you can only change the shape positions, not their number when updating a polygon
  53354. * @param name defines the name of the mesh
  53355. * @param options defines the options used to create the mesh
  53356. * @param scene defines the hosting scene
  53357. * @param earcutInjection can be used to inject your own earcut reference
  53358. * @returns the polygon mesh
  53359. */
  53360. static CreatePolygon(name: string, options: {
  53361. shape: Vector3[];
  53362. holes?: Vector3[][];
  53363. depth?: number;
  53364. faceUV?: Vector4[];
  53365. faceColors?: Color4[];
  53366. updatable?: boolean;
  53367. sideOrientation?: number;
  53368. frontUVs?: Vector4;
  53369. backUVs?: Vector4;
  53370. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53371. /**
  53372. * Creates an extruded polygon mesh, with depth in the Y direction.
  53373. * * 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)
  53374. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53375. * @param name defines the name of the mesh
  53376. * @param options defines the options used to create the mesh
  53377. * @param scene defines the hosting scene
  53378. * @param earcutInjection can be used to inject your own earcut reference
  53379. * @returns the polygon mesh
  53380. */
  53381. static ExtrudePolygon(name: string, options: {
  53382. shape: Vector3[];
  53383. holes?: Vector3[][];
  53384. depth?: number;
  53385. faceUV?: Vector4[];
  53386. faceColors?: Color4[];
  53387. updatable?: boolean;
  53388. sideOrientation?: number;
  53389. frontUVs?: Vector4;
  53390. backUVs?: Vector4;
  53391. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  53392. }
  53393. }
  53394. declare module BABYLON {
  53395. /**
  53396. * Class containing static functions to help procedurally build meshes
  53397. */
  53398. export class LatheBuilder {
  53399. /**
  53400. * Creates lathe mesh.
  53401. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  53402. * * 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
  53403. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  53404. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  53405. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  53406. * * 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
  53407. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  53408. * * 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
  53409. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53410. * * 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
  53411. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53413. * @param name defines the name of the mesh
  53414. * @param options defines the options used to create the mesh
  53415. * @param scene defines the hosting scene
  53416. * @returns the lathe mesh
  53417. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  53418. */
  53419. static CreateLathe(name: string, options: {
  53420. shape: Vector3[];
  53421. radius?: number;
  53422. tessellation?: number;
  53423. clip?: number;
  53424. arc?: number;
  53425. closed?: boolean;
  53426. updatable?: boolean;
  53427. sideOrientation?: number;
  53428. frontUVs?: Vector4;
  53429. backUVs?: Vector4;
  53430. cap?: number;
  53431. invertUV?: boolean;
  53432. }, scene?: Nullable<Scene>): Mesh;
  53433. }
  53434. }
  53435. declare module BABYLON {
  53436. /**
  53437. * Class containing static functions to help procedurally build meshes
  53438. */
  53439. export class TiledPlaneBuilder {
  53440. /**
  53441. * Creates a tiled plane mesh
  53442. * * The parameter `pattern` will, depending on value, do nothing or
  53443. * * * flip (reflect about central vertical) alternate tiles across and up
  53444. * * * flip every tile on alternate rows
  53445. * * * rotate (180 degs) alternate tiles across and up
  53446. * * * rotate every tile on alternate rows
  53447. * * * flip and rotate alternate tiles across and up
  53448. * * * flip and rotate every tile on alternate rows
  53449. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  53450. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  53451. * * 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
  53452. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  53453. * * 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)
  53454. * * 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)
  53455. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53456. * @param name defines the name of the mesh
  53457. * @param options defines the options used to create the mesh
  53458. * @param scene defines the hosting scene
  53459. * @returns the box mesh
  53460. */
  53461. static CreateTiledPlane(name: string, options: {
  53462. pattern?: number;
  53463. tileSize?: number;
  53464. tileWidth?: number;
  53465. tileHeight?: number;
  53466. size?: number;
  53467. width?: number;
  53468. height?: number;
  53469. alignHorizontal?: number;
  53470. alignVertical?: number;
  53471. sideOrientation?: number;
  53472. frontUVs?: Vector4;
  53473. backUVs?: Vector4;
  53474. updatable?: boolean;
  53475. }, scene?: Nullable<Scene>): Mesh;
  53476. }
  53477. }
  53478. declare module BABYLON {
  53479. /**
  53480. * Class containing static functions to help procedurally build meshes
  53481. */
  53482. export class TubeBuilder {
  53483. /**
  53484. * Creates a tube mesh.
  53485. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53486. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  53487. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  53488. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  53489. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  53490. * * 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)
  53491. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  53492. * * 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
  53493. * * 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
  53494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53495. * * 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
  53496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53498. * @param name defines the name of the mesh
  53499. * @param options defines the options used to create the mesh
  53500. * @param scene defines the hosting scene
  53501. * @returns the tube mesh
  53502. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53503. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  53504. */
  53505. static CreateTube(name: string, options: {
  53506. path: Vector3[];
  53507. radius?: number;
  53508. tessellation?: number;
  53509. radiusFunction?: {
  53510. (i: number, distance: number): number;
  53511. };
  53512. cap?: number;
  53513. arc?: number;
  53514. updatable?: boolean;
  53515. sideOrientation?: number;
  53516. frontUVs?: Vector4;
  53517. backUVs?: Vector4;
  53518. instance?: Mesh;
  53519. invertUV?: boolean;
  53520. }, scene?: Nullable<Scene>): Mesh;
  53521. }
  53522. }
  53523. declare module BABYLON {
  53524. /**
  53525. * Class containing static functions to help procedurally build meshes
  53526. */
  53527. export class IcoSphereBuilder {
  53528. /**
  53529. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53530. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53531. * * 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`)
  53532. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53533. * * 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
  53534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53535. * * 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
  53536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53537. * @param name defines the name of the mesh
  53538. * @param options defines the options used to create the mesh
  53539. * @param scene defines the hosting scene
  53540. * @returns the icosahedron mesh
  53541. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53542. */
  53543. static CreateIcoSphere(name: string, options: {
  53544. radius?: number;
  53545. radiusX?: number;
  53546. radiusY?: number;
  53547. radiusZ?: number;
  53548. flat?: boolean;
  53549. subdivisions?: number;
  53550. sideOrientation?: number;
  53551. frontUVs?: Vector4;
  53552. backUVs?: Vector4;
  53553. updatable?: boolean;
  53554. }, scene?: Nullable<Scene>): Mesh;
  53555. }
  53556. }
  53557. declare module BABYLON {
  53558. /**
  53559. * Class containing static functions to help procedurally build meshes
  53560. */
  53561. export class DecalBuilder {
  53562. /**
  53563. * Creates a decal mesh.
  53564. * 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
  53565. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  53566. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  53567. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  53568. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  53569. * @param name defines the name of the mesh
  53570. * @param sourceMesh defines the mesh where the decal must be applied
  53571. * @param options defines the options used to create the mesh
  53572. * @param scene defines the hosting scene
  53573. * @returns the decal mesh
  53574. * @see https://doc.babylonjs.com/how_to/decals
  53575. */
  53576. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  53577. position?: Vector3;
  53578. normal?: Vector3;
  53579. size?: Vector3;
  53580. angle?: number;
  53581. }): Mesh;
  53582. }
  53583. }
  53584. declare module BABYLON {
  53585. /**
  53586. * Class containing static functions to help procedurally build meshes
  53587. */
  53588. export class MeshBuilder {
  53589. /**
  53590. * Creates a box mesh
  53591. * * The parameter `size` sets the size (float) of each box side (default 1)
  53592. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53593. * * 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)
  53594. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53596. * * 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
  53597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53598. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53599. * @param name defines the name of the mesh
  53600. * @param options defines the options used to create the mesh
  53601. * @param scene defines the hosting scene
  53602. * @returns the box mesh
  53603. */
  53604. static CreateBox(name: string, options: {
  53605. size?: number;
  53606. width?: number;
  53607. height?: number;
  53608. depth?: number;
  53609. faceUV?: Vector4[];
  53610. faceColors?: Color4[];
  53611. sideOrientation?: number;
  53612. frontUVs?: Vector4;
  53613. backUVs?: Vector4;
  53614. updatable?: boolean;
  53615. }, scene?: Nullable<Scene>): Mesh;
  53616. /**
  53617. * Creates a tiled box mesh
  53618. * * faceTiles sets the pattern, tile size and number of tiles for a face
  53619. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53620. * @param name defines the name of the mesh
  53621. * @param options defines the options used to create the mesh
  53622. * @param scene defines the hosting scene
  53623. * @returns the tiled box mesh
  53624. */
  53625. static CreateTiledBox(name: string, options: {
  53626. pattern?: number;
  53627. size?: number;
  53628. width?: number;
  53629. height?: number;
  53630. depth: number;
  53631. tileSize?: number;
  53632. tileWidth?: number;
  53633. tileHeight?: number;
  53634. faceUV?: Vector4[];
  53635. faceColors?: Color4[];
  53636. alignHorizontal?: number;
  53637. alignVertical?: number;
  53638. sideOrientation?: number;
  53639. updatable?: boolean;
  53640. }, scene?: Nullable<Scene>): Mesh;
  53641. /**
  53642. * Creates a sphere mesh
  53643. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  53644. * * 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`)
  53645. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  53646. * * 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
  53647. * * 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)
  53648. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53649. * * 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
  53650. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53651. * @param name defines the name of the mesh
  53652. * @param options defines the options used to create the mesh
  53653. * @param scene defines the hosting scene
  53654. * @returns the sphere mesh
  53655. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  53656. */
  53657. static CreateSphere(name: string, options: {
  53658. segments?: number;
  53659. diameter?: number;
  53660. diameterX?: number;
  53661. diameterY?: number;
  53662. diameterZ?: number;
  53663. arc?: number;
  53664. slice?: number;
  53665. sideOrientation?: number;
  53666. frontUVs?: Vector4;
  53667. backUVs?: Vector4;
  53668. updatable?: boolean;
  53669. }, scene?: Nullable<Scene>): Mesh;
  53670. /**
  53671. * Creates a plane polygonal mesh. By default, this is a disc
  53672. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  53673. * * 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
  53674. * * 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
  53675. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53676. * * 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
  53677. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53678. * @param name defines the name of the mesh
  53679. * @param options defines the options used to create the mesh
  53680. * @param scene defines the hosting scene
  53681. * @returns the plane polygonal mesh
  53682. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  53683. */
  53684. static CreateDisc(name: string, options: {
  53685. radius?: number;
  53686. tessellation?: number;
  53687. arc?: number;
  53688. updatable?: boolean;
  53689. sideOrientation?: number;
  53690. frontUVs?: Vector4;
  53691. backUVs?: Vector4;
  53692. }, scene?: Nullable<Scene>): Mesh;
  53693. /**
  53694. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  53695. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  53696. * * 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`)
  53697. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  53698. * * 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
  53699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53700. * * 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
  53701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53702. * @param name defines the name of the mesh
  53703. * @param options defines the options used to create the mesh
  53704. * @param scene defines the hosting scene
  53705. * @returns the icosahedron mesh
  53706. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  53707. */
  53708. static CreateIcoSphere(name: string, options: {
  53709. radius?: number;
  53710. radiusX?: number;
  53711. radiusY?: number;
  53712. radiusZ?: number;
  53713. flat?: boolean;
  53714. subdivisions?: number;
  53715. sideOrientation?: number;
  53716. frontUVs?: Vector4;
  53717. backUVs?: Vector4;
  53718. updatable?: boolean;
  53719. }, scene?: Nullable<Scene>): Mesh;
  53720. /**
  53721. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53722. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53723. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53724. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53725. * * 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
  53726. * * 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
  53727. * * 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
  53728. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53729. * * 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
  53730. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53731. * * 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
  53732. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53733. * * 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
  53734. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53735. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53736. * @param name defines the name of the mesh
  53737. * @param options defines the options used to create the mesh
  53738. * @param scene defines the hosting scene
  53739. * @returns the ribbon mesh
  53740. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53741. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53742. */
  53743. static CreateRibbon(name: string, options: {
  53744. pathArray: Vector3[][];
  53745. closeArray?: boolean;
  53746. closePath?: boolean;
  53747. offset?: number;
  53748. updatable?: boolean;
  53749. sideOrientation?: number;
  53750. frontUVs?: Vector4;
  53751. backUVs?: Vector4;
  53752. instance?: Mesh;
  53753. invertUV?: boolean;
  53754. uvs?: Vector2[];
  53755. colors?: Color4[];
  53756. }, scene?: Nullable<Scene>): Mesh;
  53757. /**
  53758. * Creates a cylinder or a cone mesh
  53759. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  53760. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  53761. * * 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.
  53762. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  53763. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  53764. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  53765. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  53766. * * 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).
  53767. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  53768. * * 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).
  53769. * * 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
  53770. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  53771. * * 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
  53772. * * 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.
  53773. * * If `enclose` is false, a ring surface is one element.
  53774. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  53775. * * 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
  53776. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53777. * * 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
  53778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53779. * @param name defines the name of the mesh
  53780. * @param options defines the options used to create the mesh
  53781. * @param scene defines the hosting scene
  53782. * @returns the cylinder mesh
  53783. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  53784. */
  53785. static CreateCylinder(name: string, options: {
  53786. height?: number;
  53787. diameterTop?: number;
  53788. diameterBottom?: number;
  53789. diameter?: number;
  53790. tessellation?: number;
  53791. subdivisions?: number;
  53792. arc?: number;
  53793. faceColors?: Color4[];
  53794. faceUV?: Vector4[];
  53795. updatable?: boolean;
  53796. hasRings?: boolean;
  53797. enclose?: boolean;
  53798. cap?: number;
  53799. sideOrientation?: number;
  53800. frontUVs?: Vector4;
  53801. backUVs?: Vector4;
  53802. }, scene?: Nullable<Scene>): Mesh;
  53803. /**
  53804. * Creates a torus mesh
  53805. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  53806. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  53807. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  53808. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53809. * * 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
  53810. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53811. * @param name defines the name of the mesh
  53812. * @param options defines the options used to create the mesh
  53813. * @param scene defines the hosting scene
  53814. * @returns the torus mesh
  53815. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  53816. */
  53817. static CreateTorus(name: string, options: {
  53818. diameter?: number;
  53819. thickness?: number;
  53820. tessellation?: number;
  53821. updatable?: boolean;
  53822. sideOrientation?: number;
  53823. frontUVs?: Vector4;
  53824. backUVs?: Vector4;
  53825. }, scene?: Nullable<Scene>): Mesh;
  53826. /**
  53827. * Creates a torus knot mesh
  53828. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  53829. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  53830. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  53831. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  53832. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53833. * * 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
  53834. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53835. * @param name defines the name of the mesh
  53836. * @param options defines the options used to create the mesh
  53837. * @param scene defines the hosting scene
  53838. * @returns the torus knot mesh
  53839. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  53840. */
  53841. static CreateTorusKnot(name: string, options: {
  53842. radius?: number;
  53843. tube?: number;
  53844. radialSegments?: number;
  53845. tubularSegments?: number;
  53846. p?: number;
  53847. q?: number;
  53848. updatable?: boolean;
  53849. sideOrientation?: number;
  53850. frontUVs?: Vector4;
  53851. backUVs?: Vector4;
  53852. }, scene?: Nullable<Scene>): Mesh;
  53853. /**
  53854. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  53855. * * 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
  53856. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  53857. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  53858. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  53859. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  53860. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  53861. * * 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
  53862. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  53863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53864. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  53865. * @param name defines the name of the new line system
  53866. * @param options defines the options used to create the line system
  53867. * @param scene defines the hosting scene
  53868. * @returns a new line system mesh
  53869. */
  53870. static CreateLineSystem(name: string, options: {
  53871. lines: Vector3[][];
  53872. updatable?: boolean;
  53873. instance?: Nullable<LinesMesh>;
  53874. colors?: Nullable<Color4[][]>;
  53875. useVertexAlpha?: boolean;
  53876. }, scene: Nullable<Scene>): LinesMesh;
  53877. /**
  53878. * Creates a line mesh
  53879. * 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
  53880. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53881. * * The parameter `points` is an array successive Vector3
  53882. * * 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
  53883. * * The optional parameter `colors` is an array of successive Color4, one per line point
  53884. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  53885. * * When updating an instance, remember that only point positions can change, not the number of points
  53886. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53887. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  53888. * @param name defines the name of the new line system
  53889. * @param options defines the options used to create the line system
  53890. * @param scene defines the hosting scene
  53891. * @returns a new line mesh
  53892. */
  53893. static CreateLines(name: string, options: {
  53894. points: Vector3[];
  53895. updatable?: boolean;
  53896. instance?: Nullable<LinesMesh>;
  53897. colors?: Color4[];
  53898. useVertexAlpha?: boolean;
  53899. }, scene?: Nullable<Scene>): LinesMesh;
  53900. /**
  53901. * Creates a dashed line mesh
  53902. * * 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
  53903. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  53904. * * The parameter `points` is an array successive Vector3
  53905. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  53906. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  53907. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  53908. * * 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
  53909. * * When updating an instance, remember that only point positions can change, not the number of points
  53910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53911. * @param name defines the name of the mesh
  53912. * @param options defines the options used to create the mesh
  53913. * @param scene defines the hosting scene
  53914. * @returns the dashed line mesh
  53915. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  53916. */
  53917. static CreateDashedLines(name: string, options: {
  53918. points: Vector3[];
  53919. dashSize?: number;
  53920. gapSize?: number;
  53921. dashNb?: number;
  53922. updatable?: boolean;
  53923. instance?: LinesMesh;
  53924. }, scene?: Nullable<Scene>): LinesMesh;
  53925. /**
  53926. * 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.
  53927. * * 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.
  53928. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53929. * * 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.
  53930. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53931. * * 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
  53932. * * 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
  53933. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53934. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53935. * * 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
  53936. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53937. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53938. * @param name defines the name of the mesh
  53939. * @param options defines the options used to create the mesh
  53940. * @param scene defines the hosting scene
  53941. * @returns the extruded shape mesh
  53942. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53944. */
  53945. static ExtrudeShape(name: string, options: {
  53946. shape: Vector3[];
  53947. path: Vector3[];
  53948. scale?: number;
  53949. rotation?: number;
  53950. cap?: number;
  53951. updatable?: boolean;
  53952. sideOrientation?: number;
  53953. frontUVs?: Vector4;
  53954. backUVs?: Vector4;
  53955. instance?: Mesh;
  53956. invertUV?: boolean;
  53957. }, scene?: Nullable<Scene>): Mesh;
  53958. /**
  53959. * Creates an custom extruded shape mesh.
  53960. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53961. * * 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.
  53962. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53963. * * 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
  53964. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53965. * * 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
  53966. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53967. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53968. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53969. * * 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
  53970. * * 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
  53971. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53973. * * 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
  53974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53975. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53976. * @param name defines the name of the mesh
  53977. * @param options defines the options used to create the mesh
  53978. * @param scene defines the hosting scene
  53979. * @returns the custom extruded shape mesh
  53980. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53981. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53982. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53983. */
  53984. static ExtrudeShapeCustom(name: string, options: {
  53985. shape: Vector3[];
  53986. path: Vector3[];
  53987. scaleFunction?: any;
  53988. rotationFunction?: any;
  53989. ribbonCloseArray?: boolean;
  53990. ribbonClosePath?: boolean;
  53991. cap?: number;
  53992. updatable?: boolean;
  53993. sideOrientation?: number;
  53994. frontUVs?: Vector4;
  53995. backUVs?: Vector4;
  53996. instance?: Mesh;
  53997. invertUV?: boolean;
  53998. }, scene?: Nullable<Scene>): Mesh;
  53999. /**
  54000. * Creates lathe mesh.
  54001. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  54002. * * 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
  54003. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  54004. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  54005. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  54006. * * 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
  54007. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  54008. * * 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
  54009. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54010. * * 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
  54011. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54012. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54013. * @param name defines the name of the mesh
  54014. * @param options defines the options used to create the mesh
  54015. * @param scene defines the hosting scene
  54016. * @returns the lathe mesh
  54017. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  54018. */
  54019. static CreateLathe(name: string, options: {
  54020. shape: Vector3[];
  54021. radius?: number;
  54022. tessellation?: number;
  54023. clip?: number;
  54024. arc?: number;
  54025. closed?: boolean;
  54026. updatable?: boolean;
  54027. sideOrientation?: number;
  54028. frontUVs?: Vector4;
  54029. backUVs?: Vector4;
  54030. cap?: number;
  54031. invertUV?: boolean;
  54032. }, scene?: Nullable<Scene>): Mesh;
  54033. /**
  54034. * Creates a tiled plane mesh
  54035. * * You can set a limited pattern arrangement with the tiles
  54036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54037. * * 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
  54038. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54039. * @param name defines the name of the mesh
  54040. * @param options defines the options used to create the mesh
  54041. * @param scene defines the hosting scene
  54042. * @returns the plane mesh
  54043. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54044. */
  54045. static CreateTiledPlane(name: string, options: {
  54046. pattern?: number;
  54047. tileSize?: number;
  54048. tileWidth?: number;
  54049. tileHeight?: number;
  54050. size?: number;
  54051. width?: number;
  54052. height?: number;
  54053. alignHorizontal?: number;
  54054. alignVertical?: number;
  54055. sideOrientation?: number;
  54056. frontUVs?: Vector4;
  54057. backUVs?: Vector4;
  54058. updatable?: boolean;
  54059. }, scene?: Nullable<Scene>): Mesh;
  54060. /**
  54061. * Creates a plane mesh
  54062. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  54063. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  54064. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  54065. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54066. * * 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
  54067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54068. * @param name defines the name of the mesh
  54069. * @param options defines the options used to create the mesh
  54070. * @param scene defines the hosting scene
  54071. * @returns the plane mesh
  54072. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  54073. */
  54074. static CreatePlane(name: string, options: {
  54075. size?: number;
  54076. width?: number;
  54077. height?: number;
  54078. sideOrientation?: number;
  54079. frontUVs?: Vector4;
  54080. backUVs?: Vector4;
  54081. updatable?: boolean;
  54082. sourcePlane?: Plane;
  54083. }, scene?: Nullable<Scene>): Mesh;
  54084. /**
  54085. * Creates a ground mesh
  54086. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  54087. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  54088. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54089. * @param name defines the name of the mesh
  54090. * @param options defines the options used to create the mesh
  54091. * @param scene defines the hosting scene
  54092. * @returns the ground mesh
  54093. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  54094. */
  54095. static CreateGround(name: string, options: {
  54096. width?: number;
  54097. height?: number;
  54098. subdivisions?: number;
  54099. subdivisionsX?: number;
  54100. subdivisionsY?: number;
  54101. updatable?: boolean;
  54102. }, scene?: Nullable<Scene>): Mesh;
  54103. /**
  54104. * Creates a tiled ground mesh
  54105. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  54106. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  54107. * * 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
  54108. * * 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
  54109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54110. * @param name defines the name of the mesh
  54111. * @param options defines the options used to create the mesh
  54112. * @param scene defines the hosting scene
  54113. * @returns the tiled ground mesh
  54114. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  54115. */
  54116. static CreateTiledGround(name: string, options: {
  54117. xmin: number;
  54118. zmin: number;
  54119. xmax: number;
  54120. zmax: number;
  54121. subdivisions?: {
  54122. w: number;
  54123. h: number;
  54124. };
  54125. precision?: {
  54126. w: number;
  54127. h: number;
  54128. };
  54129. updatable?: boolean;
  54130. }, scene?: Nullable<Scene>): Mesh;
  54131. /**
  54132. * Creates a ground mesh from a height map
  54133. * * The parameter `url` sets the URL of the height map image resource.
  54134. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  54135. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  54136. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  54137. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  54138. * * 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.
  54139. * * 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).
  54140. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  54141. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  54142. * @param name defines the name of the mesh
  54143. * @param url defines the url to the height map
  54144. * @param options defines the options used to create the mesh
  54145. * @param scene defines the hosting scene
  54146. * @returns the ground mesh
  54147. * @see https://doc.babylonjs.com/babylon101/height_map
  54148. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  54149. */
  54150. static CreateGroundFromHeightMap(name: string, url: string, options: {
  54151. width?: number;
  54152. height?: number;
  54153. subdivisions?: number;
  54154. minHeight?: number;
  54155. maxHeight?: number;
  54156. colorFilter?: Color3;
  54157. alphaFilter?: number;
  54158. updatable?: boolean;
  54159. onReady?: (mesh: GroundMesh) => void;
  54160. }, scene?: Nullable<Scene>): GroundMesh;
  54161. /**
  54162. * Creates a polygon mesh
  54163. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  54164. * * 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
  54165. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  54166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54167. * * 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)
  54168. * * Remember you can only change the shape positions, not their number when updating a polygon
  54169. * @param name defines the name of the mesh
  54170. * @param options defines the options used to create the mesh
  54171. * @param scene defines the hosting scene
  54172. * @param earcutInjection can be used to inject your own earcut reference
  54173. * @returns the polygon mesh
  54174. */
  54175. static CreatePolygon(name: string, options: {
  54176. shape: Vector3[];
  54177. holes?: Vector3[][];
  54178. depth?: number;
  54179. faceUV?: Vector4[];
  54180. faceColors?: Color4[];
  54181. updatable?: boolean;
  54182. sideOrientation?: number;
  54183. frontUVs?: Vector4;
  54184. backUVs?: Vector4;
  54185. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54186. /**
  54187. * Creates an extruded polygon mesh, with depth in the Y direction.
  54188. * * 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)
  54189. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  54190. * @param name defines the name of the mesh
  54191. * @param options defines the options used to create the mesh
  54192. * @param scene defines the hosting scene
  54193. * @param earcutInjection can be used to inject your own earcut reference
  54194. * @returns the polygon mesh
  54195. */
  54196. static ExtrudePolygon(name: string, options: {
  54197. shape: Vector3[];
  54198. holes?: Vector3[][];
  54199. depth?: number;
  54200. faceUV?: Vector4[];
  54201. faceColors?: Color4[];
  54202. updatable?: boolean;
  54203. sideOrientation?: number;
  54204. frontUVs?: Vector4;
  54205. backUVs?: Vector4;
  54206. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  54207. /**
  54208. * Creates a tube mesh.
  54209. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  54210. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  54211. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  54212. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  54213. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  54214. * * 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)
  54215. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  54216. * * 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
  54217. * * 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
  54218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54219. * * 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
  54220. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  54221. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54222. * @param name defines the name of the mesh
  54223. * @param options defines the options used to create the mesh
  54224. * @param scene defines the hosting scene
  54225. * @returns the tube mesh
  54226. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  54227. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  54228. */
  54229. static CreateTube(name: string, options: {
  54230. path: Vector3[];
  54231. radius?: number;
  54232. tessellation?: number;
  54233. radiusFunction?: {
  54234. (i: number, distance: number): number;
  54235. };
  54236. cap?: number;
  54237. arc?: number;
  54238. updatable?: boolean;
  54239. sideOrientation?: number;
  54240. frontUVs?: Vector4;
  54241. backUVs?: Vector4;
  54242. instance?: Mesh;
  54243. invertUV?: boolean;
  54244. }, scene?: Nullable<Scene>): Mesh;
  54245. /**
  54246. * Creates a polyhedron mesh
  54247. * * 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
  54248. * * The parameter `size` (positive float, default 1) sets the polygon size
  54249. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  54250. * * 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`
  54251. * * 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
  54252. * * 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)`)
  54253. * * 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
  54254. * * 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
  54255. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  54256. * * 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
  54257. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  54258. * @param name defines the name of the mesh
  54259. * @param options defines the options used to create the mesh
  54260. * @param scene defines the hosting scene
  54261. * @returns the polyhedron mesh
  54262. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  54263. */
  54264. static CreatePolyhedron(name: string, options: {
  54265. type?: number;
  54266. size?: number;
  54267. sizeX?: number;
  54268. sizeY?: number;
  54269. sizeZ?: number;
  54270. custom?: any;
  54271. faceUV?: Vector4[];
  54272. faceColors?: Color4[];
  54273. flat?: boolean;
  54274. updatable?: boolean;
  54275. sideOrientation?: number;
  54276. frontUVs?: Vector4;
  54277. backUVs?: Vector4;
  54278. }, scene?: Nullable<Scene>): Mesh;
  54279. /**
  54280. * Creates a decal mesh.
  54281. * 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
  54282. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  54283. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  54284. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  54285. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  54286. * @param name defines the name of the mesh
  54287. * @param sourceMesh defines the mesh where the decal must be applied
  54288. * @param options defines the options used to create the mesh
  54289. * @param scene defines the hosting scene
  54290. * @returns the decal mesh
  54291. * @see https://doc.babylonjs.com/how_to/decals
  54292. */
  54293. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  54294. position?: Vector3;
  54295. normal?: Vector3;
  54296. size?: Vector3;
  54297. angle?: number;
  54298. }): Mesh;
  54299. }
  54300. }
  54301. declare module BABYLON {
  54302. /**
  54303. * A simplifier interface for future simplification implementations
  54304. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54305. */
  54306. export interface ISimplifier {
  54307. /**
  54308. * Simplification of a given mesh according to the given settings.
  54309. * Since this requires computation, it is assumed that the function runs async.
  54310. * @param settings The settings of the simplification, including quality and distance
  54311. * @param successCallback A callback that will be called after the mesh was simplified.
  54312. * @param errorCallback in case of an error, this callback will be called. optional.
  54313. */
  54314. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  54315. }
  54316. /**
  54317. * Expected simplification settings.
  54318. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  54319. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54320. */
  54321. export interface ISimplificationSettings {
  54322. /**
  54323. * Gets or sets the expected quality
  54324. */
  54325. quality: number;
  54326. /**
  54327. * Gets or sets the distance when this optimized version should be used
  54328. */
  54329. distance: number;
  54330. /**
  54331. * Gets an already optimized mesh
  54332. */
  54333. optimizeMesh?: boolean;
  54334. }
  54335. /**
  54336. * Class used to specify simplification options
  54337. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54338. */
  54339. export class SimplificationSettings implements ISimplificationSettings {
  54340. /** expected quality */
  54341. quality: number;
  54342. /** distance when this optimized version should be used */
  54343. distance: number;
  54344. /** already optimized mesh */
  54345. optimizeMesh?: boolean | undefined;
  54346. /**
  54347. * Creates a SimplificationSettings
  54348. * @param quality expected quality
  54349. * @param distance distance when this optimized version should be used
  54350. * @param optimizeMesh already optimized mesh
  54351. */
  54352. constructor(
  54353. /** expected quality */
  54354. quality: number,
  54355. /** distance when this optimized version should be used */
  54356. distance: number,
  54357. /** already optimized mesh */
  54358. optimizeMesh?: boolean | undefined);
  54359. }
  54360. /**
  54361. * Interface used to define a simplification task
  54362. */
  54363. export interface ISimplificationTask {
  54364. /**
  54365. * Array of settings
  54366. */
  54367. settings: Array<ISimplificationSettings>;
  54368. /**
  54369. * Simplification type
  54370. */
  54371. simplificationType: SimplificationType;
  54372. /**
  54373. * Mesh to simplify
  54374. */
  54375. mesh: Mesh;
  54376. /**
  54377. * Callback called on success
  54378. */
  54379. successCallback?: () => void;
  54380. /**
  54381. * Defines if parallel processing can be used
  54382. */
  54383. parallelProcessing: boolean;
  54384. }
  54385. /**
  54386. * Queue used to order the simplification tasks
  54387. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54388. */
  54389. export class SimplificationQueue {
  54390. private _simplificationArray;
  54391. /**
  54392. * Gets a boolean indicating that the process is still running
  54393. */
  54394. running: boolean;
  54395. /**
  54396. * Creates a new queue
  54397. */
  54398. constructor();
  54399. /**
  54400. * Adds a new simplification task
  54401. * @param task defines a task to add
  54402. */
  54403. addTask(task: ISimplificationTask): void;
  54404. /**
  54405. * Execute next task
  54406. */
  54407. executeNext(): void;
  54408. /**
  54409. * Execute a simplification task
  54410. * @param task defines the task to run
  54411. */
  54412. runSimplification(task: ISimplificationTask): void;
  54413. private getSimplifier;
  54414. }
  54415. /**
  54416. * The implemented types of simplification
  54417. * At the moment only Quadratic Error Decimation is implemented
  54418. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54419. */
  54420. export enum SimplificationType {
  54421. /** Quadratic error decimation */
  54422. QUADRATIC = 0
  54423. }
  54424. }
  54425. declare module BABYLON {
  54426. interface Scene {
  54427. /** @hidden (Backing field) */ private _simplificationQueue: SimplificationQueue;
  54428. /**
  54429. * Gets or sets the simplification queue attached to the scene
  54430. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  54431. */
  54432. simplificationQueue: SimplificationQueue;
  54433. }
  54434. interface Mesh {
  54435. /**
  54436. * Simplify the mesh according to the given array of settings.
  54437. * Function will return immediately and will simplify async
  54438. * @param settings a collection of simplification settings
  54439. * @param parallelProcessing should all levels calculate parallel or one after the other
  54440. * @param simplificationType the type of simplification to run
  54441. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  54442. * @returns the current mesh
  54443. */
  54444. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  54445. }
  54446. /**
  54447. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  54448. * created in a scene
  54449. */
  54450. export class SimplicationQueueSceneComponent implements ISceneComponent {
  54451. /**
  54452. * The component name helpfull to identify the component in the list of scene components.
  54453. */
  54454. readonly name: string;
  54455. /**
  54456. * The scene the component belongs to.
  54457. */
  54458. scene: Scene;
  54459. /**
  54460. * Creates a new instance of the component for the given scene
  54461. * @param scene Defines the scene to register the component in
  54462. */
  54463. constructor(scene: Scene);
  54464. /**
  54465. * Registers the component in a given scene
  54466. */
  54467. register(): void;
  54468. /**
  54469. * Rebuilds the elements related to this component in case of
  54470. * context lost for instance.
  54471. */
  54472. rebuild(): void;
  54473. /**
  54474. * Disposes the component and the associated ressources
  54475. */
  54476. dispose(): void;
  54477. private _beforeCameraUpdate;
  54478. }
  54479. }
  54480. declare module BABYLON {
  54481. /**
  54482. * Navigation plugin interface to add navigation constrained by a navigation mesh
  54483. */
  54484. export interface INavigationEnginePlugin {
  54485. /**
  54486. * plugin name
  54487. */
  54488. name: string;
  54489. /**
  54490. * Creates a navigation mesh
  54491. * @param meshes array of all the geometry used to compute the navigatio mesh
  54492. * @param parameters bunch of parameters used to filter geometry
  54493. */
  54494. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54495. /**
  54496. * Create a navigation mesh debug mesh
  54497. * @param scene is where the mesh will be added
  54498. * @returns debug display mesh
  54499. */
  54500. createDebugNavMesh(scene: Scene): Mesh;
  54501. /**
  54502. * Get a navigation mesh constrained position, closest to the parameter position
  54503. * @param position world position
  54504. * @returns the closest point to position constrained by the navigation mesh
  54505. */
  54506. getClosestPoint(position: Vector3): Vector3;
  54507. /**
  54508. * Get a navigation mesh constrained position, within a particular radius
  54509. * @param position world position
  54510. * @param maxRadius the maximum distance to the constrained world position
  54511. * @returns the closest point to position constrained by the navigation mesh
  54512. */
  54513. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54514. /**
  54515. * Compute the final position from a segment made of destination-position
  54516. * @param position world position
  54517. * @param destination world position
  54518. * @returns the resulting point along the navmesh
  54519. */
  54520. moveAlong(position: Vector3, destination: Vector3): Vector3;
  54521. /**
  54522. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54523. * @param start world position
  54524. * @param end world position
  54525. * @returns array containing world position composing the path
  54526. */
  54527. computePath(start: Vector3, end: Vector3): Vector3[];
  54528. /**
  54529. * If this plugin is supported
  54530. * @returns true if plugin is supported
  54531. */
  54532. isSupported(): boolean;
  54533. /**
  54534. * Create a new Crowd so you can add agents
  54535. * @param maxAgents the maximum agent count in the crowd
  54536. * @param maxAgentRadius the maximum radius an agent can have
  54537. * @param scene to attach the crowd to
  54538. * @returns the crowd you can add agents to
  54539. */
  54540. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54541. /**
  54542. * Release all resources
  54543. */
  54544. dispose(): void;
  54545. }
  54546. /**
  54547. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  54548. */
  54549. export interface ICrowd {
  54550. /**
  54551. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54552. * You can attach anything to that node. The node position is updated in the scene update tick.
  54553. * @param pos world position that will be constrained by the navigation mesh
  54554. * @param parameters agent parameters
  54555. * @param transform hooked to the agent that will be update by the scene
  54556. * @returns agent index
  54557. */
  54558. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54559. /**
  54560. * Returns the agent position in world space
  54561. * @param index agent index returned by addAgent
  54562. * @returns world space position
  54563. */
  54564. getAgentPosition(index: number): Vector3;
  54565. /**
  54566. * Gets the agent velocity in world space
  54567. * @param index agent index returned by addAgent
  54568. * @returns world space velocity
  54569. */
  54570. getAgentVelocity(index: number): Vector3;
  54571. /**
  54572. * remove a particular agent previously created
  54573. * @param index agent index returned by addAgent
  54574. */
  54575. removeAgent(index: number): void;
  54576. /**
  54577. * get the list of all agents attached to this crowd
  54578. * @returns list of agent indices
  54579. */
  54580. getAgents(): number[];
  54581. /**
  54582. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54583. * @param deltaTime in seconds
  54584. */
  54585. update(deltaTime: number): void;
  54586. /**
  54587. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54588. * @param index agent index returned by addAgent
  54589. * @param destination targeted world position
  54590. */
  54591. agentGoto(index: number, destination: Vector3): void;
  54592. /**
  54593. * Release all resources
  54594. */
  54595. dispose(): void;
  54596. }
  54597. /**
  54598. * Configures an agent
  54599. */
  54600. export interface IAgentParameters {
  54601. /**
  54602. * Agent radius. [Limit: >= 0]
  54603. */
  54604. radius: number;
  54605. /**
  54606. * Agent height. [Limit: > 0]
  54607. */
  54608. height: number;
  54609. /**
  54610. * Maximum allowed acceleration. [Limit: >= 0]
  54611. */
  54612. maxAcceleration: number;
  54613. /**
  54614. * Maximum allowed speed. [Limit: >= 0]
  54615. */
  54616. maxSpeed: number;
  54617. /**
  54618. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  54619. */
  54620. collisionQueryRange: number;
  54621. /**
  54622. * The path visibility optimization range. [Limit: > 0]
  54623. */
  54624. pathOptimizationRange: number;
  54625. /**
  54626. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  54627. */
  54628. separationWeight: number;
  54629. }
  54630. /**
  54631. * Configures the navigation mesh creation
  54632. */
  54633. export interface INavMeshParameters {
  54634. /**
  54635. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  54636. */
  54637. cs: number;
  54638. /**
  54639. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  54640. */
  54641. ch: number;
  54642. /**
  54643. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  54644. */
  54645. walkableSlopeAngle: number;
  54646. /**
  54647. * Minimum floor to 'ceiling' height that will still allow the floor area to
  54648. * be considered walkable. [Limit: >= 3] [Units: vx]
  54649. */
  54650. walkableHeight: number;
  54651. /**
  54652. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  54653. */
  54654. walkableClimb: number;
  54655. /**
  54656. * The distance to erode/shrink the walkable area of the heightfield away from
  54657. * obstructions. [Limit: >=0] [Units: vx]
  54658. */
  54659. walkableRadius: number;
  54660. /**
  54661. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  54662. */
  54663. maxEdgeLen: number;
  54664. /**
  54665. * The maximum distance a simplfied contour's border edges should deviate
  54666. * the original raw contour. [Limit: >=0] [Units: vx]
  54667. */
  54668. maxSimplificationError: number;
  54669. /**
  54670. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  54671. */
  54672. minRegionArea: number;
  54673. /**
  54674. * Any regions with a span count smaller than this value will, if possible,
  54675. * be merged with larger regions. [Limit: >=0] [Units: vx]
  54676. */
  54677. mergeRegionArea: number;
  54678. /**
  54679. * The maximum number of vertices allowed for polygons generated during the
  54680. * contour to polygon conversion process. [Limit: >= 3]
  54681. */
  54682. maxVertsPerPoly: number;
  54683. /**
  54684. * Sets the sampling distance to use when generating the detail mesh.
  54685. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  54686. */
  54687. detailSampleDist: number;
  54688. /**
  54689. * The maximum distance the detail mesh surface should deviate from heightfield
  54690. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  54691. */
  54692. detailSampleMaxError: number;
  54693. }
  54694. }
  54695. declare module BABYLON {
  54696. /**
  54697. * RecastJS navigation plugin
  54698. */
  54699. export class RecastJSPlugin implements INavigationEnginePlugin {
  54700. /**
  54701. * Reference to the Recast library
  54702. */
  54703. bjsRECAST: any;
  54704. /**
  54705. * plugin name
  54706. */
  54707. name: string;
  54708. /**
  54709. * the first navmesh created. We might extend this to support multiple navmeshes
  54710. */
  54711. navMesh: any;
  54712. /**
  54713. * Initializes the recastJS plugin
  54714. * @param recastInjection can be used to inject your own recast reference
  54715. */
  54716. constructor(recastInjection?: any);
  54717. /**
  54718. * Creates a navigation mesh
  54719. * @param meshes array of all the geometry used to compute the navigatio mesh
  54720. * @param parameters bunch of parameters used to filter geometry
  54721. */
  54722. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  54723. /**
  54724. * Create a navigation mesh debug mesh
  54725. * @param scene is where the mesh will be added
  54726. * @returns debug display mesh
  54727. */
  54728. createDebugNavMesh(scene: Scene): Mesh;
  54729. /**
  54730. * Get a navigation mesh constrained position, closest to the parameter position
  54731. * @param position world position
  54732. * @returns the closest point to position constrained by the navigation mesh
  54733. */
  54734. getClosestPoint(position: Vector3): Vector3;
  54735. /**
  54736. * Get a navigation mesh constrained position, within a particular radius
  54737. * @param position world position
  54738. * @param maxRadius the maximum distance to the constrained world position
  54739. * @returns the closest point to position constrained by the navigation mesh
  54740. */
  54741. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  54742. /**
  54743. * Compute the final position from a segment made of destination-position
  54744. * @param position world position
  54745. * @param destination world position
  54746. * @returns the resulting point along the navmesh
  54747. */
  54748. moveAlong(position: Vector3, destination: Vector3): Vector3;
  54749. /**
  54750. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  54751. * @param start world position
  54752. * @param end world position
  54753. * @returns array containing world position composing the path
  54754. */
  54755. computePath(start: Vector3, end: Vector3): Vector3[];
  54756. /**
  54757. * Create a new Crowd so you can add agents
  54758. * @param maxAgents the maximum agent count in the crowd
  54759. * @param maxAgentRadius the maximum radius an agent can have
  54760. * @param scene to attach the crowd to
  54761. * @returns the crowd you can add agents to
  54762. */
  54763. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  54764. /**
  54765. * Disposes
  54766. */
  54767. dispose(): void;
  54768. /**
  54769. * If this plugin is supported
  54770. * @returns true if plugin is supported
  54771. */
  54772. isSupported(): boolean;
  54773. }
  54774. /**
  54775. * Recast detour crowd implementation
  54776. */
  54777. export class RecastJSCrowd implements ICrowd {
  54778. /**
  54779. * Recast/detour plugin
  54780. */
  54781. bjsRECASTPlugin: RecastJSPlugin;
  54782. /**
  54783. * Link to the detour crowd
  54784. */
  54785. recastCrowd: any;
  54786. /**
  54787. * One transform per agent
  54788. */
  54789. transforms: TransformNode[];
  54790. /**
  54791. * All agents created
  54792. */
  54793. agents: number[];
  54794. /**
  54795. * Link to the scene is kept to unregister the crowd from the scene
  54796. */
  54797. private _scene;
  54798. /**
  54799. * Observer for crowd updates
  54800. */
  54801. private _onBeforeAnimationsObserver;
  54802. /**
  54803. * Constructor
  54804. * @param plugin recastJS plugin
  54805. * @param maxAgents the maximum agent count in the crowd
  54806. * @param maxAgentRadius the maximum radius an agent can have
  54807. * @param scene to attach the crowd to
  54808. * @returns the crowd you can add agents to
  54809. */
  54810. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  54811. /**
  54812. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  54813. * You can attach anything to that node. The node position is updated in the scene update tick.
  54814. * @param pos world position that will be constrained by the navigation mesh
  54815. * @param parameters agent parameters
  54816. * @param transform hooked to the agent that will be update by the scene
  54817. * @returns agent index
  54818. */
  54819. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  54820. /**
  54821. * Returns the agent position in world space
  54822. * @param index agent index returned by addAgent
  54823. * @returns world space position
  54824. */
  54825. getAgentPosition(index: number): Vector3;
  54826. /**
  54827. * Returns the agent velocity in world space
  54828. * @param index agent index returned by addAgent
  54829. * @returns world space velocity
  54830. */
  54831. getAgentVelocity(index: number): Vector3;
  54832. /**
  54833. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  54834. * @param index agent index returned by addAgent
  54835. * @param destination targeted world position
  54836. */
  54837. agentGoto(index: number, destination: Vector3): void;
  54838. /**
  54839. * remove a particular agent previously created
  54840. * @param index agent index returned by addAgent
  54841. */
  54842. removeAgent(index: number): void;
  54843. /**
  54844. * get the list of all agents attached to this crowd
  54845. * @returns list of agent indices
  54846. */
  54847. getAgents(): number[];
  54848. /**
  54849. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  54850. * @param deltaTime in seconds
  54851. */
  54852. update(deltaTime: number): void;
  54853. /**
  54854. * Release all resources
  54855. */
  54856. dispose(): void;
  54857. }
  54858. }
  54859. declare module BABYLON {
  54860. /**
  54861. * Class used to enable access to IndexedDB
  54862. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  54863. */
  54864. export class Database implements IOfflineProvider {
  54865. private _callbackManifestChecked;
  54866. private _currentSceneUrl;
  54867. private _db;
  54868. private _enableSceneOffline;
  54869. private _enableTexturesOffline;
  54870. private _manifestVersionFound;
  54871. private _mustUpdateRessources;
  54872. private _hasReachedQuota;
  54873. private _isSupported;
  54874. private _idbFactory;
  54875. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  54876. private static IsUASupportingBlobStorage;
  54877. /**
  54878. * Gets a boolean indicating if Database storate is enabled (off by default)
  54879. */
  54880. static IDBStorageEnabled: boolean;
  54881. /**
  54882. * Gets a boolean indicating if scene must be saved in the database
  54883. */
  54884. readonly enableSceneOffline: boolean;
  54885. /**
  54886. * Gets a boolean indicating if textures must be saved in the database
  54887. */
  54888. readonly enableTexturesOffline: boolean;
  54889. /**
  54890. * Creates a new Database
  54891. * @param urlToScene defines the url to load the scene
  54892. * @param callbackManifestChecked defines the callback to use when manifest is checked
  54893. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  54894. */
  54895. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  54896. private static _ParseURL;
  54897. private static _ReturnFullUrlLocation;
  54898. private _checkManifestFile;
  54899. /**
  54900. * Open the database and make it available
  54901. * @param successCallback defines the callback to call on success
  54902. * @param errorCallback defines the callback to call on error
  54903. */
  54904. open(successCallback: () => void, errorCallback: () => void): void;
  54905. /**
  54906. * Loads an image from the database
  54907. * @param url defines the url to load from
  54908. * @param image defines the target DOM image
  54909. */
  54910. loadImage(url: string, image: HTMLImageElement): void;
  54911. private _loadImageFromDBAsync;
  54912. private _saveImageIntoDBAsync;
  54913. private _checkVersionFromDB;
  54914. private _loadVersionFromDBAsync;
  54915. private _saveVersionIntoDBAsync;
  54916. /**
  54917. * Loads a file from database
  54918. * @param url defines the URL to load from
  54919. * @param sceneLoaded defines a callback to call on success
  54920. * @param progressCallBack defines a callback to call when progress changed
  54921. * @param errorCallback defines a callback to call on error
  54922. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  54923. */
  54924. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  54925. private _loadFileAsync;
  54926. private _saveFileAsync;
  54927. /**
  54928. * Validates if xhr data is correct
  54929. * @param xhr defines the request to validate
  54930. * @param dataType defines the expected data type
  54931. * @returns true if data is correct
  54932. */
  54933. private static _ValidateXHRData;
  54934. }
  54935. }
  54936. declare module BABYLON {
  54937. /** @hidden */
  54938. export var gpuUpdateParticlesPixelShader: {
  54939. name: string;
  54940. shader: string;
  54941. };
  54942. }
  54943. declare module BABYLON {
  54944. /** @hidden */
  54945. export var gpuUpdateParticlesVertexShader: {
  54946. name: string;
  54947. shader: string;
  54948. };
  54949. }
  54950. declare module BABYLON {
  54951. /** @hidden */
  54952. export var clipPlaneFragmentDeclaration2: {
  54953. name: string;
  54954. shader: string;
  54955. };
  54956. }
  54957. declare module BABYLON {
  54958. /** @hidden */
  54959. export var gpuRenderParticlesPixelShader: {
  54960. name: string;
  54961. shader: string;
  54962. };
  54963. }
  54964. declare module BABYLON {
  54965. /** @hidden */
  54966. export var clipPlaneVertexDeclaration2: {
  54967. name: string;
  54968. shader: string;
  54969. };
  54970. }
  54971. declare module BABYLON {
  54972. /** @hidden */
  54973. export var gpuRenderParticlesVertexShader: {
  54974. name: string;
  54975. shader: string;
  54976. };
  54977. }
  54978. declare module BABYLON {
  54979. /**
  54980. * This represents a GPU particle system in Babylon
  54981. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  54982. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  54983. */
  54984. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  54985. /**
  54986. * The layer mask we are rendering the particles through.
  54987. */
  54988. layerMask: number;
  54989. private _capacity;
  54990. private _activeCount;
  54991. private _currentActiveCount;
  54992. private _accumulatedCount;
  54993. private _renderEffect;
  54994. private _updateEffect;
  54995. private _buffer0;
  54996. private _buffer1;
  54997. private _spriteBuffer;
  54998. private _updateVAO;
  54999. private _renderVAO;
  55000. private _targetIndex;
  55001. private _sourceBuffer;
  55002. private _targetBuffer;
  55003. private _engine;
  55004. private _currentRenderId;
  55005. private _started;
  55006. private _stopped;
  55007. private _timeDelta;
  55008. private _randomTexture;
  55009. private _randomTexture2;
  55010. private _attributesStrideSize;
  55011. private _updateEffectOptions;
  55012. private _randomTextureSize;
  55013. private _actualFrame;
  55014. private readonly _rawTextureWidth;
  55015. /**
  55016. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  55017. */
  55018. static readonly IsSupported: boolean;
  55019. /**
  55020. * An event triggered when the system is disposed.
  55021. */
  55022. onDisposeObservable: Observable<GPUParticleSystem>;
  55023. /**
  55024. * Gets the maximum number of particles active at the same time.
  55025. * @returns The max number of active particles.
  55026. */
  55027. getCapacity(): number;
  55028. /**
  55029. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  55030. * to override the particles.
  55031. */
  55032. forceDepthWrite: boolean;
  55033. /**
  55034. * Gets or set the number of active particles
  55035. */
  55036. activeParticleCount: number;
  55037. private _preWarmDone;
  55038. /**
  55039. * Is this system ready to be used/rendered
  55040. * @return true if the system is ready
  55041. */
  55042. isReady(): boolean;
  55043. /**
  55044. * Gets if the system has been started. (Note: this will still be true after stop is called)
  55045. * @returns True if it has been started, otherwise false.
  55046. */
  55047. isStarted(): boolean;
  55048. /**
  55049. * Starts the particle system and begins to emit
  55050. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  55051. */
  55052. start(delay?: number): void;
  55053. /**
  55054. * Stops the particle system.
  55055. */
  55056. stop(): void;
  55057. /**
  55058. * Remove all active particles
  55059. */
  55060. reset(): void;
  55061. /**
  55062. * Returns the string "GPUParticleSystem"
  55063. * @returns a string containing the class name
  55064. */
  55065. getClassName(): string;
  55066. private _colorGradientsTexture;
  55067. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  55068. /**
  55069. * Adds a new color gradient
  55070. * @param gradient defines the gradient to use (between 0 and 1)
  55071. * @param color1 defines the color to affect to the specified gradient
  55072. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  55073. * @returns the current particle system
  55074. */
  55075. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  55076. /**
  55077. * Remove a specific color gradient
  55078. * @param gradient defines the gradient to remove
  55079. * @returns the current particle system
  55080. */
  55081. removeColorGradient(gradient: number): GPUParticleSystem;
  55082. private _angularSpeedGradientsTexture;
  55083. private _sizeGradientsTexture;
  55084. private _velocityGradientsTexture;
  55085. private _limitVelocityGradientsTexture;
  55086. private _dragGradientsTexture;
  55087. private _addFactorGradient;
  55088. /**
  55089. * Adds a new size gradient
  55090. * @param gradient defines the gradient to use (between 0 and 1)
  55091. * @param factor defines the size factor to affect to the specified gradient
  55092. * @returns the current particle system
  55093. */
  55094. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  55095. /**
  55096. * Remove a specific size gradient
  55097. * @param gradient defines the gradient to remove
  55098. * @returns the current particle system
  55099. */
  55100. removeSizeGradient(gradient: number): GPUParticleSystem;
  55101. /**
  55102. * Adds a new angular speed gradient
  55103. * @param gradient defines the gradient to use (between 0 and 1)
  55104. * @param factor defines the angular speed to affect to the specified gradient
  55105. * @returns the current particle system
  55106. */
  55107. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  55108. /**
  55109. * Remove a specific angular speed gradient
  55110. * @param gradient defines the gradient to remove
  55111. * @returns the current particle system
  55112. */
  55113. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  55114. /**
  55115. * Adds a new velocity gradient
  55116. * @param gradient defines the gradient to use (between 0 and 1)
  55117. * @param factor defines the velocity to affect to the specified gradient
  55118. * @returns the current particle system
  55119. */
  55120. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55121. /**
  55122. * Remove a specific velocity gradient
  55123. * @param gradient defines the gradient to remove
  55124. * @returns the current particle system
  55125. */
  55126. removeVelocityGradient(gradient: number): GPUParticleSystem;
  55127. /**
  55128. * Adds a new limit velocity gradient
  55129. * @param gradient defines the gradient to use (between 0 and 1)
  55130. * @param factor defines the limit velocity value to affect to the specified gradient
  55131. * @returns the current particle system
  55132. */
  55133. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  55134. /**
  55135. * Remove a specific limit velocity gradient
  55136. * @param gradient defines the gradient to remove
  55137. * @returns the current particle system
  55138. */
  55139. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  55140. /**
  55141. * Adds a new drag gradient
  55142. * @param gradient defines the gradient to use (between 0 and 1)
  55143. * @param factor defines the drag value to affect to the specified gradient
  55144. * @returns the current particle system
  55145. */
  55146. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  55147. /**
  55148. * Remove a specific drag gradient
  55149. * @param gradient defines the gradient to remove
  55150. * @returns the current particle system
  55151. */
  55152. removeDragGradient(gradient: number): GPUParticleSystem;
  55153. /**
  55154. * Not supported by GPUParticleSystem
  55155. * @param gradient defines the gradient to use (between 0 and 1)
  55156. * @param factor defines the emit rate value to affect to the specified gradient
  55157. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55158. * @returns the current particle system
  55159. */
  55160. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55161. /**
  55162. * Not supported by GPUParticleSystem
  55163. * @param gradient defines the gradient to remove
  55164. * @returns the current particle system
  55165. */
  55166. removeEmitRateGradient(gradient: number): IParticleSystem;
  55167. /**
  55168. * Not supported by GPUParticleSystem
  55169. * @param gradient defines the gradient to use (between 0 and 1)
  55170. * @param factor defines the start size value to affect to the specified gradient
  55171. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55172. * @returns the current particle system
  55173. */
  55174. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55175. /**
  55176. * Not supported by GPUParticleSystem
  55177. * @param gradient defines the gradient to remove
  55178. * @returns the current particle system
  55179. */
  55180. removeStartSizeGradient(gradient: number): IParticleSystem;
  55181. /**
  55182. * Not supported by GPUParticleSystem
  55183. * @param gradient defines the gradient to use (between 0 and 1)
  55184. * @param min defines the color remap minimal range
  55185. * @param max defines the color remap maximal range
  55186. * @returns the current particle system
  55187. */
  55188. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55189. /**
  55190. * Not supported by GPUParticleSystem
  55191. * @param gradient defines the gradient to remove
  55192. * @returns the current particle system
  55193. */
  55194. removeColorRemapGradient(): IParticleSystem;
  55195. /**
  55196. * Not supported by GPUParticleSystem
  55197. * @param gradient defines the gradient to use (between 0 and 1)
  55198. * @param min defines the alpha remap minimal range
  55199. * @param max defines the alpha remap maximal range
  55200. * @returns the current particle system
  55201. */
  55202. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  55203. /**
  55204. * Not supported by GPUParticleSystem
  55205. * @param gradient defines the gradient to remove
  55206. * @returns the current particle system
  55207. */
  55208. removeAlphaRemapGradient(): IParticleSystem;
  55209. /**
  55210. * Not supported by GPUParticleSystem
  55211. * @param gradient defines the gradient to use (between 0 and 1)
  55212. * @param color defines the color to affect to the specified gradient
  55213. * @returns the current particle system
  55214. */
  55215. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  55216. /**
  55217. * Not supported by GPUParticleSystem
  55218. * @param gradient defines the gradient to remove
  55219. * @returns the current particle system
  55220. */
  55221. removeRampGradient(): IParticleSystem;
  55222. /**
  55223. * Not supported by GPUParticleSystem
  55224. * @returns the list of ramp gradients
  55225. */
  55226. getRampGradients(): Nullable<Array<Color3Gradient>>;
  55227. /**
  55228. * Not supported by GPUParticleSystem
  55229. * Gets or sets a boolean indicating that ramp gradients must be used
  55230. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  55231. */
  55232. useRampGradients: boolean;
  55233. /**
  55234. * Not supported by GPUParticleSystem
  55235. * @param gradient defines the gradient to use (between 0 and 1)
  55236. * @param factor defines the life time factor to affect to the specified gradient
  55237. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  55238. * @returns the current particle system
  55239. */
  55240. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  55241. /**
  55242. * Not supported by GPUParticleSystem
  55243. * @param gradient defines the gradient to remove
  55244. * @returns the current particle system
  55245. */
  55246. removeLifeTimeGradient(gradient: number): IParticleSystem;
  55247. /**
  55248. * Instantiates a GPU particle system.
  55249. * 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.
  55250. * @param name The name of the particle system
  55251. * @param options The options used to create the system
  55252. * @param scene The scene the particle system belongs to
  55253. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  55254. */
  55255. constructor(name: string, options: Partial<{
  55256. capacity: number;
  55257. randomTextureSize: number;
  55258. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  55259. protected _reset(): void;
  55260. private _createUpdateVAO;
  55261. private _createRenderVAO;
  55262. private _initialize;
  55263. /** @hidden */ private _recreateUpdateEffect(): void;
  55264. /** @hidden */ private _recreateRenderEffect(): void;
  55265. /**
  55266. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  55267. * @param preWarm defines if we are in the pre-warmimg phase
  55268. */
  55269. animate(preWarm?: boolean): void;
  55270. private _createFactorGradientTexture;
  55271. private _createSizeGradientTexture;
  55272. private _createAngularSpeedGradientTexture;
  55273. private _createVelocityGradientTexture;
  55274. private _createLimitVelocityGradientTexture;
  55275. private _createDragGradientTexture;
  55276. private _createColorGradientTexture;
  55277. /**
  55278. * Renders the particle system in its current state
  55279. * @param preWarm defines if the system should only update the particles but not render them
  55280. * @returns the current number of particles
  55281. */
  55282. render(preWarm?: boolean): number;
  55283. /**
  55284. * Rebuilds the particle system
  55285. */
  55286. rebuild(): void;
  55287. private _releaseBuffers;
  55288. private _releaseVAOs;
  55289. /**
  55290. * Disposes the particle system and free the associated resources
  55291. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  55292. */
  55293. dispose(disposeTexture?: boolean): void;
  55294. /**
  55295. * Clones the particle system.
  55296. * @param name The name of the cloned object
  55297. * @param newEmitter The new emitter to use
  55298. * @returns the cloned particle system
  55299. */
  55300. clone(name: string, newEmitter: any): GPUParticleSystem;
  55301. /**
  55302. * Serializes the particle system to a JSON object.
  55303. * @returns the JSON object
  55304. */
  55305. serialize(): any;
  55306. /**
  55307. * Parses a JSON object to create a GPU particle system.
  55308. * @param parsedParticleSystem The JSON object to parse
  55309. * @param scene The scene to create the particle system in
  55310. * @param rootUrl The root url to use to load external dependencies like texture
  55311. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  55312. * @returns the parsed GPU particle system
  55313. */
  55314. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  55315. }
  55316. }
  55317. declare module BABYLON {
  55318. /**
  55319. * Represents a set of particle systems working together to create a specific effect
  55320. */
  55321. export class ParticleSystemSet implements IDisposable {
  55322. private _emitterCreationOptions;
  55323. private _emitterNode;
  55324. /**
  55325. * Gets the particle system list
  55326. */
  55327. systems: IParticleSystem[];
  55328. /**
  55329. * Gets the emitter node used with this set
  55330. */
  55331. readonly emitterNode: Nullable<TransformNode>;
  55332. /**
  55333. * Creates a new emitter mesh as a sphere
  55334. * @param options defines the options used to create the sphere
  55335. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  55336. * @param scene defines the hosting scene
  55337. */
  55338. setEmitterAsSphere(options: {
  55339. diameter: number;
  55340. segments: number;
  55341. color: Color3;
  55342. }, renderingGroupId: number, scene: Scene): void;
  55343. /**
  55344. * Starts all particle systems of the set
  55345. * @param emitter defines an optional mesh to use as emitter for the particle systems
  55346. */
  55347. start(emitter?: AbstractMesh): void;
  55348. /**
  55349. * Release all associated resources
  55350. */
  55351. dispose(): void;
  55352. /**
  55353. * Serialize the set into a JSON compatible object
  55354. * @returns a JSON compatible representation of the set
  55355. */
  55356. serialize(): any;
  55357. /**
  55358. * Parse a new ParticleSystemSet from a serialized source
  55359. * @param data defines a JSON compatible representation of the set
  55360. * @param scene defines the hosting scene
  55361. * @param gpu defines if we want GPU particles or CPU particles
  55362. * @returns a new ParticleSystemSet
  55363. */
  55364. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  55365. }
  55366. }
  55367. declare module BABYLON {
  55368. /**
  55369. * This class is made for on one-liner static method to help creating particle system set.
  55370. */
  55371. export class ParticleHelper {
  55372. /**
  55373. * Gets or sets base Assets URL
  55374. */
  55375. static BaseAssetsUrl: string;
  55376. /**
  55377. * Create a default particle system that you can tweak
  55378. * @param emitter defines the emitter to use
  55379. * @param capacity defines the system capacity (default is 500 particles)
  55380. * @param scene defines the hosting scene
  55381. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  55382. * @returns the new Particle system
  55383. */
  55384. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  55385. /**
  55386. * This is the main static method (one-liner) of this helper to create different particle systems
  55387. * @param type This string represents the type to the particle system to create
  55388. * @param scene The scene where the particle system should live
  55389. * @param gpu If the system will use gpu
  55390. * @returns the ParticleSystemSet created
  55391. */
  55392. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  55393. /**
  55394. * Static function used to export a particle system to a ParticleSystemSet variable.
  55395. * Please note that the emitter shape is not exported
  55396. * @param systems defines the particle systems to export
  55397. * @returns the created particle system set
  55398. */
  55399. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  55400. }
  55401. }
  55402. declare module BABYLON {
  55403. interface Engine {
  55404. /**
  55405. * Create an effect to use with particle systems.
  55406. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  55407. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  55408. * @param uniformsNames defines a list of attribute names
  55409. * @param samplers defines an array of string used to represent textures
  55410. * @param defines defines the string containing the defines to use to compile the shaders
  55411. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  55412. * @param onCompiled defines a function to call when the effect creation is successful
  55413. * @param onError defines a function to call when the effect creation has failed
  55414. * @returns the new Effect
  55415. */
  55416. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  55417. }
  55418. interface Mesh {
  55419. /**
  55420. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  55421. * @returns an array of IParticleSystem
  55422. */
  55423. getEmittedParticleSystems(): IParticleSystem[];
  55424. /**
  55425. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  55426. * @returns an array of IParticleSystem
  55427. */
  55428. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  55429. }
  55430. /**
  55431. * @hidden
  55432. */
  55433. export var _IDoNeedToBeInTheBuild: number;
  55434. }
  55435. declare module BABYLON {
  55436. interface Scene {
  55437. /** @hidden (Backing field) */ private _physicsEngine: Nullable<IPhysicsEngine>;
  55438. /**
  55439. * Gets the current physics engine
  55440. * @returns a IPhysicsEngine or null if none attached
  55441. */
  55442. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  55443. /**
  55444. * Enables physics to the current scene
  55445. * @param gravity defines the scene's gravity for the physics engine
  55446. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  55447. * @return a boolean indicating if the physics engine was initialized
  55448. */
  55449. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  55450. /**
  55451. * Disables and disposes the physics engine associated with the scene
  55452. */
  55453. disablePhysicsEngine(): void;
  55454. /**
  55455. * Gets a boolean indicating if there is an active physics engine
  55456. * @returns a boolean indicating if there is an active physics engine
  55457. */
  55458. isPhysicsEnabled(): boolean;
  55459. /**
  55460. * Deletes a physics compound impostor
  55461. * @param compound defines the compound to delete
  55462. */
  55463. deleteCompoundImpostor(compound: any): void;
  55464. /**
  55465. * An event triggered when physic simulation is about to be run
  55466. */
  55467. onBeforePhysicsObservable: Observable<Scene>;
  55468. /**
  55469. * An event triggered when physic simulation has been done
  55470. */
  55471. onAfterPhysicsObservable: Observable<Scene>;
  55472. }
  55473. interface AbstractMesh {
  55474. /** @hidden */ private _physicsImpostor: Nullable<PhysicsImpostor>;
  55475. /**
  55476. * Gets or sets impostor used for physic simulation
  55477. * @see http://doc.babylonjs.com/features/physics_engine
  55478. */
  55479. physicsImpostor: Nullable<PhysicsImpostor>;
  55480. /**
  55481. * Gets the current physics impostor
  55482. * @see http://doc.babylonjs.com/features/physics_engine
  55483. * @returns a physics impostor or null
  55484. */
  55485. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  55486. /** Apply a physic impulse to the mesh
  55487. * @param force defines the force to apply
  55488. * @param contactPoint defines where to apply the force
  55489. * @returns the current mesh
  55490. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  55491. */
  55492. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  55493. /**
  55494. * Creates a physic joint between two meshes
  55495. * @param otherMesh defines the other mesh to use
  55496. * @param pivot1 defines the pivot to use on this mesh
  55497. * @param pivot2 defines the pivot to use on the other mesh
  55498. * @param options defines additional options (can be plugin dependent)
  55499. * @returns the current mesh
  55500. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  55501. */
  55502. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  55503. /** @hidden */ private _disposePhysicsObserver: Nullable<Observer<Node>>;
  55504. }
  55505. /**
  55506. * Defines the physics engine scene component responsible to manage a physics engine
  55507. */
  55508. export class PhysicsEngineSceneComponent implements ISceneComponent {
  55509. /**
  55510. * The component name helpful to identify the component in the list of scene components.
  55511. */
  55512. readonly name: string;
  55513. /**
  55514. * The scene the component belongs to.
  55515. */
  55516. scene: Scene;
  55517. /**
  55518. * Creates a new instance of the component for the given scene
  55519. * @param scene Defines the scene to register the component in
  55520. */
  55521. constructor(scene: Scene);
  55522. /**
  55523. * Registers the component in a given scene
  55524. */
  55525. register(): void;
  55526. /**
  55527. * Rebuilds the elements related to this component in case of
  55528. * context lost for instance.
  55529. */
  55530. rebuild(): void;
  55531. /**
  55532. * Disposes the component and the associated ressources
  55533. */
  55534. dispose(): void;
  55535. }
  55536. }
  55537. declare module BABYLON {
  55538. /**
  55539. * A helper for physics simulations
  55540. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55541. */
  55542. export class PhysicsHelper {
  55543. private _scene;
  55544. private _physicsEngine;
  55545. /**
  55546. * Initializes the Physics helper
  55547. * @param scene Babylon.js scene
  55548. */
  55549. constructor(scene: Scene);
  55550. /**
  55551. * Applies a radial explosion impulse
  55552. * @param origin the origin of the explosion
  55553. * @param radiusOrEventOptions the radius or the options of radial explosion
  55554. * @param strength the explosion strength
  55555. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55556. * @returns A physics radial explosion event, or null
  55557. */
  55558. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55559. /**
  55560. * Applies a radial explosion force
  55561. * @param origin the origin of the explosion
  55562. * @param radiusOrEventOptions the radius or the options of radial explosion
  55563. * @param strength the explosion strength
  55564. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55565. * @returns A physics radial explosion event, or null
  55566. */
  55567. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  55568. /**
  55569. * Creates a gravitational field
  55570. * @param origin the origin of the explosion
  55571. * @param radiusOrEventOptions the radius or the options of radial explosion
  55572. * @param strength the explosion strength
  55573. * @param falloff possible options: Constant & Linear. Defaults to Constant
  55574. * @returns A physics gravitational field event, or null
  55575. */
  55576. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  55577. /**
  55578. * Creates a physics updraft event
  55579. * @param origin the origin of the updraft
  55580. * @param radiusOrEventOptions the radius or the options of the updraft
  55581. * @param strength the strength of the updraft
  55582. * @param height the height of the updraft
  55583. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  55584. * @returns A physics updraft event, or null
  55585. */
  55586. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  55587. /**
  55588. * Creates a physics vortex event
  55589. * @param origin the of the vortex
  55590. * @param radiusOrEventOptions the radius or the options of the vortex
  55591. * @param strength the strength of the vortex
  55592. * @param height the height of the vortex
  55593. * @returns a Physics vortex event, or null
  55594. * A physics vortex event or null
  55595. */
  55596. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  55597. }
  55598. /**
  55599. * Represents a physics radial explosion event
  55600. */
  55601. class PhysicsRadialExplosionEvent {
  55602. private _scene;
  55603. private _options;
  55604. private _sphere;
  55605. private _dataFetched;
  55606. /**
  55607. * Initializes a radial explosioin event
  55608. * @param _scene BabylonJS scene
  55609. * @param _options The options for the vortex event
  55610. */
  55611. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  55612. /**
  55613. * Returns the data related to the radial explosion event (sphere).
  55614. * @returns The radial explosion event data
  55615. */
  55616. getData(): PhysicsRadialExplosionEventData;
  55617. /**
  55618. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  55619. * @param impostor A physics imposter
  55620. * @param origin the origin of the explosion
  55621. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  55622. */
  55623. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  55624. /**
  55625. * Triggers affecterd impostors callbacks
  55626. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  55627. */
  55628. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  55629. /**
  55630. * Disposes the sphere.
  55631. * @param force Specifies if the sphere should be disposed by force
  55632. */
  55633. dispose(force?: boolean): void;
  55634. /*** Helpers ***/
  55635. private _prepareSphere;
  55636. private _intersectsWithSphere;
  55637. }
  55638. /**
  55639. * Represents a gravitational field event
  55640. */
  55641. class PhysicsGravitationalFieldEvent {
  55642. private _physicsHelper;
  55643. private _scene;
  55644. private _origin;
  55645. private _options;
  55646. private _tickCallback;
  55647. private _sphere;
  55648. private _dataFetched;
  55649. /**
  55650. * Initializes the physics gravitational field event
  55651. * @param _physicsHelper A physics helper
  55652. * @param _scene BabylonJS scene
  55653. * @param _origin The origin position of the gravitational field event
  55654. * @param _options The options for the vortex event
  55655. */
  55656. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  55657. /**
  55658. * Returns the data related to the gravitational field event (sphere).
  55659. * @returns A gravitational field event
  55660. */
  55661. getData(): PhysicsGravitationalFieldEventData;
  55662. /**
  55663. * Enables the gravitational field.
  55664. */
  55665. enable(): void;
  55666. /**
  55667. * Disables the gravitational field.
  55668. */
  55669. disable(): void;
  55670. /**
  55671. * Disposes the sphere.
  55672. * @param force The force to dispose from the gravitational field event
  55673. */
  55674. dispose(force?: boolean): void;
  55675. private _tick;
  55676. }
  55677. /**
  55678. * Represents a physics updraft event
  55679. */
  55680. class PhysicsUpdraftEvent {
  55681. private _scene;
  55682. private _origin;
  55683. private _options;
  55684. private _physicsEngine;
  55685. private _originTop;
  55686. private _originDirection;
  55687. private _tickCallback;
  55688. private _cylinder;
  55689. private _cylinderPosition;
  55690. private _dataFetched;
  55691. /**
  55692. * Initializes the physics updraft event
  55693. * @param _scene BabylonJS scene
  55694. * @param _origin The origin position of the updraft
  55695. * @param _options The options for the updraft event
  55696. */
  55697. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  55698. /**
  55699. * Returns the data related to the updraft event (cylinder).
  55700. * @returns A physics updraft event
  55701. */
  55702. getData(): PhysicsUpdraftEventData;
  55703. /**
  55704. * Enables the updraft.
  55705. */
  55706. enable(): void;
  55707. /**
  55708. * Disables the updraft.
  55709. */
  55710. disable(): void;
  55711. /**
  55712. * Disposes the cylinder.
  55713. * @param force Specifies if the updraft should be disposed by force
  55714. */
  55715. dispose(force?: boolean): void;
  55716. private getImpostorHitData;
  55717. private _tick;
  55718. /*** Helpers ***/
  55719. private _prepareCylinder;
  55720. private _intersectsWithCylinder;
  55721. }
  55722. /**
  55723. * Represents a physics vortex event
  55724. */
  55725. class PhysicsVortexEvent {
  55726. private _scene;
  55727. private _origin;
  55728. private _options;
  55729. private _physicsEngine;
  55730. private _originTop;
  55731. private _tickCallback;
  55732. private _cylinder;
  55733. private _cylinderPosition;
  55734. private _dataFetched;
  55735. /**
  55736. * Initializes the physics vortex event
  55737. * @param _scene The BabylonJS scene
  55738. * @param _origin The origin position of the vortex
  55739. * @param _options The options for the vortex event
  55740. */
  55741. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  55742. /**
  55743. * Returns the data related to the vortex event (cylinder).
  55744. * @returns The physics vortex event data
  55745. */
  55746. getData(): PhysicsVortexEventData;
  55747. /**
  55748. * Enables the vortex.
  55749. */
  55750. enable(): void;
  55751. /**
  55752. * Disables the cortex.
  55753. */
  55754. disable(): void;
  55755. /**
  55756. * Disposes the sphere.
  55757. * @param force
  55758. */
  55759. dispose(force?: boolean): void;
  55760. private getImpostorHitData;
  55761. private _tick;
  55762. /*** Helpers ***/
  55763. private _prepareCylinder;
  55764. private _intersectsWithCylinder;
  55765. }
  55766. /**
  55767. * Options fot the radial explosion event
  55768. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55769. */
  55770. export class PhysicsRadialExplosionEventOptions {
  55771. /**
  55772. * The radius of the sphere for the radial explosion.
  55773. */
  55774. radius: number;
  55775. /**
  55776. * The strenth of the explosion.
  55777. */
  55778. strength: number;
  55779. /**
  55780. * The strenght of the force in correspondence to the distance of the affected object
  55781. */
  55782. falloff: PhysicsRadialImpulseFalloff;
  55783. /**
  55784. * Sphere options for the radial explosion.
  55785. */
  55786. sphere: {
  55787. segments: number;
  55788. diameter: number;
  55789. };
  55790. /**
  55791. * Sphere options for the radial explosion.
  55792. */
  55793. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  55794. }
  55795. /**
  55796. * Options fot the updraft event
  55797. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55798. */
  55799. export class PhysicsUpdraftEventOptions {
  55800. /**
  55801. * The radius of the cylinder for the vortex
  55802. */
  55803. radius: number;
  55804. /**
  55805. * The strenth of the updraft.
  55806. */
  55807. strength: number;
  55808. /**
  55809. * The height of the cylinder for the updraft.
  55810. */
  55811. height: number;
  55812. /**
  55813. * The mode for the the updraft.
  55814. */
  55815. updraftMode: PhysicsUpdraftMode;
  55816. }
  55817. /**
  55818. * Options fot the vortex event
  55819. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55820. */
  55821. export class PhysicsVortexEventOptions {
  55822. /**
  55823. * The radius of the cylinder for the vortex
  55824. */
  55825. radius: number;
  55826. /**
  55827. * The strenth of the vortex.
  55828. */
  55829. strength: number;
  55830. /**
  55831. * The height of the cylinder for the vortex.
  55832. */
  55833. height: number;
  55834. /**
  55835. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  55836. */
  55837. centripetalForceThreshold: number;
  55838. /**
  55839. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  55840. */
  55841. centripetalForceMultiplier: number;
  55842. /**
  55843. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  55844. */
  55845. centrifugalForceMultiplier: number;
  55846. /**
  55847. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  55848. */
  55849. updraftForceMultiplier: number;
  55850. }
  55851. /**
  55852. * The strenght of the force in correspondence to the distance of the affected object
  55853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55854. */
  55855. export enum PhysicsRadialImpulseFalloff {
  55856. /** Defines that impulse is constant in strength across it's whole radius */
  55857. Constant = 0,
  55858. /** Defines that impulse gets weaker if it's further from the origin */
  55859. Linear = 1
  55860. }
  55861. /**
  55862. * The strength of the force in correspondence to the distance of the affected object
  55863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55864. */
  55865. export enum PhysicsUpdraftMode {
  55866. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  55867. Center = 0,
  55868. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  55869. Perpendicular = 1
  55870. }
  55871. /**
  55872. * Interface for a physics hit data
  55873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55874. */
  55875. export interface PhysicsHitData {
  55876. /**
  55877. * The force applied at the contact point
  55878. */
  55879. force: Vector3;
  55880. /**
  55881. * The contact point
  55882. */
  55883. contactPoint: Vector3;
  55884. /**
  55885. * The distance from the origin to the contact point
  55886. */
  55887. distanceFromOrigin: number;
  55888. }
  55889. /**
  55890. * Interface for radial explosion event data
  55891. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55892. */
  55893. export interface PhysicsRadialExplosionEventData {
  55894. /**
  55895. * A sphere used for the radial explosion event
  55896. */
  55897. sphere: Mesh;
  55898. }
  55899. /**
  55900. * Interface for gravitational field event data
  55901. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55902. */
  55903. export interface PhysicsGravitationalFieldEventData {
  55904. /**
  55905. * A sphere mesh used for the gravitational field event
  55906. */
  55907. sphere: Mesh;
  55908. }
  55909. /**
  55910. * Interface for updraft event data
  55911. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55912. */
  55913. export interface PhysicsUpdraftEventData {
  55914. /**
  55915. * A cylinder used for the updraft event
  55916. */
  55917. cylinder: Mesh;
  55918. }
  55919. /**
  55920. * Interface for vortex event data
  55921. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55922. */
  55923. export interface PhysicsVortexEventData {
  55924. /**
  55925. * A cylinder used for the vortex event
  55926. */
  55927. cylinder: Mesh;
  55928. }
  55929. /**
  55930. * Interface for an affected physics impostor
  55931. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  55932. */
  55933. export interface PhysicsAffectedImpostorWithData {
  55934. /**
  55935. * The impostor affected by the effect
  55936. */
  55937. impostor: PhysicsImpostor;
  55938. /**
  55939. * The data about the hit/horce from the explosion
  55940. */
  55941. hitData: PhysicsHitData;
  55942. }
  55943. }
  55944. declare module BABYLON {
  55945. /** @hidden */
  55946. export var blackAndWhitePixelShader: {
  55947. name: string;
  55948. shader: string;
  55949. };
  55950. }
  55951. declare module BABYLON {
  55952. /**
  55953. * Post process used to render in black and white
  55954. */
  55955. export class BlackAndWhitePostProcess extends PostProcess {
  55956. /**
  55957. * Linear about to convert he result to black and white (default: 1)
  55958. */
  55959. degree: number;
  55960. /**
  55961. * Creates a black and white post process
  55962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  55963. * @param name The name of the effect.
  55964. * @param options The required width/height ratio to downsize to before computing the render pass.
  55965. * @param camera The camera to apply the render pass to.
  55966. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55967. * @param engine The engine which the post process will be applied. (default: current engine)
  55968. * @param reusable If the post process can be reused on the same frame. (default: false)
  55969. */
  55970. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55971. }
  55972. }
  55973. declare module BABYLON {
  55974. /**
  55975. * This represents a set of one or more post processes in Babylon.
  55976. * A post process can be used to apply a shader to a texture after it is rendered.
  55977. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55978. */
  55979. export class PostProcessRenderEffect {
  55980. private _postProcesses;
  55981. private _getPostProcesses;
  55982. private _singleInstance;
  55983. private _cameras;
  55984. private _indicesForCamera;
  55985. /**
  55986. * Name of the effect
  55987. * @hidden
  55988. */ private _name: string;
  55989. /**
  55990. * Instantiates a post process render effect.
  55991. * A post process can be used to apply a shader to a texture after it is rendered.
  55992. * @param engine The engine the effect is tied to
  55993. * @param name The name of the effect
  55994. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  55995. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  55996. */
  55997. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  55998. /**
  55999. * Checks if all the post processes in the effect are supported.
  56000. */
  56001. readonly isSupported: boolean;
  56002. /**
  56003. * Updates the current state of the effect
  56004. * @hidden
  56005. */ private _update(): void;
  56006. /**
  56007. * Attaches the effect on cameras
  56008. * @param cameras The camera to attach to.
  56009. * @hidden
  56010. */ private _attachCameras(cameras: Camera): void;
  56011. /**
  56012. * Attaches the effect on cameras
  56013. * @param cameras The camera to attach to.
  56014. * @hidden
  56015. */ private _attachCameras(cameras: Camera[]): void;
  56016. /**
  56017. * Detaches the effect on cameras
  56018. * @param cameras The camera to detatch from.
  56019. * @hidden
  56020. */ private _detachCameras(cameras: Camera): void;
  56021. /**
  56022. * Detatches the effect on cameras
  56023. * @param cameras The camera to detatch from.
  56024. * @hidden
  56025. */ private _detachCameras(cameras: Camera[]): void;
  56026. /**
  56027. * Enables the effect on given cameras
  56028. * @param cameras The camera to enable.
  56029. * @hidden
  56030. */ private _enable(cameras: Camera): void;
  56031. /**
  56032. * Enables the effect on given cameras
  56033. * @param cameras The camera to enable.
  56034. * @hidden
  56035. */ private _enable(cameras: Nullable<Camera[]>): void;
  56036. /**
  56037. * Disables the effect on the given cameras
  56038. * @param cameras The camera to disable.
  56039. * @hidden
  56040. */ private _disable(cameras: Camera): void;
  56041. /**
  56042. * Disables the effect on the given cameras
  56043. * @param cameras The camera to disable.
  56044. * @hidden
  56045. */ private _disable(cameras: Nullable<Camera[]>): void;
  56046. /**
  56047. * Gets a list of the post processes contained in the effect.
  56048. * @param camera The camera to get the post processes on.
  56049. * @returns The list of the post processes in the effect.
  56050. */
  56051. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  56052. }
  56053. }
  56054. declare module BABYLON {
  56055. /** @hidden */
  56056. export var extractHighlightsPixelShader: {
  56057. name: string;
  56058. shader: string;
  56059. };
  56060. }
  56061. declare module BABYLON {
  56062. /**
  56063. * 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.
  56064. */
  56065. export class ExtractHighlightsPostProcess extends PostProcess {
  56066. /**
  56067. * The luminance threshold, pixels below this value will be set to black.
  56068. */
  56069. threshold: number;
  56070. /** @hidden */ private _exposure: number;
  56071. /**
  56072. * Post process which has the input texture to be used when performing highlight extraction
  56073. * @hidden
  56074. */ private _inputPostProcess: Nullable<PostProcess>;
  56075. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56076. }
  56077. }
  56078. declare module BABYLON {
  56079. /** @hidden */
  56080. export var bloomMergePixelShader: {
  56081. name: string;
  56082. shader: string;
  56083. };
  56084. }
  56085. declare module BABYLON {
  56086. /**
  56087. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56088. */
  56089. export class BloomMergePostProcess extends PostProcess {
  56090. /** Weight of the bloom to be added to the original input. */
  56091. weight: number;
  56092. /**
  56093. * Creates a new instance of @see BloomMergePostProcess
  56094. * @param name The name of the effect.
  56095. * @param originalFromInput Post process which's input will be used for the merge.
  56096. * @param blurred Blurred highlights post process which's output will be used.
  56097. * @param weight Weight of the bloom to be added to the original input.
  56098. * @param options The required width/height ratio to downsize to before computing the render pass.
  56099. * @param camera The camera to apply the render pass to.
  56100. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56101. * @param engine The engine which the post process will be applied. (default: current engine)
  56102. * @param reusable If the post process can be reused on the same frame. (default: false)
  56103. * @param textureType Type of textures used when performing the post process. (default: 0)
  56104. * @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)
  56105. */
  56106. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  56107. /** Weight of the bloom to be added to the original input. */
  56108. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56109. }
  56110. }
  56111. declare module BABYLON {
  56112. /**
  56113. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  56114. */
  56115. export class BloomEffect extends PostProcessRenderEffect {
  56116. private bloomScale;
  56117. /**
  56118. * @hidden Internal
  56119. */ private _effects: Array<PostProcess>;
  56120. /**
  56121. * @hidden Internal
  56122. */ private _downscale: ExtractHighlightsPostProcess;
  56123. private _blurX;
  56124. private _blurY;
  56125. private _merge;
  56126. /**
  56127. * The luminance threshold to find bright areas of the image to bloom.
  56128. */
  56129. threshold: number;
  56130. /**
  56131. * The strength of the bloom.
  56132. */
  56133. weight: number;
  56134. /**
  56135. * Specifies the size of the bloom blur kernel, relative to the final output size
  56136. */
  56137. kernel: number;
  56138. /**
  56139. * Creates a new instance of @see BloomEffect
  56140. * @param scene The scene the effect belongs to.
  56141. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  56142. * @param bloomKernel The size of the kernel to be used when applying the blur.
  56143. * @param bloomWeight The the strength of bloom.
  56144. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56145. * @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)
  56146. */
  56147. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  56148. /**
  56149. * Disposes each of the internal effects for a given camera.
  56150. * @param camera The camera to dispose the effect on.
  56151. */
  56152. disposeEffects(camera: Camera): void;
  56153. /**
  56154. * @hidden Internal
  56155. */ private _updateEffects(): void;
  56156. /**
  56157. * Internal
  56158. * @returns if all the contained post processes are ready.
  56159. * @hidden
  56160. */ private _isReady(): boolean;
  56161. }
  56162. }
  56163. declare module BABYLON {
  56164. /** @hidden */
  56165. export var chromaticAberrationPixelShader: {
  56166. name: string;
  56167. shader: string;
  56168. };
  56169. }
  56170. declare module BABYLON {
  56171. /**
  56172. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  56173. */
  56174. export class ChromaticAberrationPostProcess extends PostProcess {
  56175. /**
  56176. * The amount of seperation of rgb channels (default: 30)
  56177. */
  56178. aberrationAmount: number;
  56179. /**
  56180. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  56181. */
  56182. radialIntensity: number;
  56183. /**
  56184. * 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))
  56185. */
  56186. direction: Vector2;
  56187. /**
  56188. * 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))
  56189. */
  56190. centerPosition: Vector2;
  56191. /**
  56192. * Creates a new instance ChromaticAberrationPostProcess
  56193. * @param name The name of the effect.
  56194. * @param screenWidth The width of the screen to apply the effect on.
  56195. * @param screenHeight The height of the screen to apply the effect on.
  56196. * @param options The required width/height ratio to downsize to before computing the render pass.
  56197. * @param camera The camera to apply the render pass to.
  56198. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56199. * @param engine The engine which the post process will be applied. (default: current engine)
  56200. * @param reusable If the post process can be reused on the same frame. (default: false)
  56201. * @param textureType Type of textures used when performing the post process. (default: 0)
  56202. * @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)
  56203. */
  56204. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56205. }
  56206. }
  56207. declare module BABYLON {
  56208. /** @hidden */
  56209. export var circleOfConfusionPixelShader: {
  56210. name: string;
  56211. shader: string;
  56212. };
  56213. }
  56214. declare module BABYLON {
  56215. /**
  56216. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  56217. */
  56218. export class CircleOfConfusionPostProcess extends PostProcess {
  56219. /**
  56220. * 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.
  56221. */
  56222. lensSize: number;
  56223. /**
  56224. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56225. */
  56226. fStop: number;
  56227. /**
  56228. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56229. */
  56230. focusDistance: number;
  56231. /**
  56232. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  56233. */
  56234. focalLength: number;
  56235. private _depthTexture;
  56236. /**
  56237. * Creates a new instance CircleOfConfusionPostProcess
  56238. * @param name The name of the effect.
  56239. * @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.
  56240. * @param options The required width/height ratio to downsize to before computing the render pass.
  56241. * @param camera The camera to apply the render pass to.
  56242. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56243. * @param engine The engine which the post process will be applied. (default: current engine)
  56244. * @param reusable If the post process can be reused on the same frame. (default: false)
  56245. * @param textureType Type of textures used when performing the post process. (default: 0)
  56246. * @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)
  56247. */
  56248. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56249. /**
  56250. * 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.
  56251. */
  56252. depthTexture: RenderTargetTexture;
  56253. }
  56254. }
  56255. declare module BABYLON {
  56256. /** @hidden */
  56257. export var colorCorrectionPixelShader: {
  56258. name: string;
  56259. shader: string;
  56260. };
  56261. }
  56262. declare module BABYLON {
  56263. /**
  56264. *
  56265. * This post-process allows the modification of rendered colors by using
  56266. * a 'look-up table' (LUT). This effect is also called Color Grading.
  56267. *
  56268. * The object needs to be provided an url to a texture containing the color
  56269. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  56270. * Use an image editing software to tweak the LUT to match your needs.
  56271. *
  56272. * For an example of a color LUT, see here:
  56273. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  56274. * For explanations on color grading, see here:
  56275. * @see http://udn.epicgames.com/Three/ColorGrading.html
  56276. *
  56277. */
  56278. export class ColorCorrectionPostProcess extends PostProcess {
  56279. private _colorTableTexture;
  56280. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56281. }
  56282. }
  56283. declare module BABYLON {
  56284. /** @hidden */
  56285. export var convolutionPixelShader: {
  56286. name: string;
  56287. shader: string;
  56288. };
  56289. }
  56290. declare module BABYLON {
  56291. /**
  56292. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  56293. * input texture to perform effects such as edge detection or sharpening
  56294. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56295. */
  56296. export class ConvolutionPostProcess extends PostProcess {
  56297. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56298. kernel: number[];
  56299. /**
  56300. * Creates a new instance ConvolutionPostProcess
  56301. * @param name The name of the effect.
  56302. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  56303. * @param options The required width/height ratio to downsize to before computing the render pass.
  56304. * @param camera The camera to apply the render pass to.
  56305. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56306. * @param engine The engine which the post process will be applied. (default: current engine)
  56307. * @param reusable If the post process can be reused on the same frame. (default: false)
  56308. * @param textureType Type of textures used when performing the post process. (default: 0)
  56309. */
  56310. constructor(name: string,
  56311. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  56312. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56313. /**
  56314. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56315. */
  56316. static EdgeDetect0Kernel: number[];
  56317. /**
  56318. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56319. */
  56320. static EdgeDetect1Kernel: number[];
  56321. /**
  56322. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56323. */
  56324. static EdgeDetect2Kernel: number[];
  56325. /**
  56326. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56327. */
  56328. static SharpenKernel: number[];
  56329. /**
  56330. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56331. */
  56332. static EmbossKernel: number[];
  56333. /**
  56334. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  56335. */
  56336. static GaussianKernel: number[];
  56337. }
  56338. }
  56339. declare module BABYLON {
  56340. /**
  56341. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  56342. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  56343. * based on samples that have a large difference in distance than the center pixel.
  56344. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  56345. */
  56346. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  56347. direction: Vector2;
  56348. /**
  56349. * Creates a new instance CircleOfConfusionPostProcess
  56350. * @param name The name of the effect.
  56351. * @param scene The scene the effect belongs to.
  56352. * @param direction The direction the blur should be applied.
  56353. * @param kernel The size of the kernel used to blur.
  56354. * @param options The required width/height ratio to downsize to before computing the render pass.
  56355. * @param camera The camera to apply the render pass to.
  56356. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  56357. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  56358. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56359. * @param engine The engine which the post process will be applied. (default: current engine)
  56360. * @param reusable If the post process can be reused on the same frame. (default: false)
  56361. * @param textureType Type of textures used when performing the post process. (default: 0)
  56362. * @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)
  56363. */
  56364. 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);
  56365. }
  56366. }
  56367. declare module BABYLON {
  56368. /** @hidden */
  56369. export var depthOfFieldMergePixelShader: {
  56370. name: string;
  56371. shader: string;
  56372. };
  56373. }
  56374. declare module BABYLON {
  56375. /**
  56376. * Options to be set when merging outputs from the default pipeline.
  56377. */
  56378. export class DepthOfFieldMergePostProcessOptions {
  56379. /**
  56380. * The original image to merge on top of
  56381. */
  56382. originalFromInput: PostProcess;
  56383. /**
  56384. * Parameters to perform the merge of the depth of field effect
  56385. */
  56386. depthOfField?: {
  56387. circleOfConfusion: PostProcess;
  56388. blurSteps: Array<PostProcess>;
  56389. };
  56390. /**
  56391. * Parameters to perform the merge of bloom effect
  56392. */
  56393. bloom?: {
  56394. blurred: PostProcess;
  56395. weight: number;
  56396. };
  56397. }
  56398. /**
  56399. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  56400. */
  56401. export class DepthOfFieldMergePostProcess extends PostProcess {
  56402. private blurSteps;
  56403. /**
  56404. * Creates a new instance of DepthOfFieldMergePostProcess
  56405. * @param name The name of the effect.
  56406. * @param originalFromInput Post process which's input will be used for the merge.
  56407. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  56408. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  56409. * @param options The required width/height ratio to downsize to before computing the render pass.
  56410. * @param camera The camera to apply the render pass to.
  56411. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56412. * @param engine The engine which the post process will be applied. (default: current engine)
  56413. * @param reusable If the post process can be reused on the same frame. (default: false)
  56414. * @param textureType Type of textures used when performing the post process. (default: 0)
  56415. * @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)
  56416. */
  56417. 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);
  56418. /**
  56419. * Updates the effect with the current post process compile time values and recompiles the shader.
  56420. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  56421. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  56422. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  56423. * @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
  56424. * @param onCompiled Called when the shader has been compiled.
  56425. * @param onError Called if there is an error when compiling a shader.
  56426. */
  56427. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  56428. }
  56429. }
  56430. declare module BABYLON {
  56431. /**
  56432. * Specifies the level of max blur that should be applied when using the depth of field effect
  56433. */
  56434. export enum DepthOfFieldEffectBlurLevel {
  56435. /**
  56436. * Subtle blur
  56437. */
  56438. Low = 0,
  56439. /**
  56440. * Medium blur
  56441. */
  56442. Medium = 1,
  56443. /**
  56444. * Large blur
  56445. */
  56446. High = 2
  56447. }
  56448. /**
  56449. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  56450. */
  56451. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  56452. private _circleOfConfusion;
  56453. /**
  56454. * @hidden Internal, blurs from high to low
  56455. */ private _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  56456. private _depthOfFieldBlurY;
  56457. private _dofMerge;
  56458. /**
  56459. * @hidden Internal post processes in depth of field effect
  56460. */ private _effects: Array<PostProcess>;
  56461. /**
  56462. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  56463. */
  56464. focalLength: number;
  56465. /**
  56466. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  56467. */
  56468. fStop: number;
  56469. /**
  56470. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  56471. */
  56472. focusDistance: number;
  56473. /**
  56474. * 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.
  56475. */
  56476. lensSize: number;
  56477. /**
  56478. * Creates a new instance DepthOfFieldEffect
  56479. * @param scene The scene the effect belongs to.
  56480. * @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.
  56481. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  56482. * @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)
  56483. */
  56484. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  56485. /**
  56486. * Get the current class name of the current effet
  56487. * @returns "DepthOfFieldEffect"
  56488. */
  56489. getClassName(): string;
  56490. /**
  56491. * 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.
  56492. */
  56493. depthTexture: RenderTargetTexture;
  56494. /**
  56495. * Disposes each of the internal effects for a given camera.
  56496. * @param camera The camera to dispose the effect on.
  56497. */
  56498. disposeEffects(camera: Camera): void;
  56499. /**
  56500. * @hidden Internal
  56501. */ private _updateEffects(): void;
  56502. /**
  56503. * Internal
  56504. * @returns if all the contained post processes are ready.
  56505. * @hidden
  56506. */ private _isReady(): boolean;
  56507. }
  56508. }
  56509. declare module BABYLON {
  56510. /** @hidden */
  56511. export var displayPassPixelShader: {
  56512. name: string;
  56513. shader: string;
  56514. };
  56515. }
  56516. declare module BABYLON {
  56517. /**
  56518. * DisplayPassPostProcess which produces an output the same as it's input
  56519. */
  56520. export class DisplayPassPostProcess extends PostProcess {
  56521. /**
  56522. * Creates the DisplayPassPostProcess
  56523. * @param name The name of the effect.
  56524. * @param options The required width/height ratio to downsize to before computing the render pass.
  56525. * @param camera The camera to apply the render pass to.
  56526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56527. * @param engine The engine which the post process will be applied. (default: current engine)
  56528. * @param reusable If the post process can be reused on the same frame. (default: false)
  56529. */
  56530. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56531. }
  56532. }
  56533. declare module BABYLON {
  56534. /** @hidden */
  56535. export var filterPixelShader: {
  56536. name: string;
  56537. shader: string;
  56538. };
  56539. }
  56540. declare module BABYLON {
  56541. /**
  56542. * Applies a kernel filter to the image
  56543. */
  56544. export class FilterPostProcess extends PostProcess {
  56545. /** The matrix to be applied to the image */
  56546. kernelMatrix: Matrix;
  56547. /**
  56548. *
  56549. * @param name The name of the effect.
  56550. * @param kernelMatrix The matrix to be applied to the image
  56551. * @param options The required width/height ratio to downsize to before computing the render pass.
  56552. * @param camera The camera to apply the render pass to.
  56553. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56554. * @param engine The engine which the post process will be applied. (default: current engine)
  56555. * @param reusable If the post process can be reused on the same frame. (default: false)
  56556. */
  56557. constructor(name: string,
  56558. /** The matrix to be applied to the image */
  56559. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56560. }
  56561. }
  56562. declare module BABYLON {
  56563. /** @hidden */
  56564. export var fxaaPixelShader: {
  56565. name: string;
  56566. shader: string;
  56567. };
  56568. }
  56569. declare module BABYLON {
  56570. /** @hidden */
  56571. export var fxaaVertexShader: {
  56572. name: string;
  56573. shader: string;
  56574. };
  56575. }
  56576. declare module BABYLON {
  56577. /**
  56578. * Fxaa post process
  56579. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  56580. */
  56581. export class FxaaPostProcess extends PostProcess {
  56582. /** @hidden */
  56583. texelWidth: number;
  56584. /** @hidden */
  56585. texelHeight: number;
  56586. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56587. private _getDefines;
  56588. }
  56589. }
  56590. declare module BABYLON {
  56591. /** @hidden */
  56592. export var grainPixelShader: {
  56593. name: string;
  56594. shader: string;
  56595. };
  56596. }
  56597. declare module BABYLON {
  56598. /**
  56599. * The GrainPostProcess adds noise to the image at mid luminance levels
  56600. */
  56601. export class GrainPostProcess extends PostProcess {
  56602. /**
  56603. * The intensity of the grain added (default: 30)
  56604. */
  56605. intensity: number;
  56606. /**
  56607. * If the grain should be randomized on every frame
  56608. */
  56609. animated: boolean;
  56610. /**
  56611. * Creates a new instance of @see GrainPostProcess
  56612. * @param name The name of the effect.
  56613. * @param options The required width/height ratio to downsize to before computing the render pass.
  56614. * @param camera The camera to apply the render pass to.
  56615. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56616. * @param engine The engine which the post process will be applied. (default: current engine)
  56617. * @param reusable If the post process can be reused on the same frame. (default: false)
  56618. * @param textureType Type of textures used when performing the post process. (default: 0)
  56619. * @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)
  56620. */
  56621. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56622. }
  56623. }
  56624. declare module BABYLON {
  56625. /** @hidden */
  56626. export var highlightsPixelShader: {
  56627. name: string;
  56628. shader: string;
  56629. };
  56630. }
  56631. declare module BABYLON {
  56632. /**
  56633. * Extracts highlights from the image
  56634. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56635. */
  56636. export class HighlightsPostProcess extends PostProcess {
  56637. /**
  56638. * Extracts highlights from the image
  56639. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  56640. * @param name The name of the effect.
  56641. * @param options The required width/height ratio to downsize to before computing the render pass.
  56642. * @param camera The camera to apply the render pass to.
  56643. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56644. * @param engine The engine which the post process will be applied. (default: current engine)
  56645. * @param reusable If the post process can be reused on the same frame. (default: false)
  56646. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  56647. */
  56648. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  56649. }
  56650. }
  56651. declare module BABYLON {
  56652. /** @hidden */
  56653. export var mrtFragmentDeclaration: {
  56654. name: string;
  56655. shader: string;
  56656. };
  56657. }
  56658. declare module BABYLON {
  56659. /** @hidden */
  56660. export var geometryPixelShader: {
  56661. name: string;
  56662. shader: string;
  56663. };
  56664. }
  56665. declare module BABYLON {
  56666. /** @hidden */
  56667. export var geometryVertexShader: {
  56668. name: string;
  56669. shader: string;
  56670. };
  56671. }
  56672. declare module BABYLON {
  56673. /** @hidden */
  56674. interface ISavedTransformationMatrix {
  56675. world: Matrix;
  56676. viewProjection: Matrix;
  56677. }
  56678. /**
  56679. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  56680. */
  56681. export class GeometryBufferRenderer {
  56682. /**
  56683. * Constant used to retrieve the position texture index in the G-Buffer textures array
  56684. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  56685. */
  56686. static readonly POSITION_TEXTURE_TYPE: number;
  56687. /**
  56688. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  56689. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  56690. */
  56691. static readonly VELOCITY_TEXTURE_TYPE: number;
  56692. /**
  56693. * Dictionary used to store the previous transformation matrices of each rendered mesh
  56694. * in order to compute objects velocities when enableVelocity is set to "true"
  56695. * @hidden
  56696. */ private _previousTransformationMatrices: {
  56697. [index: number]: ISavedTransformationMatrix;
  56698. };
  56699. /**
  56700. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  56701. * in order to compute objects velocities when enableVelocity is set to "true"
  56702. * @hidden
  56703. */ private _previousBonesTransformationMatrices: {
  56704. [index: number]: Float32Array;
  56705. };
  56706. /**
  56707. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  56708. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  56709. */
  56710. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  56711. private _scene;
  56712. private _multiRenderTarget;
  56713. private _ratio;
  56714. private _enablePosition;
  56715. private _enableVelocity;
  56716. private _positionIndex;
  56717. private _velocityIndex;
  56718. protected _effect: Effect;
  56719. protected _cachedDefines: string;
  56720. /**
  56721. * Set the render list (meshes to be rendered) used in the G buffer.
  56722. */
  56723. renderList: Mesh[];
  56724. /**
  56725. * Gets wether or not G buffer are supported by the running hardware.
  56726. * This requires draw buffer supports
  56727. */
  56728. readonly isSupported: boolean;
  56729. /**
  56730. * Returns the index of the given texture type in the G-Buffer textures array
  56731. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  56732. * @returns the index of the given texture type in the G-Buffer textures array
  56733. */
  56734. getTextureIndex(textureType: number): number;
  56735. /**
  56736. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  56737. */
  56738. /**
  56739. * Sets whether or not objects positions are enabled for the G buffer.
  56740. */
  56741. enablePosition: boolean;
  56742. /**
  56743. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  56744. */
  56745. /**
  56746. * Sets wether or not objects velocities are enabled for the G buffer.
  56747. */
  56748. enableVelocity: boolean;
  56749. /**
  56750. * Gets the scene associated with the buffer.
  56751. */
  56752. readonly scene: Scene;
  56753. /**
  56754. * Gets the ratio used by the buffer during its creation.
  56755. * How big is the buffer related to the main canvas.
  56756. */
  56757. readonly ratio: number;
  56758. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  56759. /**
  56760. * Creates a new G Buffer for the scene
  56761. * @param scene The scene the buffer belongs to
  56762. * @param ratio How big is the buffer related to the main canvas.
  56763. */
  56764. constructor(scene: Scene, ratio?: number);
  56765. /**
  56766. * Checks wether everything is ready to render a submesh to the G buffer.
  56767. * @param subMesh the submesh to check readiness for
  56768. * @param useInstances is the mesh drawn using instance or not
  56769. * @returns true if ready otherwise false
  56770. */
  56771. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56772. /**
  56773. * Gets the current underlying G Buffer.
  56774. * @returns the buffer
  56775. */
  56776. getGBuffer(): MultiRenderTarget;
  56777. /**
  56778. * Gets the number of samples used to render the buffer (anti aliasing).
  56779. */
  56780. /**
  56781. * Sets the number of samples used to render the buffer (anti aliasing).
  56782. */
  56783. samples: number;
  56784. /**
  56785. * Disposes the renderer and frees up associated resources.
  56786. */
  56787. dispose(): void;
  56788. protected _createRenderTargets(): void;
  56789. private _copyBonesTransformationMatrices;
  56790. }
  56791. }
  56792. declare module BABYLON {
  56793. interface Scene {
  56794. /** @hidden (Backing field) */ private _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56795. /**
  56796. * Gets or Sets the current geometry buffer associated to the scene.
  56797. */
  56798. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  56799. /**
  56800. * Enables a GeometryBufferRender and associates it with the scene
  56801. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  56802. * @returns the GeometryBufferRenderer
  56803. */
  56804. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  56805. /**
  56806. * Disables the GeometryBufferRender associated with the scene
  56807. */
  56808. disableGeometryBufferRenderer(): void;
  56809. }
  56810. /**
  56811. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  56812. * in several rendering techniques.
  56813. */
  56814. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  56815. /**
  56816. * The component name helpful to identify the component in the list of scene components.
  56817. */
  56818. readonly name: string;
  56819. /**
  56820. * The scene the component belongs to.
  56821. */
  56822. scene: Scene;
  56823. /**
  56824. * Creates a new instance of the component for the given scene
  56825. * @param scene Defines the scene to register the component in
  56826. */
  56827. constructor(scene: Scene);
  56828. /**
  56829. * Registers the component in a given scene
  56830. */
  56831. register(): void;
  56832. /**
  56833. * Rebuilds the elements related to this component in case of
  56834. * context lost for instance.
  56835. */
  56836. rebuild(): void;
  56837. /**
  56838. * Disposes the component and the associated ressources
  56839. */
  56840. dispose(): void;
  56841. private _gatherRenderTargets;
  56842. }
  56843. }
  56844. declare module BABYLON {
  56845. /** @hidden */
  56846. export var motionBlurPixelShader: {
  56847. name: string;
  56848. shader: string;
  56849. };
  56850. }
  56851. declare module BABYLON {
  56852. /**
  56853. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  56854. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  56855. * As an example, all you have to do is to create the post-process:
  56856. * var mb = new BABYLON.MotionBlurPostProcess(
  56857. * 'mb', // The name of the effect.
  56858. * scene, // The scene containing the objects to blur according to their velocity.
  56859. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  56860. * camera // The camera to apply the render pass to.
  56861. * );
  56862. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  56863. */
  56864. export class MotionBlurPostProcess extends PostProcess {
  56865. /**
  56866. * Defines how much the image is blurred by the movement. Default value is equal to 1
  56867. */
  56868. motionStrength: number;
  56869. /**
  56870. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  56871. */
  56872. /**
  56873. * Sets the number of iterations to be used for motion blur quality
  56874. */
  56875. motionBlurSamples: number;
  56876. private _motionBlurSamples;
  56877. private _geometryBufferRenderer;
  56878. /**
  56879. * Creates a new instance MotionBlurPostProcess
  56880. * @param name The name of the effect.
  56881. * @param scene The scene containing the objects to blur according to their velocity.
  56882. * @param options The required width/height ratio to downsize to before computing the render pass.
  56883. * @param camera The camera to apply the render pass to.
  56884. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56885. * @param engine The engine which the post process will be applied. (default: current engine)
  56886. * @param reusable If the post process can be reused on the same frame. (default: false)
  56887. * @param textureType Type of textures used when performing the post process. (default: 0)
  56888. * @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)
  56889. */
  56890. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56891. /**
  56892. * Excludes the given skinned mesh from computing bones velocities.
  56893. * 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.
  56894. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  56895. */
  56896. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56897. /**
  56898. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  56899. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  56900. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  56901. */
  56902. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  56903. /**
  56904. * Disposes the post process.
  56905. * @param camera The camera to dispose the post process on.
  56906. */
  56907. dispose(camera?: Camera): void;
  56908. }
  56909. }
  56910. declare module BABYLON {
  56911. /** @hidden */
  56912. export var refractionPixelShader: {
  56913. name: string;
  56914. shader: string;
  56915. };
  56916. }
  56917. declare module BABYLON {
  56918. /**
  56919. * Post process which applies a refractin texture
  56920. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56921. */
  56922. export class RefractionPostProcess extends PostProcess {
  56923. /** the base color of the refraction (used to taint the rendering) */
  56924. color: Color3;
  56925. /** simulated refraction depth */
  56926. depth: number;
  56927. /** the coefficient of the base color (0 to remove base color tainting) */
  56928. colorLevel: number;
  56929. private _refTexture;
  56930. private _ownRefractionTexture;
  56931. /**
  56932. * Gets or sets the refraction texture
  56933. * Please note that you are responsible for disposing the texture if you set it manually
  56934. */
  56935. refractionTexture: Texture;
  56936. /**
  56937. * Initializes the RefractionPostProcess
  56938. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  56939. * @param name The name of the effect.
  56940. * @param refractionTextureUrl Url of the refraction texture to use
  56941. * @param color the base color of the refraction (used to taint the rendering)
  56942. * @param depth simulated refraction depth
  56943. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  56944. * @param camera The camera to apply the render pass to.
  56945. * @param options The required width/height ratio to downsize to before computing the render pass.
  56946. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56947. * @param engine The engine which the post process will be applied. (default: current engine)
  56948. * @param reusable If the post process can be reused on the same frame. (default: false)
  56949. */
  56950. constructor(name: string, refractionTextureUrl: string,
  56951. /** the base color of the refraction (used to taint the rendering) */
  56952. color: Color3,
  56953. /** simulated refraction depth */
  56954. depth: number,
  56955. /** the coefficient of the base color (0 to remove base color tainting) */
  56956. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  56957. /**
  56958. * Disposes of the post process
  56959. * @param camera Camera to dispose post process on
  56960. */
  56961. dispose(camera: Camera): void;
  56962. }
  56963. }
  56964. declare module BABYLON {
  56965. /** @hidden */
  56966. export var sharpenPixelShader: {
  56967. name: string;
  56968. shader: string;
  56969. };
  56970. }
  56971. declare module BABYLON {
  56972. /**
  56973. * The SharpenPostProcess applies a sharpen kernel to every pixel
  56974. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  56975. */
  56976. export class SharpenPostProcess extends PostProcess {
  56977. /**
  56978. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  56979. */
  56980. colorAmount: number;
  56981. /**
  56982. * How much sharpness should be applied (default: 0.3)
  56983. */
  56984. edgeAmount: number;
  56985. /**
  56986. * Creates a new instance ConvolutionPostProcess
  56987. * @param name The name of the effect.
  56988. * @param options The required width/height ratio to downsize to before computing the render pass.
  56989. * @param camera The camera to apply the render pass to.
  56990. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  56991. * @param engine The engine which the post process will be applied. (default: current engine)
  56992. * @param reusable If the post process can be reused on the same frame. (default: false)
  56993. * @param textureType Type of textures used when performing the post process. (default: 0)
  56994. * @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)
  56995. */
  56996. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  56997. }
  56998. }
  56999. declare module BABYLON {
  57000. /**
  57001. * PostProcessRenderPipeline
  57002. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57003. */
  57004. export class PostProcessRenderPipeline {
  57005. private engine;
  57006. private _renderEffects;
  57007. private _renderEffectsForIsolatedPass;
  57008. /**
  57009. * List of inspectable custom properties (used by the Inspector)
  57010. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  57011. */
  57012. inspectableCustomProperties: IInspectable[];
  57013. /**
  57014. * @hidden
  57015. */
  57016. protected _cameras: Camera[];
  57017. /** @hidden */ private _name: string;
  57018. /**
  57019. * Gets pipeline name
  57020. */
  57021. readonly name: string;
  57022. /**
  57023. * Initializes a PostProcessRenderPipeline
  57024. * @param engine engine to add the pipeline to
  57025. * @param name name of the pipeline
  57026. */
  57027. constructor(engine: Engine, name: string);
  57028. /**
  57029. * Gets the class name
  57030. * @returns "PostProcessRenderPipeline"
  57031. */
  57032. getClassName(): string;
  57033. /**
  57034. * If all the render effects in the pipeline are supported
  57035. */
  57036. readonly isSupported: boolean;
  57037. /**
  57038. * Adds an effect to the pipeline
  57039. * @param renderEffect the effect to add
  57040. */
  57041. addEffect(renderEffect: PostProcessRenderEffect): void;
  57042. /** @hidden */ private _rebuild(): void;
  57043. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera): void;
  57044. /** @hidden */ private _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  57045. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57046. /** @hidden */ private _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  57047. /** @hidden */ private _attachCameras(cameras: Camera, unique: boolean): void;
  57048. /** @hidden */ private _attachCameras(cameras: Camera[], unique: boolean): void;
  57049. /** @hidden */ private _detachCameras(cameras: Camera): void;
  57050. /** @hidden */ private _detachCameras(cameras: Nullable<Camera[]>): void;
  57051. /** @hidden */ private _update(): void;
  57052. /** @hidden */ private _reset(): void;
  57053. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  57054. /**
  57055. * Disposes of the pipeline
  57056. */
  57057. dispose(): void;
  57058. }
  57059. }
  57060. declare module BABYLON {
  57061. /**
  57062. * PostProcessRenderPipelineManager class
  57063. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57064. */
  57065. export class PostProcessRenderPipelineManager {
  57066. private _renderPipelines;
  57067. /**
  57068. * Initializes a PostProcessRenderPipelineManager
  57069. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57070. */
  57071. constructor();
  57072. /**
  57073. * Gets the list of supported render pipelines
  57074. */
  57075. readonly supportedPipelines: PostProcessRenderPipeline[];
  57076. /**
  57077. * Adds a pipeline to the manager
  57078. * @param renderPipeline The pipeline to add
  57079. */
  57080. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  57081. /**
  57082. * Attaches a camera to the pipeline
  57083. * @param renderPipelineName The name of the pipeline to attach to
  57084. * @param cameras the camera to attach
  57085. * @param unique if the camera can be attached multiple times to the pipeline
  57086. */
  57087. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  57088. /**
  57089. * Detaches a camera from the pipeline
  57090. * @param renderPipelineName The name of the pipeline to detach from
  57091. * @param cameras the camera to detach
  57092. */
  57093. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  57094. /**
  57095. * Enables an effect by name on a pipeline
  57096. * @param renderPipelineName the name of the pipeline to enable the effect in
  57097. * @param renderEffectName the name of the effect to enable
  57098. * @param cameras the cameras that the effect should be enabled on
  57099. */
  57100. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57101. /**
  57102. * Disables an effect by name on a pipeline
  57103. * @param renderPipelineName the name of the pipeline to disable the effect in
  57104. * @param renderEffectName the name of the effect to disable
  57105. * @param cameras the cameras that the effect should be disabled on
  57106. */
  57107. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  57108. /**
  57109. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  57110. */
  57111. update(): void;
  57112. /** @hidden */ private _rebuild(): void;
  57113. /**
  57114. * Disposes of the manager and pipelines
  57115. */
  57116. dispose(): void;
  57117. }
  57118. }
  57119. declare module BABYLON {
  57120. interface Scene {
  57121. /** @hidden (Backing field) */ private _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57122. /**
  57123. * Gets the postprocess render pipeline manager
  57124. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  57125. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57126. */
  57127. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  57128. }
  57129. /**
  57130. * Defines the Render Pipeline scene component responsible to rendering pipelines
  57131. */
  57132. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  57133. /**
  57134. * The component name helpfull to identify the component in the list of scene components.
  57135. */
  57136. readonly name: string;
  57137. /**
  57138. * The scene the component belongs to.
  57139. */
  57140. scene: Scene;
  57141. /**
  57142. * Creates a new instance of the component for the given scene
  57143. * @param scene Defines the scene to register the component in
  57144. */
  57145. constructor(scene: Scene);
  57146. /**
  57147. * Registers the component in a given scene
  57148. */
  57149. register(): void;
  57150. /**
  57151. * Rebuilds the elements related to this component in case of
  57152. * context lost for instance.
  57153. */
  57154. rebuild(): void;
  57155. /**
  57156. * Disposes the component and the associated ressources
  57157. */
  57158. dispose(): void;
  57159. private _gatherRenderTargets;
  57160. }
  57161. }
  57162. declare module BABYLON {
  57163. /**
  57164. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  57165. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  57166. */
  57167. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57168. private _scene;
  57169. private _camerasToBeAttached;
  57170. /**
  57171. * ID of the sharpen post process,
  57172. */
  57173. private readonly SharpenPostProcessId;
  57174. /**
  57175. * @ignore
  57176. * ID of the image processing post process;
  57177. */
  57178. readonly ImageProcessingPostProcessId: string;
  57179. /**
  57180. * @ignore
  57181. * ID of the Fast Approximate Anti-Aliasing post process;
  57182. */
  57183. readonly FxaaPostProcessId: string;
  57184. /**
  57185. * ID of the chromatic aberration post process,
  57186. */
  57187. private readonly ChromaticAberrationPostProcessId;
  57188. /**
  57189. * ID of the grain post process
  57190. */
  57191. private readonly GrainPostProcessId;
  57192. /**
  57193. * Sharpen post process which will apply a sharpen convolution to enhance edges
  57194. */
  57195. sharpen: SharpenPostProcess;
  57196. private _sharpenEffect;
  57197. private bloom;
  57198. /**
  57199. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  57200. */
  57201. depthOfField: DepthOfFieldEffect;
  57202. /**
  57203. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57204. */
  57205. fxaa: FxaaPostProcess;
  57206. /**
  57207. * Image post processing pass used to perform operations such as tone mapping or color grading.
  57208. */
  57209. imageProcessing: ImageProcessingPostProcess;
  57210. /**
  57211. * Chromatic aberration post process which will shift rgb colors in the image
  57212. */
  57213. chromaticAberration: ChromaticAberrationPostProcess;
  57214. private _chromaticAberrationEffect;
  57215. /**
  57216. * Grain post process which add noise to the image
  57217. */
  57218. grain: GrainPostProcess;
  57219. private _grainEffect;
  57220. /**
  57221. * Glow post process which adds a glow to emissive areas of the image
  57222. */
  57223. private _glowLayer;
  57224. /**
  57225. * Animations which can be used to tweak settings over a period of time
  57226. */
  57227. animations: Animation[];
  57228. private _imageProcessingConfigurationObserver;
  57229. private _sharpenEnabled;
  57230. private _bloomEnabled;
  57231. private _depthOfFieldEnabled;
  57232. private _depthOfFieldBlurLevel;
  57233. private _fxaaEnabled;
  57234. private _imageProcessingEnabled;
  57235. private _defaultPipelineTextureType;
  57236. private _bloomScale;
  57237. private _chromaticAberrationEnabled;
  57238. private _grainEnabled;
  57239. private _buildAllowed;
  57240. /**
  57241. * Gets active scene
  57242. */
  57243. readonly scene: Scene;
  57244. /**
  57245. * Enable or disable the sharpen process from the pipeline
  57246. */
  57247. sharpenEnabled: boolean;
  57248. private _resizeObserver;
  57249. private _hardwareScaleLevel;
  57250. private _bloomKernel;
  57251. /**
  57252. * Specifies the size of the bloom blur kernel, relative to the final output size
  57253. */
  57254. bloomKernel: number;
  57255. /**
  57256. * Specifies the weight of the bloom in the final rendering
  57257. */
  57258. private _bloomWeight;
  57259. /**
  57260. * Specifies the luma threshold for the area that will be blurred by the bloom
  57261. */
  57262. private _bloomThreshold;
  57263. private _hdr;
  57264. /**
  57265. * The strength of the bloom.
  57266. */
  57267. bloomWeight: number;
  57268. /**
  57269. * The strength of the bloom.
  57270. */
  57271. bloomThreshold: number;
  57272. /**
  57273. * The scale of the bloom, lower value will provide better performance.
  57274. */
  57275. bloomScale: number;
  57276. /**
  57277. * Enable or disable the bloom from the pipeline
  57278. */
  57279. bloomEnabled: boolean;
  57280. private _rebuildBloom;
  57281. /**
  57282. * If the depth of field is enabled.
  57283. */
  57284. depthOfFieldEnabled: boolean;
  57285. /**
  57286. * Blur level of the depth of field effect. (Higher blur will effect performance)
  57287. */
  57288. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  57289. /**
  57290. * If the anti aliasing is enabled.
  57291. */
  57292. fxaaEnabled: boolean;
  57293. private _samples;
  57294. /**
  57295. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  57296. */
  57297. samples: number;
  57298. /**
  57299. * If image processing is enabled.
  57300. */
  57301. imageProcessingEnabled: boolean;
  57302. /**
  57303. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  57304. */
  57305. glowLayerEnabled: boolean;
  57306. /**
  57307. * Gets the glow layer (or null if not defined)
  57308. */
  57309. readonly glowLayer: Nullable<GlowLayer>;
  57310. /**
  57311. * Enable or disable the chromaticAberration process from the pipeline
  57312. */
  57313. chromaticAberrationEnabled: boolean;
  57314. /**
  57315. * Enable or disable the grain process from the pipeline
  57316. */
  57317. grainEnabled: boolean;
  57318. /**
  57319. * @constructor
  57320. * @param name - The rendering pipeline name (default: "")
  57321. * @param hdr - If high dynamic range textures should be used (default: true)
  57322. * @param scene - The scene linked to this pipeline (default: the last created scene)
  57323. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  57324. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  57325. */
  57326. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  57327. /**
  57328. * Get the class name
  57329. * @returns "DefaultRenderingPipeline"
  57330. */
  57331. getClassName(): string;
  57332. /**
  57333. * Force the compilation of the entire pipeline.
  57334. */
  57335. prepare(): void;
  57336. private _hasCleared;
  57337. private _prevPostProcess;
  57338. private _prevPrevPostProcess;
  57339. private _setAutoClearAndTextureSharing;
  57340. private _depthOfFieldSceneObserver;
  57341. private _buildPipeline;
  57342. private _disposePostProcesses;
  57343. /**
  57344. * Adds a camera to the pipeline
  57345. * @param camera the camera to be added
  57346. */
  57347. addCamera(camera: Camera): void;
  57348. /**
  57349. * Removes a camera from the pipeline
  57350. * @param camera the camera to remove
  57351. */
  57352. removeCamera(camera: Camera): void;
  57353. /**
  57354. * Dispose of the pipeline and stop all post processes
  57355. */
  57356. dispose(): void;
  57357. /**
  57358. * Serialize the rendering pipeline (Used when exporting)
  57359. * @returns the serialized object
  57360. */
  57361. serialize(): any;
  57362. /**
  57363. * Parse the serialized pipeline
  57364. * @param source Source pipeline.
  57365. * @param scene The scene to load the pipeline to.
  57366. * @param rootUrl The URL of the serialized pipeline.
  57367. * @returns An instantiated pipeline from the serialized object.
  57368. */
  57369. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  57370. }
  57371. }
  57372. declare module BABYLON {
  57373. /** @hidden */
  57374. export var lensHighlightsPixelShader: {
  57375. name: string;
  57376. shader: string;
  57377. };
  57378. }
  57379. declare module BABYLON {
  57380. /** @hidden */
  57381. export var depthOfFieldPixelShader: {
  57382. name: string;
  57383. shader: string;
  57384. };
  57385. }
  57386. declare module BABYLON {
  57387. /**
  57388. * BABYLON.JS Chromatic Aberration GLSL Shader
  57389. * Author: Olivier Guyot
  57390. * Separates very slightly R, G and B colors on the edges of the screen
  57391. * Inspired by Francois Tarlier & Martins Upitis
  57392. */
  57393. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  57394. /**
  57395. * @ignore
  57396. * The chromatic aberration PostProcess id in the pipeline
  57397. */
  57398. LensChromaticAberrationEffect: string;
  57399. /**
  57400. * @ignore
  57401. * The highlights enhancing PostProcess id in the pipeline
  57402. */
  57403. HighlightsEnhancingEffect: string;
  57404. /**
  57405. * @ignore
  57406. * The depth-of-field PostProcess id in the pipeline
  57407. */
  57408. LensDepthOfFieldEffect: string;
  57409. private _scene;
  57410. private _depthTexture;
  57411. private _grainTexture;
  57412. private _chromaticAberrationPostProcess;
  57413. private _highlightsPostProcess;
  57414. private _depthOfFieldPostProcess;
  57415. private _edgeBlur;
  57416. private _grainAmount;
  57417. private _chromaticAberration;
  57418. private _distortion;
  57419. private _highlightsGain;
  57420. private _highlightsThreshold;
  57421. private _dofDistance;
  57422. private _dofAperture;
  57423. private _dofDarken;
  57424. private _dofPentagon;
  57425. private _blurNoise;
  57426. /**
  57427. * @constructor
  57428. *
  57429. * Effect parameters are as follow:
  57430. * {
  57431. * chromatic_aberration: number; // from 0 to x (1 for realism)
  57432. * edge_blur: number; // from 0 to x (1 for realism)
  57433. * distortion: number; // from 0 to x (1 for realism)
  57434. * grain_amount: number; // from 0 to 1
  57435. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  57436. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  57437. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  57438. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  57439. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  57440. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  57441. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  57442. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  57443. * }
  57444. * Note: if an effect parameter is unset, effect is disabled
  57445. *
  57446. * @param name The rendering pipeline name
  57447. * @param parameters - An object containing all parameters (see above)
  57448. * @param scene The scene linked to this pipeline
  57449. * @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)
  57450. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57451. */
  57452. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  57453. /**
  57454. * Get the class name
  57455. * @returns "LensRenderingPipeline"
  57456. */
  57457. getClassName(): string;
  57458. /**
  57459. * Gets associated scene
  57460. */
  57461. readonly scene: Scene;
  57462. /**
  57463. * Gets or sets the edge blur
  57464. */
  57465. edgeBlur: number;
  57466. /**
  57467. * Gets or sets the grain amount
  57468. */
  57469. grainAmount: number;
  57470. /**
  57471. * Gets or sets the chromatic aberration amount
  57472. */
  57473. chromaticAberration: number;
  57474. /**
  57475. * Gets or sets the depth of field aperture
  57476. */
  57477. dofAperture: number;
  57478. /**
  57479. * Gets or sets the edge distortion
  57480. */
  57481. edgeDistortion: number;
  57482. /**
  57483. * Gets or sets the depth of field distortion
  57484. */
  57485. dofDistortion: number;
  57486. /**
  57487. * Gets or sets the darken out of focus amount
  57488. */
  57489. darkenOutOfFocus: number;
  57490. /**
  57491. * Gets or sets a boolean indicating if blur noise is enabled
  57492. */
  57493. blurNoise: boolean;
  57494. /**
  57495. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  57496. */
  57497. pentagonBokeh: boolean;
  57498. /**
  57499. * Gets or sets the highlight grain amount
  57500. */
  57501. highlightsGain: number;
  57502. /**
  57503. * Gets or sets the highlight threshold
  57504. */
  57505. highlightsThreshold: number;
  57506. /**
  57507. * Sets the amount of blur at the edges
  57508. * @param amount blur amount
  57509. */
  57510. setEdgeBlur(amount: number): void;
  57511. /**
  57512. * Sets edge blur to 0
  57513. */
  57514. disableEdgeBlur(): void;
  57515. /**
  57516. * Sets the amout of grain
  57517. * @param amount Amount of grain
  57518. */
  57519. setGrainAmount(amount: number): void;
  57520. /**
  57521. * Set grain amount to 0
  57522. */
  57523. disableGrain(): void;
  57524. /**
  57525. * Sets the chromatic aberration amount
  57526. * @param amount amount of chromatic aberration
  57527. */
  57528. setChromaticAberration(amount: number): void;
  57529. /**
  57530. * Sets chromatic aberration amount to 0
  57531. */
  57532. disableChromaticAberration(): void;
  57533. /**
  57534. * Sets the EdgeDistortion amount
  57535. * @param amount amount of EdgeDistortion
  57536. */
  57537. setEdgeDistortion(amount: number): void;
  57538. /**
  57539. * Sets edge distortion to 0
  57540. */
  57541. disableEdgeDistortion(): void;
  57542. /**
  57543. * Sets the FocusDistance amount
  57544. * @param amount amount of FocusDistance
  57545. */
  57546. setFocusDistance(amount: number): void;
  57547. /**
  57548. * Disables depth of field
  57549. */
  57550. disableDepthOfField(): void;
  57551. /**
  57552. * Sets the Aperture amount
  57553. * @param amount amount of Aperture
  57554. */
  57555. setAperture(amount: number): void;
  57556. /**
  57557. * Sets the DarkenOutOfFocus amount
  57558. * @param amount amount of DarkenOutOfFocus
  57559. */
  57560. setDarkenOutOfFocus(amount: number): void;
  57561. private _pentagonBokehIsEnabled;
  57562. /**
  57563. * Creates a pentagon bokeh effect
  57564. */
  57565. enablePentagonBokeh(): void;
  57566. /**
  57567. * Disables the pentagon bokeh effect
  57568. */
  57569. disablePentagonBokeh(): void;
  57570. /**
  57571. * Enables noise blur
  57572. */
  57573. enableNoiseBlur(): void;
  57574. /**
  57575. * Disables noise blur
  57576. */
  57577. disableNoiseBlur(): void;
  57578. /**
  57579. * Sets the HighlightsGain amount
  57580. * @param amount amount of HighlightsGain
  57581. */
  57582. setHighlightsGain(amount: number): void;
  57583. /**
  57584. * Sets the HighlightsThreshold amount
  57585. * @param amount amount of HighlightsThreshold
  57586. */
  57587. setHighlightsThreshold(amount: number): void;
  57588. /**
  57589. * Disables highlights
  57590. */
  57591. disableHighlights(): void;
  57592. /**
  57593. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  57594. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  57595. */
  57596. dispose(disableDepthRender?: boolean): void;
  57597. private _createChromaticAberrationPostProcess;
  57598. private _createHighlightsPostProcess;
  57599. private _createDepthOfFieldPostProcess;
  57600. private _createGrainTexture;
  57601. }
  57602. }
  57603. declare module BABYLON {
  57604. /** @hidden */
  57605. export var ssao2PixelShader: {
  57606. name: string;
  57607. shader: string;
  57608. };
  57609. }
  57610. declare module BABYLON {
  57611. /** @hidden */
  57612. export var ssaoCombinePixelShader: {
  57613. name: string;
  57614. shader: string;
  57615. };
  57616. }
  57617. declare module BABYLON {
  57618. /**
  57619. * Render pipeline to produce ssao effect
  57620. */
  57621. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  57622. /**
  57623. * @ignore
  57624. * The PassPostProcess id in the pipeline that contains the original scene color
  57625. */
  57626. SSAOOriginalSceneColorEffect: string;
  57627. /**
  57628. * @ignore
  57629. * The SSAO PostProcess id in the pipeline
  57630. */
  57631. SSAORenderEffect: string;
  57632. /**
  57633. * @ignore
  57634. * The horizontal blur PostProcess id in the pipeline
  57635. */
  57636. SSAOBlurHRenderEffect: string;
  57637. /**
  57638. * @ignore
  57639. * The vertical blur PostProcess id in the pipeline
  57640. */
  57641. SSAOBlurVRenderEffect: string;
  57642. /**
  57643. * @ignore
  57644. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57645. */
  57646. SSAOCombineRenderEffect: string;
  57647. /**
  57648. * The output strength of the SSAO post-process. Default value is 1.0.
  57649. */
  57650. totalStrength: number;
  57651. /**
  57652. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  57653. */
  57654. maxZ: number;
  57655. /**
  57656. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  57657. */
  57658. minZAspect: number;
  57659. private _samples;
  57660. /**
  57661. * Number of samples used for the SSAO calculations. Default value is 8
  57662. */
  57663. samples: number;
  57664. private _textureSamples;
  57665. /**
  57666. * Number of samples to use for antialiasing
  57667. */
  57668. textureSamples: number;
  57669. /**
  57670. * Ratio object used for SSAO ratio and blur ratio
  57671. */
  57672. private _ratio;
  57673. /**
  57674. * Dynamically generated sphere sampler.
  57675. */
  57676. private _sampleSphere;
  57677. /**
  57678. * Blur filter offsets
  57679. */
  57680. private _samplerOffsets;
  57681. private _expensiveBlur;
  57682. /**
  57683. * If bilateral blur should be used
  57684. */
  57685. expensiveBlur: boolean;
  57686. /**
  57687. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  57688. */
  57689. radius: number;
  57690. /**
  57691. * The base color of the SSAO post-process
  57692. * The final result is "base + ssao" between [0, 1]
  57693. */
  57694. base: number;
  57695. /**
  57696. * Support test.
  57697. */
  57698. static readonly IsSupported: boolean;
  57699. private _scene;
  57700. private _depthTexture;
  57701. private _normalTexture;
  57702. private _randomTexture;
  57703. private _originalColorPostProcess;
  57704. private _ssaoPostProcess;
  57705. private _blurHPostProcess;
  57706. private _blurVPostProcess;
  57707. private _ssaoCombinePostProcess;
  57708. private _firstUpdate;
  57709. /**
  57710. * Gets active scene
  57711. */
  57712. readonly scene: Scene;
  57713. /**
  57714. * @constructor
  57715. * @param name The rendering pipeline name
  57716. * @param scene The scene linked to this pipeline
  57717. * @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 }
  57718. * @param cameras The array of cameras that the rendering pipeline will be attached to
  57719. */
  57720. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57721. /**
  57722. * Get the class name
  57723. * @returns "SSAO2RenderingPipeline"
  57724. */
  57725. getClassName(): string;
  57726. /**
  57727. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57728. */
  57729. dispose(disableGeometryBufferRenderer?: boolean): void;
  57730. private _createBlurPostProcess;
  57731. /** @hidden */ private _rebuild(): void;
  57732. private _bits;
  57733. private _radicalInverse_VdC;
  57734. private _hammersley;
  57735. private _hemisphereSample_uniform;
  57736. private _generateHemisphere;
  57737. private _createSSAOPostProcess;
  57738. private _createSSAOCombinePostProcess;
  57739. private _createRandomTexture;
  57740. /**
  57741. * Serialize the rendering pipeline (Used when exporting)
  57742. * @returns the serialized object
  57743. */
  57744. serialize(): any;
  57745. /**
  57746. * Parse the serialized pipeline
  57747. * @param source Source pipeline.
  57748. * @param scene The scene to load the pipeline to.
  57749. * @param rootUrl The URL of the serialized pipeline.
  57750. * @returns An instantiated pipeline from the serialized object.
  57751. */
  57752. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  57753. }
  57754. }
  57755. declare module BABYLON {
  57756. /** @hidden */
  57757. export var ssaoPixelShader: {
  57758. name: string;
  57759. shader: string;
  57760. };
  57761. }
  57762. declare module BABYLON {
  57763. /**
  57764. * Render pipeline to produce ssao effect
  57765. */
  57766. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  57767. /**
  57768. * @ignore
  57769. * The PassPostProcess id in the pipeline that contains the original scene color
  57770. */
  57771. SSAOOriginalSceneColorEffect: string;
  57772. /**
  57773. * @ignore
  57774. * The SSAO PostProcess id in the pipeline
  57775. */
  57776. SSAORenderEffect: string;
  57777. /**
  57778. * @ignore
  57779. * The horizontal blur PostProcess id in the pipeline
  57780. */
  57781. SSAOBlurHRenderEffect: string;
  57782. /**
  57783. * @ignore
  57784. * The vertical blur PostProcess id in the pipeline
  57785. */
  57786. SSAOBlurVRenderEffect: string;
  57787. /**
  57788. * @ignore
  57789. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  57790. */
  57791. SSAOCombineRenderEffect: string;
  57792. /**
  57793. * The output strength of the SSAO post-process. Default value is 1.0.
  57794. */
  57795. totalStrength: number;
  57796. /**
  57797. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  57798. */
  57799. radius: number;
  57800. /**
  57801. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  57802. * Must not be equal to fallOff and superior to fallOff.
  57803. * Default value is 0.0075
  57804. */
  57805. area: number;
  57806. /**
  57807. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  57808. * Must not be equal to area and inferior to area.
  57809. * Default value is 0.000001
  57810. */
  57811. fallOff: number;
  57812. /**
  57813. * The base color of the SSAO post-process
  57814. * The final result is "base + ssao" between [0, 1]
  57815. */
  57816. base: number;
  57817. private _scene;
  57818. private _depthTexture;
  57819. private _randomTexture;
  57820. private _originalColorPostProcess;
  57821. private _ssaoPostProcess;
  57822. private _blurHPostProcess;
  57823. private _blurVPostProcess;
  57824. private _ssaoCombinePostProcess;
  57825. private _firstUpdate;
  57826. /**
  57827. * Gets active scene
  57828. */
  57829. readonly scene: Scene;
  57830. /**
  57831. * @constructor
  57832. * @param name - The rendering pipeline name
  57833. * @param scene - The scene linked to this pipeline
  57834. * @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 }
  57835. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  57836. */
  57837. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  57838. /**
  57839. * Get the class name
  57840. * @returns "SSAORenderingPipeline"
  57841. */
  57842. getClassName(): string;
  57843. /**
  57844. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  57845. */
  57846. dispose(disableDepthRender?: boolean): void;
  57847. private _createBlurPostProcess;
  57848. /** @hidden */ private _rebuild(): void;
  57849. private _createSSAOPostProcess;
  57850. private _createSSAOCombinePostProcess;
  57851. private _createRandomTexture;
  57852. }
  57853. }
  57854. declare module BABYLON {
  57855. /** @hidden */
  57856. export var standardPixelShader: {
  57857. name: string;
  57858. shader: string;
  57859. };
  57860. }
  57861. declare module BABYLON {
  57862. /**
  57863. * Standard rendering pipeline
  57864. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  57865. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  57866. */
  57867. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  57868. /**
  57869. * Public members
  57870. */
  57871. /**
  57872. * Post-process which contains the original scene color before the pipeline applies all the effects
  57873. */
  57874. originalPostProcess: Nullable<PostProcess>;
  57875. /**
  57876. * Post-process used to down scale an image x4
  57877. */
  57878. downSampleX4PostProcess: Nullable<PostProcess>;
  57879. /**
  57880. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  57881. */
  57882. brightPassPostProcess: Nullable<PostProcess>;
  57883. /**
  57884. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  57885. */
  57886. blurHPostProcesses: PostProcess[];
  57887. /**
  57888. * Post-process array storing all the vertical blur post-processes used by the pipeline
  57889. */
  57890. blurVPostProcesses: PostProcess[];
  57891. /**
  57892. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  57893. */
  57894. textureAdderPostProcess: Nullable<PostProcess>;
  57895. /**
  57896. * Post-process used to create volumetric lighting effect
  57897. */
  57898. volumetricLightPostProcess: Nullable<PostProcess>;
  57899. /**
  57900. * Post-process used to smooth the previous volumetric light post-process on the X axis
  57901. */
  57902. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  57903. /**
  57904. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  57905. */
  57906. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  57907. /**
  57908. * Post-process used to merge the volumetric light effect and the real scene color
  57909. */
  57910. volumetricLightMergePostProces: Nullable<PostProcess>;
  57911. /**
  57912. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  57913. */
  57914. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  57915. /**
  57916. * Base post-process used to calculate the average luminance of the final image for HDR
  57917. */
  57918. luminancePostProcess: Nullable<PostProcess>;
  57919. /**
  57920. * Post-processes used to create down sample post-processes in order to get
  57921. * the average luminance of the final image for HDR
  57922. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  57923. */
  57924. luminanceDownSamplePostProcesses: PostProcess[];
  57925. /**
  57926. * Post-process used to create a HDR effect (light adaptation)
  57927. */
  57928. hdrPostProcess: Nullable<PostProcess>;
  57929. /**
  57930. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  57931. */
  57932. textureAdderFinalPostProcess: Nullable<PostProcess>;
  57933. /**
  57934. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  57935. */
  57936. lensFlareFinalPostProcess: Nullable<PostProcess>;
  57937. /**
  57938. * Post-process used to merge the final HDR post-process and the real scene color
  57939. */
  57940. hdrFinalPostProcess: Nullable<PostProcess>;
  57941. /**
  57942. * Post-process used to create a lens flare effect
  57943. */
  57944. lensFlarePostProcess: Nullable<PostProcess>;
  57945. /**
  57946. * Post-process that merges the result of the lens flare post-process and the real scene color
  57947. */
  57948. lensFlareComposePostProcess: Nullable<PostProcess>;
  57949. /**
  57950. * Post-process used to create a motion blur effect
  57951. */
  57952. motionBlurPostProcess: Nullable<PostProcess>;
  57953. /**
  57954. * Post-process used to create a depth of field effect
  57955. */
  57956. depthOfFieldPostProcess: Nullable<PostProcess>;
  57957. /**
  57958. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  57959. */
  57960. fxaaPostProcess: Nullable<FxaaPostProcess>;
  57961. /**
  57962. * Represents the brightness threshold in order to configure the illuminated surfaces
  57963. */
  57964. brightThreshold: number;
  57965. /**
  57966. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  57967. */
  57968. blurWidth: number;
  57969. /**
  57970. * Sets if the blur for highlighted surfaces must be only horizontal
  57971. */
  57972. horizontalBlur: boolean;
  57973. /**
  57974. * Gets the overall exposure used by the pipeline
  57975. */
  57976. /**
  57977. * Sets the overall exposure used by the pipeline
  57978. */
  57979. exposure: number;
  57980. /**
  57981. * Texture used typically to simulate "dirty" on camera lens
  57982. */
  57983. lensTexture: Nullable<Texture>;
  57984. /**
  57985. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  57986. */
  57987. volumetricLightCoefficient: number;
  57988. /**
  57989. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  57990. */
  57991. volumetricLightPower: number;
  57992. /**
  57993. * Used the set the blur intensity to smooth the volumetric lights
  57994. */
  57995. volumetricLightBlurScale: number;
  57996. /**
  57997. * Light (spot or directional) used to generate the volumetric lights rays
  57998. * The source light must have a shadow generate so the pipeline can get its
  57999. * depth map
  58000. */
  58001. sourceLight: Nullable<SpotLight | DirectionalLight>;
  58002. /**
  58003. * For eye adaptation, represents the minimum luminance the eye can see
  58004. */
  58005. hdrMinimumLuminance: number;
  58006. /**
  58007. * For eye adaptation, represents the decrease luminance speed
  58008. */
  58009. hdrDecreaseRate: number;
  58010. /**
  58011. * For eye adaptation, represents the increase luminance speed
  58012. */
  58013. hdrIncreaseRate: number;
  58014. /**
  58015. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58016. */
  58017. /**
  58018. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  58019. */
  58020. hdrAutoExposure: boolean;
  58021. /**
  58022. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  58023. */
  58024. lensColorTexture: Nullable<Texture>;
  58025. /**
  58026. * The overall strengh for the lens flare effect
  58027. */
  58028. lensFlareStrength: number;
  58029. /**
  58030. * Dispersion coefficient for lens flare ghosts
  58031. */
  58032. lensFlareGhostDispersal: number;
  58033. /**
  58034. * Main lens flare halo width
  58035. */
  58036. lensFlareHaloWidth: number;
  58037. /**
  58038. * Based on the lens distortion effect, defines how much the lens flare result
  58039. * is distorted
  58040. */
  58041. lensFlareDistortionStrength: number;
  58042. /**
  58043. * Lens star texture must be used to simulate rays on the flares and is available
  58044. * in the documentation
  58045. */
  58046. lensStarTexture: Nullable<Texture>;
  58047. /**
  58048. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  58049. * flare effect by taking account of the dirt texture
  58050. */
  58051. lensFlareDirtTexture: Nullable<Texture>;
  58052. /**
  58053. * Represents the focal length for the depth of field effect
  58054. */
  58055. depthOfFieldDistance: number;
  58056. /**
  58057. * Represents the blur intensity for the blurred part of the depth of field effect
  58058. */
  58059. depthOfFieldBlurWidth: number;
  58060. /**
  58061. * Gets how much the image is blurred by the movement while using the motion blur post-process
  58062. */
  58063. /**
  58064. * Sets how much the image is blurred by the movement while using the motion blur post-process
  58065. */
  58066. motionStrength: number;
  58067. /**
  58068. * Gets wether or not the motion blur post-process is object based or screen based.
  58069. */
  58070. /**
  58071. * Sets wether or not the motion blur post-process should be object based or screen based
  58072. */
  58073. objectBasedMotionBlur: boolean;
  58074. /**
  58075. * List of animations for the pipeline (IAnimatable implementation)
  58076. */
  58077. animations: Animation[];
  58078. /**
  58079. * Private members
  58080. */
  58081. private _scene;
  58082. private _currentDepthOfFieldSource;
  58083. private _basePostProcess;
  58084. private _fixedExposure;
  58085. private _currentExposure;
  58086. private _hdrAutoExposure;
  58087. private _hdrCurrentLuminance;
  58088. private _motionStrength;
  58089. private _isObjectBasedMotionBlur;
  58090. private _floatTextureType;
  58091. private _ratio;
  58092. private _bloomEnabled;
  58093. private _depthOfFieldEnabled;
  58094. private _vlsEnabled;
  58095. private _lensFlareEnabled;
  58096. private _hdrEnabled;
  58097. private _motionBlurEnabled;
  58098. private _fxaaEnabled;
  58099. private _motionBlurSamples;
  58100. private _volumetricLightStepsCount;
  58101. private _samples;
  58102. /**
  58103. * @ignore
  58104. * Specifies if the bloom pipeline is enabled
  58105. */
  58106. BloomEnabled: boolean;
  58107. /**
  58108. * @ignore
  58109. * Specifies if the depth of field pipeline is enabed
  58110. */
  58111. DepthOfFieldEnabled: boolean;
  58112. /**
  58113. * @ignore
  58114. * Specifies if the lens flare pipeline is enabed
  58115. */
  58116. LensFlareEnabled: boolean;
  58117. /**
  58118. * @ignore
  58119. * Specifies if the HDR pipeline is enabled
  58120. */
  58121. HDREnabled: boolean;
  58122. /**
  58123. * @ignore
  58124. * Specifies if the volumetric lights scattering effect is enabled
  58125. */
  58126. VLSEnabled: boolean;
  58127. /**
  58128. * @ignore
  58129. * Specifies if the motion blur effect is enabled
  58130. */
  58131. MotionBlurEnabled: boolean;
  58132. /**
  58133. * Specifies if anti-aliasing is enabled
  58134. */
  58135. fxaaEnabled: boolean;
  58136. /**
  58137. * Specifies the number of steps used to calculate the volumetric lights
  58138. * Typically in interval [50, 200]
  58139. */
  58140. volumetricLightStepsCount: number;
  58141. /**
  58142. * Specifies the number of samples used for the motion blur effect
  58143. * Typically in interval [16, 64]
  58144. */
  58145. motionBlurSamples: number;
  58146. /**
  58147. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  58148. */
  58149. samples: number;
  58150. /**
  58151. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  58152. * @constructor
  58153. * @param name The rendering pipeline name
  58154. * @param scene The scene linked to this pipeline
  58155. * @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)
  58156. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  58157. * @param cameras The array of cameras that the rendering pipeline will be attached to
  58158. */
  58159. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  58160. private _buildPipeline;
  58161. private _createDownSampleX4PostProcess;
  58162. private _createBrightPassPostProcess;
  58163. private _createBlurPostProcesses;
  58164. private _createTextureAdderPostProcess;
  58165. private _createVolumetricLightPostProcess;
  58166. private _createLuminancePostProcesses;
  58167. private _createHdrPostProcess;
  58168. private _createLensFlarePostProcess;
  58169. private _createDepthOfFieldPostProcess;
  58170. private _createMotionBlurPostProcess;
  58171. private _getDepthTexture;
  58172. private _disposePostProcesses;
  58173. /**
  58174. * Dispose of the pipeline and stop all post processes
  58175. */
  58176. dispose(): void;
  58177. /**
  58178. * Serialize the rendering pipeline (Used when exporting)
  58179. * @returns the serialized object
  58180. */
  58181. serialize(): any;
  58182. /**
  58183. * Parse the serialized pipeline
  58184. * @param source Source pipeline.
  58185. * @param scene The scene to load the pipeline to.
  58186. * @param rootUrl The URL of the serialized pipeline.
  58187. * @returns An instantiated pipeline from the serialized object.
  58188. */
  58189. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  58190. /**
  58191. * Luminance steps
  58192. */
  58193. static LuminanceSteps: number;
  58194. }
  58195. }
  58196. declare module BABYLON {
  58197. /** @hidden */
  58198. export var tonemapPixelShader: {
  58199. name: string;
  58200. shader: string;
  58201. };
  58202. }
  58203. declare module BABYLON {
  58204. /** Defines operator used for tonemapping */
  58205. export enum TonemappingOperator {
  58206. /** Hable */
  58207. Hable = 0,
  58208. /** Reinhard */
  58209. Reinhard = 1,
  58210. /** HejiDawson */
  58211. HejiDawson = 2,
  58212. /** Photographic */
  58213. Photographic = 3
  58214. }
  58215. /**
  58216. * Defines a post process to apply tone mapping
  58217. */
  58218. export class TonemapPostProcess extends PostProcess {
  58219. private _operator;
  58220. /** Defines the required exposure adjustement */
  58221. exposureAdjustment: number;
  58222. /**
  58223. * Creates a new TonemapPostProcess
  58224. * @param name defines the name of the postprocess
  58225. * @param _operator defines the operator to use
  58226. * @param exposureAdjustment defines the required exposure adjustement
  58227. * @param camera defines the camera to use (can be null)
  58228. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  58229. * @param engine defines the hosting engine (can be ignore if camera is set)
  58230. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  58231. */
  58232. constructor(name: string, _operator: TonemappingOperator,
  58233. /** Defines the required exposure adjustement */
  58234. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  58235. }
  58236. }
  58237. declare module BABYLON {
  58238. /** @hidden */
  58239. export var depthVertexShader: {
  58240. name: string;
  58241. shader: string;
  58242. };
  58243. }
  58244. declare module BABYLON {
  58245. /** @hidden */
  58246. export var volumetricLightScatteringPixelShader: {
  58247. name: string;
  58248. shader: string;
  58249. };
  58250. }
  58251. declare module BABYLON {
  58252. /** @hidden */
  58253. export var volumetricLightScatteringPassVertexShader: {
  58254. name: string;
  58255. shader: string;
  58256. };
  58257. }
  58258. declare module BABYLON {
  58259. /** @hidden */
  58260. export var volumetricLightScatteringPassPixelShader: {
  58261. name: string;
  58262. shader: string;
  58263. };
  58264. }
  58265. declare module BABYLON {
  58266. /**
  58267. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  58268. */
  58269. export class VolumetricLightScatteringPostProcess extends PostProcess {
  58270. private _volumetricLightScatteringPass;
  58271. private _volumetricLightScatteringRTT;
  58272. private _viewPort;
  58273. private _screenCoordinates;
  58274. private _cachedDefines;
  58275. /**
  58276. * If not undefined, the mesh position is computed from the attached node position
  58277. */
  58278. attachedNode: {
  58279. position: Vector3;
  58280. };
  58281. /**
  58282. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  58283. */
  58284. customMeshPosition: Vector3;
  58285. /**
  58286. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  58287. */
  58288. useCustomMeshPosition: boolean;
  58289. /**
  58290. * If the post-process should inverse the light scattering direction
  58291. */
  58292. invert: boolean;
  58293. /**
  58294. * The internal mesh used by the post-process
  58295. */
  58296. mesh: Mesh;
  58297. /**
  58298. * @hidden
  58299. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  58300. */
  58301. useDiffuseColor: boolean;
  58302. /**
  58303. * Array containing the excluded meshes not rendered in the internal pass
  58304. */
  58305. excludedMeshes: AbstractMesh[];
  58306. /**
  58307. * Controls the overall intensity of the post-process
  58308. */
  58309. exposure: number;
  58310. /**
  58311. * Dissipates each sample's contribution in range [0, 1]
  58312. */
  58313. decay: number;
  58314. /**
  58315. * Controls the overall intensity of each sample
  58316. */
  58317. weight: number;
  58318. /**
  58319. * Controls the density of each sample
  58320. */
  58321. density: number;
  58322. /**
  58323. * @constructor
  58324. * @param name The post-process name
  58325. * @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)
  58326. * @param camera The camera that the post-process will be attached to
  58327. * @param mesh The mesh used to create the light scattering
  58328. * @param samples The post-process quality, default 100
  58329. * @param samplingModeThe post-process filtering mode
  58330. * @param engine The babylon engine
  58331. * @param reusable If the post-process is reusable
  58332. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  58333. */
  58334. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  58335. /**
  58336. * Returns the string "VolumetricLightScatteringPostProcess"
  58337. * @returns "VolumetricLightScatteringPostProcess"
  58338. */
  58339. getClassName(): string;
  58340. private _isReady;
  58341. /**
  58342. * Sets the new light position for light scattering effect
  58343. * @param position The new custom light position
  58344. */
  58345. setCustomMeshPosition(position: Vector3): void;
  58346. /**
  58347. * Returns the light position for light scattering effect
  58348. * @return Vector3 The custom light position
  58349. */
  58350. getCustomMeshPosition(): Vector3;
  58351. /**
  58352. * Disposes the internal assets and detaches the post-process from the camera
  58353. */
  58354. dispose(camera: Camera): void;
  58355. /**
  58356. * Returns the render target texture used by the post-process
  58357. * @return the render target texture used by the post-process
  58358. */
  58359. getPass(): RenderTargetTexture;
  58360. private _meshExcluded;
  58361. private _createPass;
  58362. private _updateMeshScreenCoordinates;
  58363. /**
  58364. * Creates a default mesh for the Volumeric Light Scattering post-process
  58365. * @param name The mesh name
  58366. * @param scene The scene where to create the mesh
  58367. * @return the default mesh
  58368. */
  58369. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  58370. }
  58371. }
  58372. declare module BABYLON {
  58373. interface Scene {
  58374. /** @hidden (Backing field) */ private _boundingBoxRenderer: BoundingBoxRenderer;
  58375. /** @hidden (Backing field) */ private _forceShowBoundingBoxes: boolean;
  58376. /**
  58377. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  58378. */
  58379. forceShowBoundingBoxes: boolean;
  58380. /**
  58381. * Gets the bounding box renderer associated with the scene
  58382. * @returns a BoundingBoxRenderer
  58383. */
  58384. getBoundingBoxRenderer(): BoundingBoxRenderer;
  58385. }
  58386. interface AbstractMesh {
  58387. /** @hidden (Backing field) */ private _showBoundingBox: boolean;
  58388. /**
  58389. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  58390. */
  58391. showBoundingBox: boolean;
  58392. }
  58393. /**
  58394. * Component responsible of rendering the bounding box of the meshes in a scene.
  58395. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  58396. */
  58397. export class BoundingBoxRenderer implements ISceneComponent {
  58398. /**
  58399. * The component name helpfull to identify the component in the list of scene components.
  58400. */
  58401. readonly name: string;
  58402. /**
  58403. * The scene the component belongs to.
  58404. */
  58405. scene: Scene;
  58406. /**
  58407. * Color of the bounding box lines placed in front of an object
  58408. */
  58409. frontColor: Color3;
  58410. /**
  58411. * Color of the bounding box lines placed behind an object
  58412. */
  58413. backColor: Color3;
  58414. /**
  58415. * Defines if the renderer should show the back lines or not
  58416. */
  58417. showBackLines: boolean;
  58418. /**
  58419. * @hidden
  58420. */
  58421. renderList: SmartArray<BoundingBox>;
  58422. private _colorShader;
  58423. private _vertexBuffers;
  58424. private _indexBuffer;
  58425. private _fillIndexBuffer;
  58426. private _fillIndexData;
  58427. /**
  58428. * Instantiates a new bounding box renderer in a scene.
  58429. * @param scene the scene the renderer renders in
  58430. */
  58431. constructor(scene: Scene);
  58432. /**
  58433. * Registers the component in a given scene
  58434. */
  58435. register(): void;
  58436. private _evaluateSubMesh;
  58437. private _activeMesh;
  58438. private _prepareRessources;
  58439. private _createIndexBuffer;
  58440. /**
  58441. * Rebuilds the elements related to this component in case of
  58442. * context lost for instance.
  58443. */
  58444. rebuild(): void;
  58445. /**
  58446. * @hidden
  58447. */
  58448. reset(): void;
  58449. /**
  58450. * Render the bounding boxes of a specific rendering group
  58451. * @param renderingGroupId defines the rendering group to render
  58452. */
  58453. render(renderingGroupId: number): void;
  58454. /**
  58455. * In case of occlusion queries, we can render the occlusion bounding box through this method
  58456. * @param mesh Define the mesh to render the occlusion bounding box for
  58457. */
  58458. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  58459. /**
  58460. * Dispose and release the resources attached to this renderer.
  58461. */
  58462. dispose(): void;
  58463. }
  58464. }
  58465. declare module BABYLON {
  58466. /** @hidden */
  58467. export var depthPixelShader: {
  58468. name: string;
  58469. shader: string;
  58470. };
  58471. }
  58472. declare module BABYLON {
  58473. /**
  58474. * This represents a depth renderer in Babylon.
  58475. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  58476. */
  58477. export class DepthRenderer {
  58478. private _scene;
  58479. private _depthMap;
  58480. private _effect;
  58481. private readonly _storeNonLinearDepth;
  58482. private readonly _clearColor;
  58483. /** Get if the depth renderer is using packed depth or not */
  58484. readonly isPacked: boolean;
  58485. private _cachedDefines;
  58486. private _camera;
  58487. /**
  58488. * Specifiess that the depth renderer will only be used within
  58489. * the camera it is created for.
  58490. * This can help forcing its rendering during the camera processing.
  58491. */
  58492. useOnlyInActiveCamera: boolean;
  58493. /** @hidden */ private static _SceneComponentInitialization: (scene: Scene) => void;
  58494. /**
  58495. * Instantiates a depth renderer
  58496. * @param scene The scene the renderer belongs to
  58497. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  58498. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  58499. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58500. */
  58501. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  58502. /**
  58503. * Creates the depth rendering effect and checks if the effect is ready.
  58504. * @param subMesh The submesh to be used to render the depth map of
  58505. * @param useInstances If multiple world instances should be used
  58506. * @returns if the depth renderer is ready to render the depth map
  58507. */
  58508. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58509. /**
  58510. * Gets the texture which the depth map will be written to.
  58511. * @returns The depth map texture
  58512. */
  58513. getDepthMap(): RenderTargetTexture;
  58514. /**
  58515. * Disposes of the depth renderer.
  58516. */
  58517. dispose(): void;
  58518. }
  58519. }
  58520. declare module BABYLON {
  58521. interface Scene {
  58522. /** @hidden (Backing field) */ private _depthRenderer: {
  58523. [id: string]: DepthRenderer;
  58524. };
  58525. /**
  58526. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  58527. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  58528. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  58529. * @returns the created depth renderer
  58530. */
  58531. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  58532. /**
  58533. * Disables a depth renderer for a given camera
  58534. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  58535. */
  58536. disableDepthRenderer(camera?: Nullable<Camera>): void;
  58537. }
  58538. /**
  58539. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  58540. * in several rendering techniques.
  58541. */
  58542. export class DepthRendererSceneComponent implements ISceneComponent {
  58543. /**
  58544. * The component name helpfull to identify the component in the list of scene components.
  58545. */
  58546. readonly name: string;
  58547. /**
  58548. * The scene the component belongs to.
  58549. */
  58550. scene: Scene;
  58551. /**
  58552. * Creates a new instance of the component for the given scene
  58553. * @param scene Defines the scene to register the component in
  58554. */
  58555. constructor(scene: Scene);
  58556. /**
  58557. * Registers the component in a given scene
  58558. */
  58559. register(): void;
  58560. /**
  58561. * Rebuilds the elements related to this component in case of
  58562. * context lost for instance.
  58563. */
  58564. rebuild(): void;
  58565. /**
  58566. * Disposes the component and the associated ressources
  58567. */
  58568. dispose(): void;
  58569. private _gatherRenderTargets;
  58570. private _gatherActiveCameraRenderTargets;
  58571. }
  58572. }
  58573. declare module BABYLON {
  58574. /** @hidden */
  58575. export var outlinePixelShader: {
  58576. name: string;
  58577. shader: string;
  58578. };
  58579. }
  58580. declare module BABYLON {
  58581. /** @hidden */
  58582. export var outlineVertexShader: {
  58583. name: string;
  58584. shader: string;
  58585. };
  58586. }
  58587. declare module BABYLON {
  58588. interface Scene {
  58589. /** @hidden */ private _outlineRenderer: OutlineRenderer;
  58590. /**
  58591. * Gets the outline renderer associated with the scene
  58592. * @returns a OutlineRenderer
  58593. */
  58594. getOutlineRenderer(): OutlineRenderer;
  58595. }
  58596. interface AbstractMesh {
  58597. /** @hidden (Backing field) */ private _renderOutline: boolean;
  58598. /**
  58599. * Gets or sets a boolean indicating if the outline must be rendered as well
  58600. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  58601. */
  58602. renderOutline: boolean;
  58603. /** @hidden (Backing field) */ private _renderOverlay: boolean;
  58604. /**
  58605. * Gets or sets a boolean indicating if the overlay must be rendered as well
  58606. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  58607. */
  58608. renderOverlay: boolean;
  58609. }
  58610. /**
  58611. * This class is responsible to draw bothe outline/overlay of meshes.
  58612. * It should not be used directly but through the available method on mesh.
  58613. */
  58614. export class OutlineRenderer implements ISceneComponent {
  58615. /**
  58616. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  58617. */
  58618. private static _StencilReference;
  58619. /**
  58620. * The name of the component. Each component must have a unique name.
  58621. */
  58622. name: string;
  58623. /**
  58624. * The scene the component belongs to.
  58625. */
  58626. scene: Scene;
  58627. /**
  58628. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  58629. */
  58630. zOffset: number;
  58631. private _engine;
  58632. private _effect;
  58633. private _cachedDefines;
  58634. private _savedDepthWrite;
  58635. /**
  58636. * Instantiates a new outline renderer. (There could be only one per scene).
  58637. * @param scene Defines the scene it belongs to
  58638. */
  58639. constructor(scene: Scene);
  58640. /**
  58641. * Register the component to one instance of a scene.
  58642. */
  58643. register(): void;
  58644. /**
  58645. * Rebuilds the elements related to this component in case of
  58646. * context lost for instance.
  58647. */
  58648. rebuild(): void;
  58649. /**
  58650. * Disposes the component and the associated ressources.
  58651. */
  58652. dispose(): void;
  58653. /**
  58654. * Renders the outline in the canvas.
  58655. * @param subMesh Defines the sumesh to render
  58656. * @param batch Defines the batch of meshes in case of instances
  58657. * @param useOverlay Defines if the rendering is for the overlay or the outline
  58658. */
  58659. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  58660. /**
  58661. * Returns whether or not the outline renderer is ready for a given submesh.
  58662. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  58663. * @param subMesh Defines the submesh to check readyness for
  58664. * @param useInstances Defines wheter wee are trying to render instances or not
  58665. * @returns true if ready otherwise false
  58666. */
  58667. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  58668. private _beforeRenderingMesh;
  58669. private _afterRenderingMesh;
  58670. }
  58671. }
  58672. declare module BABYLON {
  58673. /**
  58674. * Class used to manage multiple sprites of different sizes on the same spritesheet
  58675. * @see http://doc.babylonjs.com/babylon101/sprites
  58676. */
  58677. export class SpritePackedManager extends SpriteManager {
  58678. /** defines the packed manager's name */
  58679. name: string;
  58680. /**
  58681. * Creates a new sprite manager from a packed sprite sheet
  58682. * @param name defines the manager's name
  58683. * @param imgUrl defines the sprite sheet url
  58684. * @param capacity defines the maximum allowed number of sprites
  58685. * @param scene defines the hosting scene
  58686. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  58687. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  58688. * @param samplingMode defines the smapling mode to use with spritesheet
  58689. * @param fromPacked set to true; do not alter
  58690. */
  58691. constructor(
  58692. /** defines the packed manager's name */
  58693. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  58694. }
  58695. }
  58696. declare module BABYLON {
  58697. /**
  58698. * Defines the list of states available for a task inside a AssetsManager
  58699. */
  58700. export enum AssetTaskState {
  58701. /**
  58702. * Initialization
  58703. */
  58704. INIT = 0,
  58705. /**
  58706. * Running
  58707. */
  58708. RUNNING = 1,
  58709. /**
  58710. * Done
  58711. */
  58712. DONE = 2,
  58713. /**
  58714. * Error
  58715. */
  58716. ERROR = 3
  58717. }
  58718. /**
  58719. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  58720. */
  58721. export abstract class AbstractAssetTask {
  58722. /**
  58723. * Task name
  58724. */ name: string;
  58725. /**
  58726. * Callback called when the task is successful
  58727. */
  58728. onSuccess: (task: any) => void;
  58729. /**
  58730. * Callback called when the task is not successful
  58731. */
  58732. onError: (task: any, message?: string, exception?: any) => void;
  58733. /**
  58734. * Creates a new AssetsManager
  58735. * @param name defines the name of the task
  58736. */
  58737. constructor(
  58738. /**
  58739. * Task name
  58740. */ name: string);
  58741. private _isCompleted;
  58742. private _taskState;
  58743. private _errorObject;
  58744. /**
  58745. * Get if the task is completed
  58746. */
  58747. readonly isCompleted: boolean;
  58748. /**
  58749. * Gets the current state of the task
  58750. */
  58751. readonly taskState: AssetTaskState;
  58752. /**
  58753. * Gets the current error object (if task is in error)
  58754. */
  58755. readonly errorObject: {
  58756. message?: string;
  58757. exception?: any;
  58758. };
  58759. /**
  58760. * Internal only
  58761. * @hidden
  58762. */ private _setErrorObject(message?: string, exception?: any): void;
  58763. /**
  58764. * Execute the current task
  58765. * @param scene defines the scene where you want your assets to be loaded
  58766. * @param onSuccess is a callback called when the task is successfully executed
  58767. * @param onError is a callback called if an error occurs
  58768. */
  58769. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58770. /**
  58771. * Execute the current task
  58772. * @param scene defines the scene where you want your assets to be loaded
  58773. * @param onSuccess is a callback called when the task is successfully executed
  58774. * @param onError is a callback called if an error occurs
  58775. */
  58776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58777. /**
  58778. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  58779. * This can be used with failed tasks that have the reason for failure fixed.
  58780. */
  58781. reset(): void;
  58782. private onErrorCallback;
  58783. private onDoneCallback;
  58784. }
  58785. /**
  58786. * Define the interface used by progress events raised during assets loading
  58787. */
  58788. export interface IAssetsProgressEvent {
  58789. /**
  58790. * Defines the number of remaining tasks to process
  58791. */
  58792. remainingCount: number;
  58793. /**
  58794. * Defines the total number of tasks
  58795. */
  58796. totalCount: number;
  58797. /**
  58798. * Defines the task that was just processed
  58799. */
  58800. task: AbstractAssetTask;
  58801. }
  58802. /**
  58803. * Class used to share progress information about assets loading
  58804. */
  58805. export class AssetsProgressEvent implements IAssetsProgressEvent {
  58806. /**
  58807. * Defines the number of remaining tasks to process
  58808. */
  58809. remainingCount: number;
  58810. /**
  58811. * Defines the total number of tasks
  58812. */
  58813. totalCount: number;
  58814. /**
  58815. * Defines the task that was just processed
  58816. */
  58817. task: AbstractAssetTask;
  58818. /**
  58819. * Creates a AssetsProgressEvent
  58820. * @param remainingCount defines the number of remaining tasks to process
  58821. * @param totalCount defines the total number of tasks
  58822. * @param task defines the task that was just processed
  58823. */
  58824. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  58825. }
  58826. /**
  58827. * Define a task used by AssetsManager to load meshes
  58828. */
  58829. export class MeshAssetTask extends AbstractAssetTask {
  58830. /**
  58831. * Defines the name of the task
  58832. */
  58833. name: string;
  58834. /**
  58835. * Defines the list of mesh's names you want to load
  58836. */
  58837. meshesNames: any;
  58838. /**
  58839. * Defines the root url to use as a base to load your meshes and associated resources
  58840. */
  58841. rootUrl: string;
  58842. /**
  58843. * Defines the filename of the scene to load from
  58844. */
  58845. sceneFilename: string;
  58846. /**
  58847. * Gets the list of loaded meshes
  58848. */
  58849. loadedMeshes: Array<AbstractMesh>;
  58850. /**
  58851. * Gets the list of loaded particle systems
  58852. */
  58853. loadedParticleSystems: Array<IParticleSystem>;
  58854. /**
  58855. * Gets the list of loaded skeletons
  58856. */
  58857. loadedSkeletons: Array<Skeleton>;
  58858. /**
  58859. * Gets the list of loaded animation groups
  58860. */
  58861. loadedAnimationGroups: Array<AnimationGroup>;
  58862. /**
  58863. * Callback called when the task is successful
  58864. */
  58865. onSuccess: (task: MeshAssetTask) => void;
  58866. /**
  58867. * Callback called when the task is successful
  58868. */
  58869. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  58870. /**
  58871. * Creates a new MeshAssetTask
  58872. * @param name defines the name of the task
  58873. * @param meshesNames defines the list of mesh's names you want to load
  58874. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  58875. * @param sceneFilename defines the filename of the scene to load from
  58876. */
  58877. constructor(
  58878. /**
  58879. * Defines the name of the task
  58880. */
  58881. name: string,
  58882. /**
  58883. * Defines the list of mesh's names you want to load
  58884. */
  58885. meshesNames: any,
  58886. /**
  58887. * Defines the root url to use as a base to load your meshes and associated resources
  58888. */
  58889. rootUrl: string,
  58890. /**
  58891. * Defines the filename of the scene to load from
  58892. */
  58893. sceneFilename: string);
  58894. /**
  58895. * Execute the current task
  58896. * @param scene defines the scene where you want your assets to be loaded
  58897. * @param onSuccess is a callback called when the task is successfully executed
  58898. * @param onError is a callback called if an error occurs
  58899. */
  58900. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58901. }
  58902. /**
  58903. * Define a task used by AssetsManager to load text content
  58904. */
  58905. export class TextFileAssetTask extends AbstractAssetTask {
  58906. /**
  58907. * Defines the name of the task
  58908. */
  58909. name: string;
  58910. /**
  58911. * Defines the location of the file to load
  58912. */
  58913. url: string;
  58914. /**
  58915. * Gets the loaded text string
  58916. */
  58917. text: string;
  58918. /**
  58919. * Callback called when the task is successful
  58920. */
  58921. onSuccess: (task: TextFileAssetTask) => void;
  58922. /**
  58923. * Callback called when the task is successful
  58924. */
  58925. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  58926. /**
  58927. * Creates a new TextFileAssetTask object
  58928. * @param name defines the name of the task
  58929. * @param url defines the location of the file to load
  58930. */
  58931. constructor(
  58932. /**
  58933. * Defines the name of the task
  58934. */
  58935. name: string,
  58936. /**
  58937. * Defines the location of the file to load
  58938. */
  58939. url: string);
  58940. /**
  58941. * Execute the current task
  58942. * @param scene defines the scene where you want your assets to be loaded
  58943. * @param onSuccess is a callback called when the task is successfully executed
  58944. * @param onError is a callback called if an error occurs
  58945. */
  58946. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58947. }
  58948. /**
  58949. * Define a task used by AssetsManager to load binary data
  58950. */
  58951. export class BinaryFileAssetTask extends AbstractAssetTask {
  58952. /**
  58953. * Defines the name of the task
  58954. */
  58955. name: string;
  58956. /**
  58957. * Defines the location of the file to load
  58958. */
  58959. url: string;
  58960. /**
  58961. * Gets the lodaded data (as an array buffer)
  58962. */
  58963. data: ArrayBuffer;
  58964. /**
  58965. * Callback called when the task is successful
  58966. */
  58967. onSuccess: (task: BinaryFileAssetTask) => void;
  58968. /**
  58969. * Callback called when the task is successful
  58970. */
  58971. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  58972. /**
  58973. * Creates a new BinaryFileAssetTask object
  58974. * @param name defines the name of the new task
  58975. * @param url defines the location of the file to load
  58976. */
  58977. constructor(
  58978. /**
  58979. * Defines the name of the task
  58980. */
  58981. name: string,
  58982. /**
  58983. * Defines the location of the file to load
  58984. */
  58985. url: string);
  58986. /**
  58987. * Execute the current task
  58988. * @param scene defines the scene where you want your assets to be loaded
  58989. * @param onSuccess is a callback called when the task is successfully executed
  58990. * @param onError is a callback called if an error occurs
  58991. */
  58992. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58993. }
  58994. /**
  58995. * Define a task used by AssetsManager to load images
  58996. */
  58997. export class ImageAssetTask extends AbstractAssetTask {
  58998. /**
  58999. * Defines the name of the task
  59000. */
  59001. name: string;
  59002. /**
  59003. * Defines the location of the image to load
  59004. */
  59005. url: string;
  59006. /**
  59007. * Gets the loaded images
  59008. */
  59009. image: HTMLImageElement;
  59010. /**
  59011. * Callback called when the task is successful
  59012. */
  59013. onSuccess: (task: ImageAssetTask) => void;
  59014. /**
  59015. * Callback called when the task is successful
  59016. */
  59017. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  59018. /**
  59019. * Creates a new ImageAssetTask
  59020. * @param name defines the name of the task
  59021. * @param url defines the location of the image to load
  59022. */
  59023. constructor(
  59024. /**
  59025. * Defines the name of the task
  59026. */
  59027. name: string,
  59028. /**
  59029. * Defines the location of the image to load
  59030. */
  59031. url: string);
  59032. /**
  59033. * Execute the current task
  59034. * @param scene defines the scene where you want your assets to be loaded
  59035. * @param onSuccess is a callback called when the task is successfully executed
  59036. * @param onError is a callback called if an error occurs
  59037. */
  59038. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59039. }
  59040. /**
  59041. * Defines the interface used by texture loading tasks
  59042. */
  59043. export interface ITextureAssetTask<TEX extends BaseTexture> {
  59044. /**
  59045. * Gets the loaded texture
  59046. */
  59047. texture: TEX;
  59048. }
  59049. /**
  59050. * Define a task used by AssetsManager to load 2D textures
  59051. */
  59052. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  59053. /**
  59054. * Defines the name of the task
  59055. */
  59056. name: string;
  59057. /**
  59058. * Defines the location of the file to load
  59059. */
  59060. url: string;
  59061. /**
  59062. * Defines if mipmap should not be generated (default is false)
  59063. */
  59064. noMipmap?: boolean | undefined;
  59065. /**
  59066. * Defines if texture must be inverted on Y axis (default is false)
  59067. */
  59068. invertY?: boolean | undefined;
  59069. /**
  59070. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59071. */
  59072. samplingMode: number;
  59073. /**
  59074. * Gets the loaded texture
  59075. */
  59076. texture: Texture;
  59077. /**
  59078. * Callback called when the task is successful
  59079. */
  59080. onSuccess: (task: TextureAssetTask) => void;
  59081. /**
  59082. * Callback called when the task is successful
  59083. */
  59084. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  59085. /**
  59086. * Creates a new TextureAssetTask object
  59087. * @param name defines the name of the task
  59088. * @param url defines the location of the file to load
  59089. * @param noMipmap defines if mipmap should not be generated (default is false)
  59090. * @param invertY defines if texture must be inverted on Y axis (default is false)
  59091. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59092. */
  59093. constructor(
  59094. /**
  59095. * Defines the name of the task
  59096. */
  59097. name: string,
  59098. /**
  59099. * Defines the location of the file to load
  59100. */
  59101. url: string,
  59102. /**
  59103. * Defines if mipmap should not be generated (default is false)
  59104. */
  59105. noMipmap?: boolean | undefined,
  59106. /**
  59107. * Defines if texture must be inverted on Y axis (default is false)
  59108. */
  59109. invertY?: boolean | undefined,
  59110. /**
  59111. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  59112. */
  59113. samplingMode?: number);
  59114. /**
  59115. * Execute the current task
  59116. * @param scene defines the scene where you want your assets to be loaded
  59117. * @param onSuccess is a callback called when the task is successfully executed
  59118. * @param onError is a callback called if an error occurs
  59119. */
  59120. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59121. }
  59122. /**
  59123. * Define a task used by AssetsManager to load cube textures
  59124. */
  59125. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  59126. /**
  59127. * Defines the name of the task
  59128. */
  59129. name: string;
  59130. /**
  59131. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59132. */
  59133. url: string;
  59134. /**
  59135. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59136. */
  59137. extensions?: string[] | undefined;
  59138. /**
  59139. * Defines if mipmaps should not be generated (default is false)
  59140. */
  59141. noMipmap?: boolean | undefined;
  59142. /**
  59143. * Defines the explicit list of files (undefined by default)
  59144. */
  59145. files?: string[] | undefined;
  59146. /**
  59147. * Gets the loaded texture
  59148. */
  59149. texture: CubeTexture;
  59150. /**
  59151. * Callback called when the task is successful
  59152. */
  59153. onSuccess: (task: CubeTextureAssetTask) => void;
  59154. /**
  59155. * Callback called when the task is successful
  59156. */
  59157. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  59158. /**
  59159. * Creates a new CubeTextureAssetTask
  59160. * @param name defines the name of the task
  59161. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59162. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59163. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59164. * @param files defines the explicit list of files (undefined by default)
  59165. */
  59166. constructor(
  59167. /**
  59168. * Defines the name of the task
  59169. */
  59170. name: string,
  59171. /**
  59172. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  59173. */
  59174. url: string,
  59175. /**
  59176. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  59177. */
  59178. extensions?: string[] | undefined,
  59179. /**
  59180. * Defines if mipmaps should not be generated (default is false)
  59181. */
  59182. noMipmap?: boolean | undefined,
  59183. /**
  59184. * Defines the explicit list of files (undefined by default)
  59185. */
  59186. files?: string[] | undefined);
  59187. /**
  59188. * Execute the current task
  59189. * @param scene defines the scene where you want your assets to be loaded
  59190. * @param onSuccess is a callback called when the task is successfully executed
  59191. * @param onError is a callback called if an error occurs
  59192. */
  59193. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59194. }
  59195. /**
  59196. * Define a task used by AssetsManager to load HDR cube textures
  59197. */
  59198. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  59199. /**
  59200. * Defines the name of the task
  59201. */
  59202. name: string;
  59203. /**
  59204. * Defines the location of the file to load
  59205. */
  59206. url: string;
  59207. /**
  59208. * Defines the desired size (the more it increases the longer the generation will be)
  59209. */
  59210. size: number;
  59211. /**
  59212. * Defines if mipmaps should not be generated (default is false)
  59213. */
  59214. noMipmap: boolean;
  59215. /**
  59216. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59217. */
  59218. generateHarmonics: boolean;
  59219. /**
  59220. * 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)
  59221. */
  59222. gammaSpace: boolean;
  59223. /**
  59224. * Internal Use Only
  59225. */
  59226. reserved: boolean;
  59227. /**
  59228. * Gets the loaded texture
  59229. */
  59230. texture: HDRCubeTexture;
  59231. /**
  59232. * Callback called when the task is successful
  59233. */
  59234. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  59235. /**
  59236. * Callback called when the task is successful
  59237. */
  59238. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  59239. /**
  59240. * Creates a new HDRCubeTextureAssetTask object
  59241. * @param name defines the name of the task
  59242. * @param url defines the location of the file to load
  59243. * @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.
  59244. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59245. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59246. * @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)
  59247. * @param reserved Internal use only
  59248. */
  59249. constructor(
  59250. /**
  59251. * Defines the name of the task
  59252. */
  59253. name: string,
  59254. /**
  59255. * Defines the location of the file to load
  59256. */
  59257. url: string,
  59258. /**
  59259. * Defines the desired size (the more it increases the longer the generation will be)
  59260. */
  59261. size: number,
  59262. /**
  59263. * Defines if mipmaps should not be generated (default is false)
  59264. */
  59265. noMipmap?: boolean,
  59266. /**
  59267. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  59268. */
  59269. generateHarmonics?: boolean,
  59270. /**
  59271. * 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)
  59272. */
  59273. gammaSpace?: boolean,
  59274. /**
  59275. * Internal Use Only
  59276. */
  59277. reserved?: boolean);
  59278. /**
  59279. * Execute the current task
  59280. * @param scene defines the scene where you want your assets to be loaded
  59281. * @param onSuccess is a callback called when the task is successfully executed
  59282. * @param onError is a callback called if an error occurs
  59283. */
  59284. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59285. }
  59286. /**
  59287. * Define a task used by AssetsManager to load Equirectangular cube textures
  59288. */
  59289. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  59290. /**
  59291. * Defines the name of the task
  59292. */
  59293. name: string;
  59294. /**
  59295. * Defines the location of the file to load
  59296. */
  59297. url: string;
  59298. /**
  59299. * Defines the desired size (the more it increases the longer the generation will be)
  59300. */
  59301. size: number;
  59302. /**
  59303. * Defines if mipmaps should not be generated (default is false)
  59304. */
  59305. noMipmap: boolean;
  59306. /**
  59307. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59308. * but the standard material would require them in Gamma space) (default is true)
  59309. */
  59310. gammaSpace: boolean;
  59311. /**
  59312. * Gets the loaded texture
  59313. */
  59314. texture: EquiRectangularCubeTexture;
  59315. /**
  59316. * Callback called when the task is successful
  59317. */
  59318. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  59319. /**
  59320. * Callback called when the task is successful
  59321. */
  59322. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  59323. /**
  59324. * Creates a new EquiRectangularCubeTextureAssetTask object
  59325. * @param name defines the name of the task
  59326. * @param url defines the location of the file to load
  59327. * @param size defines the desired size (the more it increases the longer the generation will be)
  59328. * If the size is omitted this implies you are using a preprocessed cubemap.
  59329. * @param noMipmap defines if mipmaps should not be generated (default is false)
  59330. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  59331. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  59332. * (default is true)
  59333. */
  59334. constructor(
  59335. /**
  59336. * Defines the name of the task
  59337. */
  59338. name: string,
  59339. /**
  59340. * Defines the location of the file to load
  59341. */
  59342. url: string,
  59343. /**
  59344. * Defines the desired size (the more it increases the longer the generation will be)
  59345. */
  59346. size: number,
  59347. /**
  59348. * Defines if mipmaps should not be generated (default is false)
  59349. */
  59350. noMipmap?: boolean,
  59351. /**
  59352. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  59353. * but the standard material would require them in Gamma space) (default is true)
  59354. */
  59355. gammaSpace?: boolean);
  59356. /**
  59357. * Execute the current task
  59358. * @param scene defines the scene where you want your assets to be loaded
  59359. * @param onSuccess is a callback called when the task is successfully executed
  59360. * @param onError is a callback called if an error occurs
  59361. */
  59362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  59363. }
  59364. /**
  59365. * This class can be used to easily import assets into a scene
  59366. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  59367. */
  59368. export class AssetsManager {
  59369. private _scene;
  59370. private _isLoading;
  59371. protected _tasks: AbstractAssetTask[];
  59372. protected _waitingTasksCount: number;
  59373. protected _totalTasksCount: number;
  59374. /**
  59375. * Callback called when all tasks are processed
  59376. */
  59377. onFinish: (tasks: AbstractAssetTask[]) => void;
  59378. /**
  59379. * Callback called when a task is successful
  59380. */
  59381. onTaskSuccess: (task: AbstractAssetTask) => void;
  59382. /**
  59383. * Callback called when a task had an error
  59384. */
  59385. onTaskError: (task: AbstractAssetTask) => void;
  59386. /**
  59387. * Callback called when a task is done (whatever the result is)
  59388. */
  59389. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  59390. /**
  59391. * Observable called when all tasks are processed
  59392. */
  59393. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  59394. /**
  59395. * Observable called when a task had an error
  59396. */
  59397. onTaskErrorObservable: Observable<AbstractAssetTask>;
  59398. /**
  59399. * Observable called when all tasks were executed
  59400. */
  59401. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  59402. /**
  59403. * Observable called when a task is done (whatever the result is)
  59404. */
  59405. onProgressObservable: Observable<IAssetsProgressEvent>;
  59406. /**
  59407. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  59408. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  59409. */
  59410. useDefaultLoadingScreen: boolean;
  59411. /**
  59412. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  59413. * when all assets have been downloaded.
  59414. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  59415. */
  59416. autoHideLoadingUI: boolean;
  59417. /**
  59418. * Creates a new AssetsManager
  59419. * @param scene defines the scene to work on
  59420. */
  59421. constructor(scene: Scene);
  59422. /**
  59423. * Add a MeshAssetTask to the list of active tasks
  59424. * @param taskName defines the name of the new task
  59425. * @param meshesNames defines the name of meshes to load
  59426. * @param rootUrl defines the root url to use to locate files
  59427. * @param sceneFilename defines the filename of the scene file
  59428. * @returns a new MeshAssetTask object
  59429. */
  59430. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  59431. /**
  59432. * Add a TextFileAssetTask to the list of active tasks
  59433. * @param taskName defines the name of the new task
  59434. * @param url defines the url of the file to load
  59435. * @returns a new TextFileAssetTask object
  59436. */
  59437. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  59438. /**
  59439. * Add a BinaryFileAssetTask to the list of active tasks
  59440. * @param taskName defines the name of the new task
  59441. * @param url defines the url of the file to load
  59442. * @returns a new BinaryFileAssetTask object
  59443. */
  59444. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  59445. /**
  59446. * Add a ImageAssetTask to the list of active tasks
  59447. * @param taskName defines the name of the new task
  59448. * @param url defines the url of the file to load
  59449. * @returns a new ImageAssetTask object
  59450. */
  59451. addImageTask(taskName: string, url: string): ImageAssetTask;
  59452. /**
  59453. * Add a TextureAssetTask to the list of active tasks
  59454. * @param taskName defines the name of the new task
  59455. * @param url defines the url of the file to load
  59456. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59457. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  59458. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59459. * @returns a new TextureAssetTask object
  59460. */
  59461. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  59462. /**
  59463. * Add a CubeTextureAssetTask to the list of active tasks
  59464. * @param taskName defines the name of the new task
  59465. * @param url defines the url of the file to load
  59466. * @param extensions defines the extension to use to load the cube map (can be null)
  59467. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59468. * @param files defines the list of files to load (can be null)
  59469. * @returns a new CubeTextureAssetTask object
  59470. */
  59471. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  59472. /**
  59473. *
  59474. * Add a HDRCubeTextureAssetTask to the list of active tasks
  59475. * @param taskName defines the name of the new task
  59476. * @param url defines the url of the file to load
  59477. * @param size defines the size you want for the cubemap (can be null)
  59478. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59479. * @param generateHarmonics defines if you want to automatically generate (true by default)
  59480. * @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)
  59481. * @param reserved Internal use only
  59482. * @returns a new HDRCubeTextureAssetTask object
  59483. */
  59484. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  59485. /**
  59486. *
  59487. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  59488. * @param taskName defines the name of the new task
  59489. * @param url defines the url of the file to load
  59490. * @param size defines the size you want for the cubemap (can be null)
  59491. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  59492. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59493. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59494. * @returns a new EquiRectangularCubeTextureAssetTask object
  59495. */
  59496. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  59497. /**
  59498. * Remove a task from the assets manager.
  59499. * @param task the task to remove
  59500. */
  59501. removeTask(task: AbstractAssetTask): void;
  59502. private _decreaseWaitingTasksCount;
  59503. private _runTask;
  59504. /**
  59505. * Reset the AssetsManager and remove all tasks
  59506. * @return the current instance of the AssetsManager
  59507. */
  59508. reset(): AssetsManager;
  59509. /**
  59510. * Start the loading process
  59511. * @return the current instance of the AssetsManager
  59512. */
  59513. load(): AssetsManager;
  59514. /**
  59515. * Start the loading process as an async operation
  59516. * @return a promise returning the list of failed tasks
  59517. */
  59518. loadAsync(): Promise<void>;
  59519. }
  59520. }
  59521. declare module BABYLON {
  59522. /**
  59523. * Wrapper class for promise with external resolve and reject.
  59524. */
  59525. export class Deferred<T> {
  59526. /**
  59527. * The promise associated with this deferred object.
  59528. */
  59529. readonly promise: Promise<T>;
  59530. private _resolve;
  59531. private _reject;
  59532. /**
  59533. * The resolve method of the promise associated with this deferred object.
  59534. */
  59535. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  59536. /**
  59537. * The reject method of the promise associated with this deferred object.
  59538. */
  59539. readonly reject: (reason?: any) => void;
  59540. /**
  59541. * Constructor for this deferred object.
  59542. */
  59543. constructor();
  59544. }
  59545. }
  59546. declare module BABYLON {
  59547. /**
  59548. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  59549. */
  59550. export class MeshExploder {
  59551. private _centerMesh;
  59552. private _meshes;
  59553. private _meshesOrigins;
  59554. private _toCenterVectors;
  59555. private _scaledDirection;
  59556. private _newPosition;
  59557. private _centerPosition;
  59558. /**
  59559. * Explodes meshes from a center mesh.
  59560. * @param meshes The meshes to explode.
  59561. * @param centerMesh The mesh to be center of explosion.
  59562. */
  59563. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  59564. private _setCenterMesh;
  59565. /**
  59566. * Get class name
  59567. * @returns "MeshExploder"
  59568. */
  59569. getClassName(): string;
  59570. /**
  59571. * "Exploded meshes"
  59572. * @returns Array of meshes with the centerMesh at index 0.
  59573. */
  59574. getMeshes(): Array<Mesh>;
  59575. /**
  59576. * Explodes meshes giving a specific direction
  59577. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  59578. */
  59579. explode(direction?: number): void;
  59580. }
  59581. }
  59582. declare module BABYLON {
  59583. /**
  59584. * Class used to help managing file picking and drag'n'drop
  59585. */
  59586. export class FilesInput {
  59587. /**
  59588. * List of files ready to be loaded
  59589. */
  59590. static readonly FilesToLoad: {
  59591. [key: string]: File;
  59592. };
  59593. /**
  59594. * Callback called when a file is processed
  59595. */
  59596. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  59597. private _engine;
  59598. private _currentScene;
  59599. private _sceneLoadedCallback;
  59600. private _progressCallback;
  59601. private _additionalRenderLoopLogicCallback;
  59602. private _textureLoadingCallback;
  59603. private _startingProcessingFilesCallback;
  59604. private _onReloadCallback;
  59605. private _errorCallback;
  59606. private _elementToMonitor;
  59607. private _sceneFileToLoad;
  59608. private _filesToLoad;
  59609. /**
  59610. * Creates a new FilesInput
  59611. * @param engine defines the rendering engine
  59612. * @param scene defines the hosting scene
  59613. * @param sceneLoadedCallback callback called when scene is loaded
  59614. * @param progressCallback callback called to track progress
  59615. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  59616. * @param textureLoadingCallback callback called when a texture is loading
  59617. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  59618. * @param onReloadCallback callback called when a reload is requested
  59619. * @param errorCallback callback call if an error occurs
  59620. */
  59621. 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);
  59622. private _dragEnterHandler;
  59623. private _dragOverHandler;
  59624. private _dropHandler;
  59625. /**
  59626. * Calls this function to listen to drag'n'drop events on a specific DOM element
  59627. * @param elementToMonitor defines the DOM element to track
  59628. */
  59629. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  59630. /**
  59631. * Release all associated resources
  59632. */
  59633. dispose(): void;
  59634. private renderFunction;
  59635. private drag;
  59636. private drop;
  59637. private _traverseFolder;
  59638. private _processFiles;
  59639. /**
  59640. * Load files from a drop event
  59641. * @param event defines the drop event to use as source
  59642. */
  59643. loadFiles(event: any): void;
  59644. private _processReload;
  59645. /**
  59646. * Reload the current scene from the loaded files
  59647. */
  59648. reload(): void;
  59649. }
  59650. }
  59651. declare module BABYLON {
  59652. /**
  59653. * Defines the root class used to create scene optimization to use with SceneOptimizer
  59654. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59655. */
  59656. export class SceneOptimization {
  59657. /**
  59658. * Defines the priority of this optimization (0 by default which means first in the list)
  59659. */
  59660. priority: number;
  59661. /**
  59662. * Gets a string describing the action executed by the current optimization
  59663. * @returns description string
  59664. */
  59665. getDescription(): string;
  59666. /**
  59667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59668. * @param scene defines the current scene where to apply this optimization
  59669. * @param optimizer defines the current optimizer
  59670. * @returns true if everything that can be done was applied
  59671. */
  59672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59673. /**
  59674. * Creates the SceneOptimization object
  59675. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59676. * @param desc defines the description associated with the optimization
  59677. */
  59678. constructor(
  59679. /**
  59680. * Defines the priority of this optimization (0 by default which means first in the list)
  59681. */
  59682. priority?: number);
  59683. }
  59684. /**
  59685. * Defines an optimization used to reduce the size of render target textures
  59686. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59687. */
  59688. export class TextureOptimization extends SceneOptimization {
  59689. /**
  59690. * Defines the priority of this optimization (0 by default which means first in the list)
  59691. */
  59692. priority: number;
  59693. /**
  59694. * 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
  59695. */
  59696. maximumSize: number;
  59697. /**
  59698. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59699. */
  59700. step: number;
  59701. /**
  59702. * Gets a string describing the action executed by the current optimization
  59703. * @returns description string
  59704. */
  59705. getDescription(): string;
  59706. /**
  59707. * Creates the TextureOptimization object
  59708. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59709. * @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
  59710. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59711. */
  59712. constructor(
  59713. /**
  59714. * Defines the priority of this optimization (0 by default which means first in the list)
  59715. */
  59716. priority?: number,
  59717. /**
  59718. * 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
  59719. */
  59720. maximumSize?: number,
  59721. /**
  59722. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  59723. */
  59724. step?: number);
  59725. /**
  59726. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59727. * @param scene defines the current scene where to apply this optimization
  59728. * @param optimizer defines the current optimizer
  59729. * @returns true if everything that can be done was applied
  59730. */
  59731. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59732. }
  59733. /**
  59734. * Defines an optimization used to increase or decrease the rendering resolution
  59735. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59736. */
  59737. export class HardwareScalingOptimization extends SceneOptimization {
  59738. /**
  59739. * Defines the priority of this optimization (0 by default which means first in the list)
  59740. */
  59741. priority: number;
  59742. /**
  59743. * Defines the maximum scale to use (2 by default)
  59744. */
  59745. maximumScale: number;
  59746. /**
  59747. * Defines the step to use between two passes (0.5 by default)
  59748. */
  59749. step: number;
  59750. private _currentScale;
  59751. private _directionOffset;
  59752. /**
  59753. * Gets a string describing the action executed by the current optimization
  59754. * @return description string
  59755. */
  59756. getDescription(): string;
  59757. /**
  59758. * Creates the HardwareScalingOptimization object
  59759. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59760. * @param maximumScale defines the maximum scale to use (2 by default)
  59761. * @param step defines the step to use between two passes (0.5 by default)
  59762. */
  59763. constructor(
  59764. /**
  59765. * Defines the priority of this optimization (0 by default which means first in the list)
  59766. */
  59767. priority?: number,
  59768. /**
  59769. * Defines the maximum scale to use (2 by default)
  59770. */
  59771. maximumScale?: number,
  59772. /**
  59773. * Defines the step to use between two passes (0.5 by default)
  59774. */
  59775. step?: number);
  59776. /**
  59777. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59778. * @param scene defines the current scene where to apply this optimization
  59779. * @param optimizer defines the current optimizer
  59780. * @returns true if everything that can be done was applied
  59781. */
  59782. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59783. }
  59784. /**
  59785. * Defines an optimization used to remove shadows
  59786. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59787. */
  59788. export class ShadowsOptimization extends SceneOptimization {
  59789. /**
  59790. * Gets a string describing the action executed by the current optimization
  59791. * @return description string
  59792. */
  59793. getDescription(): string;
  59794. /**
  59795. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59796. * @param scene defines the current scene where to apply this optimization
  59797. * @param optimizer defines the current optimizer
  59798. * @returns true if everything that can be done was applied
  59799. */
  59800. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59801. }
  59802. /**
  59803. * Defines an optimization used to turn post-processes off
  59804. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59805. */
  59806. export class PostProcessesOptimization extends SceneOptimization {
  59807. /**
  59808. * Gets a string describing the action executed by the current optimization
  59809. * @return description string
  59810. */
  59811. getDescription(): string;
  59812. /**
  59813. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59814. * @param scene defines the current scene where to apply this optimization
  59815. * @param optimizer defines the current optimizer
  59816. * @returns true if everything that can be done was applied
  59817. */
  59818. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59819. }
  59820. /**
  59821. * Defines an optimization used to turn lens flares off
  59822. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59823. */
  59824. export class LensFlaresOptimization extends SceneOptimization {
  59825. /**
  59826. * Gets a string describing the action executed by the current optimization
  59827. * @return description string
  59828. */
  59829. getDescription(): string;
  59830. /**
  59831. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59832. * @param scene defines the current scene where to apply this optimization
  59833. * @param optimizer defines the current optimizer
  59834. * @returns true if everything that can be done was applied
  59835. */
  59836. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59837. }
  59838. /**
  59839. * Defines an optimization based on user defined callback.
  59840. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59841. */
  59842. export class CustomOptimization extends SceneOptimization {
  59843. /**
  59844. * Callback called to apply the custom optimization.
  59845. */
  59846. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  59847. /**
  59848. * Callback called to get custom description
  59849. */
  59850. onGetDescription: () => string;
  59851. /**
  59852. * Gets a string describing the action executed by the current optimization
  59853. * @returns description string
  59854. */
  59855. getDescription(): string;
  59856. /**
  59857. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59858. * @param scene defines the current scene where to apply this optimization
  59859. * @param optimizer defines the current optimizer
  59860. * @returns true if everything that can be done was applied
  59861. */
  59862. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59863. }
  59864. /**
  59865. * Defines an optimization used to turn particles off
  59866. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59867. */
  59868. export class ParticlesOptimization extends SceneOptimization {
  59869. /**
  59870. * Gets a string describing the action executed by the current optimization
  59871. * @return description string
  59872. */
  59873. getDescription(): string;
  59874. /**
  59875. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59876. * @param scene defines the current scene where to apply this optimization
  59877. * @param optimizer defines the current optimizer
  59878. * @returns true if everything that can be done was applied
  59879. */
  59880. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59881. }
  59882. /**
  59883. * Defines an optimization used to turn render targets off
  59884. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59885. */
  59886. export class RenderTargetsOptimization extends SceneOptimization {
  59887. /**
  59888. * Gets a string describing the action executed by the current optimization
  59889. * @return description string
  59890. */
  59891. getDescription(): string;
  59892. /**
  59893. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59894. * @param scene defines the current scene where to apply this optimization
  59895. * @param optimizer defines the current optimizer
  59896. * @returns true if everything that can be done was applied
  59897. */
  59898. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  59899. }
  59900. /**
  59901. * Defines an optimization used to merge meshes with compatible materials
  59902. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59903. */
  59904. export class MergeMeshesOptimization extends SceneOptimization {
  59905. private static _UpdateSelectionTree;
  59906. /**
  59907. * Gets or sets a boolean which defines if optimization octree has to be updated
  59908. */
  59909. /**
  59910. * Gets or sets a boolean which defines if optimization octree has to be updated
  59911. */
  59912. static UpdateSelectionTree: boolean;
  59913. /**
  59914. * Gets a string describing the action executed by the current optimization
  59915. * @return description string
  59916. */
  59917. getDescription(): string;
  59918. private _canBeMerged;
  59919. /**
  59920. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  59921. * @param scene defines the current scene where to apply this optimization
  59922. * @param optimizer defines the current optimizer
  59923. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  59924. * @returns true if everything that can be done was applied
  59925. */
  59926. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  59927. }
  59928. /**
  59929. * Defines a list of options used by SceneOptimizer
  59930. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59931. */
  59932. export class SceneOptimizerOptions {
  59933. /**
  59934. * Defines the target frame rate to reach (60 by default)
  59935. */
  59936. targetFrameRate: number;
  59937. /**
  59938. * Defines the interval between two checkes (2000ms by default)
  59939. */
  59940. trackerDuration: number;
  59941. /**
  59942. * Gets the list of optimizations to apply
  59943. */
  59944. optimizations: SceneOptimization[];
  59945. /**
  59946. * Creates a new list of options used by SceneOptimizer
  59947. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  59948. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  59949. */
  59950. constructor(
  59951. /**
  59952. * Defines the target frame rate to reach (60 by default)
  59953. */
  59954. targetFrameRate?: number,
  59955. /**
  59956. * Defines the interval between two checkes (2000ms by default)
  59957. */
  59958. trackerDuration?: number);
  59959. /**
  59960. * Add a new optimization
  59961. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  59962. * @returns the current SceneOptimizerOptions
  59963. */
  59964. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  59965. /**
  59966. * Add a new custom optimization
  59967. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  59968. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  59969. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  59970. * @returns the current SceneOptimizerOptions
  59971. */
  59972. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  59973. /**
  59974. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  59975. * @param targetFrameRate defines the target frame rate (60 by default)
  59976. * @returns a SceneOptimizerOptions object
  59977. */
  59978. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59979. /**
  59980. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  59981. * @param targetFrameRate defines the target frame rate (60 by default)
  59982. * @returns a SceneOptimizerOptions object
  59983. */
  59984. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59985. /**
  59986. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  59987. * @param targetFrameRate defines the target frame rate (60 by default)
  59988. * @returns a SceneOptimizerOptions object
  59989. */
  59990. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  59991. }
  59992. /**
  59993. * Class used to run optimizations in order to reach a target frame rate
  59994. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  59995. */
  59996. export class SceneOptimizer implements IDisposable {
  59997. private _isRunning;
  59998. private _options;
  59999. private _scene;
  60000. private _currentPriorityLevel;
  60001. private _targetFrameRate;
  60002. private _trackerDuration;
  60003. private _currentFrameRate;
  60004. private _sceneDisposeObserver;
  60005. private _improvementMode;
  60006. /**
  60007. * Defines an observable called when the optimizer reaches the target frame rate
  60008. */
  60009. onSuccessObservable: Observable<SceneOptimizer>;
  60010. /**
  60011. * Defines an observable called when the optimizer enables an optimization
  60012. */
  60013. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  60014. /**
  60015. * Defines an observable called when the optimizer is not able to reach the target frame rate
  60016. */
  60017. onFailureObservable: Observable<SceneOptimizer>;
  60018. /**
  60019. * Gets a boolean indicating if the optimizer is in improvement mode
  60020. */
  60021. readonly isInImprovementMode: boolean;
  60022. /**
  60023. * Gets the current priority level (0 at start)
  60024. */
  60025. readonly currentPriorityLevel: number;
  60026. /**
  60027. * Gets the current frame rate checked by the SceneOptimizer
  60028. */
  60029. readonly currentFrameRate: number;
  60030. /**
  60031. * Gets or sets the current target frame rate (60 by default)
  60032. */
  60033. /**
  60034. * Gets or sets the current target frame rate (60 by default)
  60035. */
  60036. targetFrameRate: number;
  60037. /**
  60038. * Gets or sets the current interval between two checks (every 2000ms by default)
  60039. */
  60040. /**
  60041. * Gets or sets the current interval between two checks (every 2000ms by default)
  60042. */
  60043. trackerDuration: number;
  60044. /**
  60045. * Gets the list of active optimizations
  60046. */
  60047. readonly optimizations: SceneOptimization[];
  60048. /**
  60049. * Creates a new SceneOptimizer
  60050. * @param scene defines the scene to work on
  60051. * @param options defines the options to use with the SceneOptimizer
  60052. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  60053. * @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)
  60054. */
  60055. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  60056. /**
  60057. * Stops the current optimizer
  60058. */
  60059. stop(): void;
  60060. /**
  60061. * Reset the optimizer to initial step (current priority level = 0)
  60062. */
  60063. reset(): void;
  60064. /**
  60065. * Start the optimizer. By default it will try to reach a specific framerate
  60066. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  60067. */
  60068. start(): void;
  60069. private _checkCurrentState;
  60070. /**
  60071. * Release all resources
  60072. */
  60073. dispose(): void;
  60074. /**
  60075. * Helper function to create a SceneOptimizer with one single line of code
  60076. * @param scene defines the scene to work on
  60077. * @param options defines the options to use with the SceneOptimizer
  60078. * @param onSuccess defines a callback to call on success
  60079. * @param onFailure defines a callback to call on failure
  60080. * @returns the new SceneOptimizer object
  60081. */
  60082. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  60083. }
  60084. }
  60085. declare module BABYLON {
  60086. /**
  60087. * Class used to serialize a scene into a string
  60088. */
  60089. export class SceneSerializer {
  60090. /**
  60091. * Clear cache used by a previous serialization
  60092. */
  60093. static ClearCache(): void;
  60094. /**
  60095. * Serialize a scene into a JSON compatible object
  60096. * @param scene defines the scene to serialize
  60097. * @returns a JSON compatible object
  60098. */
  60099. static Serialize(scene: Scene): any;
  60100. /**
  60101. * Serialize a mesh into a JSON compatible object
  60102. * @param toSerialize defines the mesh to serialize
  60103. * @param withParents defines if parents must be serialized as well
  60104. * @param withChildren defines if children must be serialized as well
  60105. * @returns a JSON compatible object
  60106. */
  60107. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  60108. }
  60109. }
  60110. declare module BABYLON {
  60111. /**
  60112. * Class used to host texture specific utilities
  60113. */
  60114. export class TextureTools {
  60115. /**
  60116. * Uses the GPU to create a copy texture rescaled at a given size
  60117. * @param texture Texture to copy from
  60118. * @param width defines the desired width
  60119. * @param height defines the desired height
  60120. * @param useBilinearMode defines if bilinear mode has to be used
  60121. * @return the generated texture
  60122. */
  60123. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  60124. }
  60125. }
  60126. declare module BABYLON {
  60127. /**
  60128. * This represents the different options available for the video capture.
  60129. */
  60130. export interface VideoRecorderOptions {
  60131. /** Defines the mime type of the video. */
  60132. mimeType: string;
  60133. /** Defines the FPS the video should be recorded at. */
  60134. fps: number;
  60135. /** Defines the chunk size for the recording data. */
  60136. recordChunckSize: number;
  60137. /** The audio tracks to attach to the recording. */
  60138. audioTracks?: MediaStreamTrack[];
  60139. }
  60140. /**
  60141. * This can help with recording videos from BabylonJS.
  60142. * This is based on the available WebRTC functionalities of the browser.
  60143. *
  60144. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  60145. */
  60146. export class VideoRecorder {
  60147. private static readonly _defaultOptions;
  60148. /**
  60149. * Returns whether or not the VideoRecorder is available in your browser.
  60150. * @param engine Defines the Babylon Engine.
  60151. * @returns true if supported otherwise false.
  60152. */
  60153. static IsSupported(engine: Engine): boolean;
  60154. private readonly _options;
  60155. private _canvas;
  60156. private _mediaRecorder;
  60157. private _recordedChunks;
  60158. private _fileName;
  60159. private _resolve;
  60160. private _reject;
  60161. /**
  60162. * True when a recording is already in progress.
  60163. */
  60164. readonly isRecording: boolean;
  60165. /**
  60166. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  60167. * @param engine Defines the BabylonJS Engine you wish to record.
  60168. * @param options Defines options that can be used to customize the capture.
  60169. */
  60170. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  60171. /**
  60172. * Stops the current recording before the default capture timeout passed in the startRecording function.
  60173. */
  60174. stopRecording(): void;
  60175. /**
  60176. * Starts recording the canvas for a max duration specified in parameters.
  60177. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  60178. * If null no automatic download will start and you can rely on the promise to get the data back.
  60179. * @param maxDuration Defines the maximum recording time in seconds.
  60180. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  60181. * @return A promise callback at the end of the recording with the video data in Blob.
  60182. */
  60183. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  60184. /**
  60185. * Releases internal resources used during the recording.
  60186. */
  60187. dispose(): void;
  60188. private _handleDataAvailable;
  60189. private _handleError;
  60190. private _handleStop;
  60191. }
  60192. }
  60193. declare module BABYLON {
  60194. /**
  60195. * Class containing a set of static utilities functions for screenshots
  60196. */
  60197. export class ScreenshotTools {
  60198. /**
  60199. * Captures a screenshot of the current rendering
  60200. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60201. * @param engine defines the rendering engine
  60202. * @param camera defines the source camera
  60203. * @param size This parameter can be set to a single number or to an object with the
  60204. * following (optional) properties: precision, width, height. If a single number is passed,
  60205. * it will be used for both width and height. If an object is passed, the screenshot size
  60206. * will be derived from the parameters. The precision property is a multiplier allowing
  60207. * rendering at a higher or lower resolution
  60208. * @param successCallback defines the callback receives a single parameter which contains the
  60209. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60210. * src parameter of an <img> to display it
  60211. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60212. * Check your browser for supported MIME types
  60213. */
  60214. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  60215. /**
  60216. * Captures a screenshot of the current rendering
  60217. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60218. * @param engine defines the rendering engine
  60219. * @param camera defines the source camera
  60220. * @param size This parameter can be set to a single number or to an object with the
  60221. * following (optional) properties: precision, width, height. If a single number is passed,
  60222. * it will be used for both width and height. If an object is passed, the screenshot size
  60223. * will be derived from the parameters. The precision property is a multiplier allowing
  60224. * rendering at a higher or lower resolution
  60225. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  60226. * Check your browser for supported MIME types
  60227. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60228. * to the src parameter of an <img> to display it
  60229. */
  60230. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  60231. /**
  60232. * Generates an image screenshot from the specified camera.
  60233. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60234. * @param engine The engine to use for rendering
  60235. * @param camera The camera to use for rendering
  60236. * @param size This parameter can be set to a single number or to an object with the
  60237. * following (optional) properties: precision, width, height. If a single number is passed,
  60238. * it will be used for both width and height. If an object is passed, the screenshot size
  60239. * will be derived from the parameters. The precision property is a multiplier allowing
  60240. * rendering at a higher or lower resolution
  60241. * @param successCallback The callback receives a single parameter which contains the
  60242. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  60243. * src parameter of an <img> to display it
  60244. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60245. * Check your browser for supported MIME types
  60246. * @param samples Texture samples (default: 1)
  60247. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60248. * @param fileName A name for for the downloaded file.
  60249. */
  60250. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  60251. /**
  60252. * Generates an image screenshot from the specified camera.
  60253. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  60254. * @param engine The engine to use for rendering
  60255. * @param camera The camera to use for rendering
  60256. * @param size This parameter can be set to a single number or to an object with the
  60257. * following (optional) properties: precision, width, height. If a single number is passed,
  60258. * it will be used for both width and height. If an object is passed, the screenshot size
  60259. * will be derived from the parameters. The precision property is a multiplier allowing
  60260. * rendering at a higher or lower resolution
  60261. * @param mimeType The MIME type of the screenshot image (default: image/png).
  60262. * Check your browser for supported MIME types
  60263. * @param samples Texture samples (default: 1)
  60264. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  60265. * @param fileName A name for for the downloaded file.
  60266. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  60267. * to the src parameter of an <img> to display it
  60268. */
  60269. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  60270. /**
  60271. * Gets height and width for screenshot size
  60272. * @private
  60273. */
  60274. private static _getScreenshotSize;
  60275. }
  60276. }
  60277. declare module BABYLON {
  60278. /**
  60279. * A cursor which tracks a point on a path
  60280. */
  60281. export class PathCursor {
  60282. private path;
  60283. /**
  60284. * Stores path cursor callbacks for when an onchange event is triggered
  60285. */
  60286. private _onchange;
  60287. /**
  60288. * The value of the path cursor
  60289. */
  60290. value: number;
  60291. /**
  60292. * The animation array of the path cursor
  60293. */
  60294. animations: Animation[];
  60295. /**
  60296. * Initializes the path cursor
  60297. * @param path The path to track
  60298. */
  60299. constructor(path: Path2);
  60300. /**
  60301. * Gets the cursor point on the path
  60302. * @returns A point on the path cursor at the cursor location
  60303. */
  60304. getPoint(): Vector3;
  60305. /**
  60306. * Moves the cursor ahead by the step amount
  60307. * @param step The amount to move the cursor forward
  60308. * @returns This path cursor
  60309. */
  60310. moveAhead(step?: number): PathCursor;
  60311. /**
  60312. * Moves the cursor behind by the step amount
  60313. * @param step The amount to move the cursor back
  60314. * @returns This path cursor
  60315. */
  60316. moveBack(step?: number): PathCursor;
  60317. /**
  60318. * Moves the cursor by the step amount
  60319. * If the step amount is greater than one, an exception is thrown
  60320. * @param step The amount to move the cursor
  60321. * @returns This path cursor
  60322. */
  60323. move(step: number): PathCursor;
  60324. /**
  60325. * Ensures that the value is limited between zero and one
  60326. * @returns This path cursor
  60327. */
  60328. private ensureLimits;
  60329. /**
  60330. * Runs onchange callbacks on change (used by the animation engine)
  60331. * @returns This path cursor
  60332. */
  60333. private raiseOnChange;
  60334. /**
  60335. * Executes a function on change
  60336. * @param f A path cursor onchange callback
  60337. * @returns This path cursor
  60338. */
  60339. onchange(f: (cursor: PathCursor) => void): PathCursor;
  60340. }
  60341. }
  60342. declare module BABYLON {
  60343. /** @hidden */
  60344. export var blurPixelShader: {
  60345. name: string;
  60346. shader: string;
  60347. };
  60348. }
  60349. declare module BABYLON {
  60350. /** @hidden */
  60351. export var pointCloudVertexDeclaration: {
  60352. name: string;
  60353. shader: string;
  60354. };
  60355. }
  60356. // Mixins
  60357. interface Window {
  60358. mozIndexedDB: IDBFactory;
  60359. webkitIndexedDB: IDBFactory;
  60360. msIndexedDB: IDBFactory;
  60361. webkitURL: typeof URL;
  60362. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  60363. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  60364. WebGLRenderingContext: WebGLRenderingContext;
  60365. MSGesture: MSGesture;
  60366. CANNON: any;
  60367. AudioContext: AudioContext;
  60368. webkitAudioContext: AudioContext;
  60369. PointerEvent: any;
  60370. Math: Math;
  60371. Uint8Array: Uint8ArrayConstructor;
  60372. Float32Array: Float32ArrayConstructor;
  60373. mozURL: typeof URL;
  60374. msURL: typeof URL;
  60375. VRFrameData: any; // WebVR, from specs 1.1
  60376. DracoDecoderModule: any;
  60377. setImmediate(handler: (...args: any[]) => void): number;
  60378. }
  60379. interface HTMLCanvasElement {
  60380. requestPointerLock(): void;
  60381. msRequestPointerLock?(): void;
  60382. mozRequestPointerLock?(): void;
  60383. webkitRequestPointerLock?(): void;
  60384. /** Track wether a record is in progress */
  60385. isRecording: boolean;
  60386. /** Capture Stream method defined by some browsers */
  60387. captureStream(fps?: number): MediaStream;
  60388. }
  60389. interface CanvasRenderingContext2D {
  60390. msImageSmoothingEnabled: boolean;
  60391. }
  60392. interface MouseEvent {
  60393. mozMovementX: number;
  60394. mozMovementY: number;
  60395. webkitMovementX: number;
  60396. webkitMovementY: number;
  60397. msMovementX: number;
  60398. msMovementY: number;
  60399. }
  60400. interface Navigator {
  60401. mozGetVRDevices: (any: any) => any;
  60402. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60403. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60404. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  60405. webkitGetGamepads(): Gamepad[];
  60406. msGetGamepads(): Gamepad[];
  60407. webkitGamepads(): Gamepad[];
  60408. }
  60409. interface HTMLVideoElement {
  60410. mozSrcObject: any;
  60411. }
  60412. interface Math {
  60413. fround(x: number): number;
  60414. imul(a: number, b: number): number;
  60415. }
  60416. interface WebGLRenderingContext {
  60417. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  60418. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  60419. vertexAttribDivisor(index: number, divisor: number): void;
  60420. createVertexArray(): any;
  60421. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  60422. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  60423. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  60424. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  60425. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  60426. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  60427. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  60428. // Queries
  60429. createQuery(): WebGLQuery;
  60430. deleteQuery(query: WebGLQuery): void;
  60431. beginQuery(target: number, query: WebGLQuery): void;
  60432. endQuery(target: number): void;
  60433. getQueryParameter(query: WebGLQuery, pname: number): any;
  60434. getQuery(target: number, pname: number): any;
  60435. MAX_SAMPLES: number;
  60436. RGBA8: number;
  60437. READ_FRAMEBUFFER: number;
  60438. DRAW_FRAMEBUFFER: number;
  60439. UNIFORM_BUFFER: number;
  60440. HALF_FLOAT_OES: number;
  60441. RGBA16F: number;
  60442. RGBA32F: number;
  60443. R32F: number;
  60444. RG32F: number;
  60445. RGB32F: number;
  60446. R16F: number;
  60447. RG16F: number;
  60448. RGB16F: number;
  60449. RED: number;
  60450. RG: number;
  60451. R8: number;
  60452. RG8: number;
  60453. UNSIGNED_INT_24_8: number;
  60454. DEPTH24_STENCIL8: number;
  60455. /* Multiple Render Targets */
  60456. drawBuffers(buffers: number[]): void;
  60457. readBuffer(src: number): void;
  60458. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  60459. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  60460. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  60461. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  60462. // Occlusion Query
  60463. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  60464. ANY_SAMPLES_PASSED: number;
  60465. QUERY_RESULT_AVAILABLE: number;
  60466. QUERY_RESULT: number;
  60467. }
  60468. interface WebGLProgram { private __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  60469. }
  60470. interface EXT_disjoint_timer_query {
  60471. QUERY_COUNTER_BITS_EXT: number;
  60472. TIME_ELAPSED_EXT: number;
  60473. TIMESTAMP_EXT: number;
  60474. GPU_DISJOINT_EXT: number;
  60475. QUERY_RESULT_EXT: number;
  60476. QUERY_RESULT_AVAILABLE_EXT: number;
  60477. queryCounterEXT(query: WebGLQuery, target: number): void;
  60478. createQueryEXT(): WebGLQuery;
  60479. beginQueryEXT(target: number, query: WebGLQuery): void;
  60480. endQueryEXT(target: number): void;
  60481. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  60482. deleteQueryEXT(query: WebGLQuery): void;
  60483. }
  60484. interface WebGLUniformLocation { private _currentState: any;
  60485. }
  60486. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  60487. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  60488. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  60489. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60490. interface WebGLRenderingContext {
  60491. readonly RASTERIZER_DISCARD: number;
  60492. readonly DEPTH_COMPONENT24: number;
  60493. readonly TEXTURE_3D: number;
  60494. readonly TEXTURE_2D_ARRAY: number;
  60495. readonly TEXTURE_COMPARE_FUNC: number;
  60496. readonly TEXTURE_COMPARE_MODE: number;
  60497. readonly COMPARE_REF_TO_TEXTURE: number;
  60498. readonly TEXTURE_WRAP_R: number;
  60499. readonly HALF_FLOAT: number;
  60500. readonly RGB8: number;
  60501. readonly RED_INTEGER: number;
  60502. readonly RG_INTEGER: number;
  60503. readonly RGB_INTEGER: number;
  60504. readonly RGBA_INTEGER: number;
  60505. readonly R8_SNORM: number;
  60506. readonly RG8_SNORM: number;
  60507. readonly RGB8_SNORM: number;
  60508. readonly RGBA8_SNORM: number;
  60509. readonly R8I: number;
  60510. readonly RG8I: number;
  60511. readonly RGB8I: number;
  60512. readonly RGBA8I: number;
  60513. readonly R8UI: number;
  60514. readonly RG8UI: number;
  60515. readonly RGB8UI: number;
  60516. readonly RGBA8UI: number;
  60517. readonly R16I: number;
  60518. readonly RG16I: number;
  60519. readonly RGB16I: number;
  60520. readonly RGBA16I: number;
  60521. readonly R16UI: number;
  60522. readonly RG16UI: number;
  60523. readonly RGB16UI: number;
  60524. readonly RGBA16UI: number;
  60525. readonly R32I: number;
  60526. readonly RG32I: number;
  60527. readonly RGB32I: number;
  60528. readonly RGBA32I: number;
  60529. readonly R32UI: number;
  60530. readonly RG32UI: number;
  60531. readonly RGB32UI: number;
  60532. readonly RGBA32UI: number;
  60533. readonly RGB10_A2UI: number;
  60534. readonly R11F_G11F_B10F: number;
  60535. readonly RGB9_E5: number;
  60536. readonly RGB10_A2: number;
  60537. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  60538. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  60539. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  60540. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  60541. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  60542. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  60543. 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;
  60544. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  60545. readonly TRANSFORM_FEEDBACK: number;
  60546. readonly INTERLEAVED_ATTRIBS: number;
  60547. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  60548. createTransformFeedback(): WebGLTransformFeedback;
  60549. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  60550. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  60551. beginTransformFeedback(primitiveMode: number): void;
  60552. endTransformFeedback(): void;
  60553. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  60554. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60555. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60556. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  60557. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  60558. }
  60559. interface ImageBitmap {
  60560. readonly width: number;
  60561. readonly height: number;
  60562. close(): void;
  60563. }
  60564. interface WebGLQuery extends WebGLObject {
  60565. }
  60566. declare var WebGLQuery: {
  60567. prototype: WebGLQuery;
  60568. new(): WebGLQuery;
  60569. };
  60570. interface WebGLSampler extends WebGLObject {
  60571. }
  60572. declare var WebGLSampler: {
  60573. prototype: WebGLSampler;
  60574. new(): WebGLSampler;
  60575. };
  60576. interface WebGLSync extends WebGLObject {
  60577. }
  60578. declare var WebGLSync: {
  60579. prototype: WebGLSync;
  60580. new(): WebGLSync;
  60581. };
  60582. interface WebGLTransformFeedback extends WebGLObject {
  60583. }
  60584. declare var WebGLTransformFeedback: {
  60585. prototype: WebGLTransformFeedback;
  60586. new(): WebGLTransformFeedback;
  60587. };
  60588. interface WebGLVertexArrayObject extends WebGLObject {
  60589. }
  60590. declare var WebGLVertexArrayObject: {
  60591. prototype: WebGLVertexArrayObject;
  60592. new(): WebGLVertexArrayObject;
  60593. };
  60594. // Type definitions for WebVR API
  60595. // Project: https://w3c.github.io/webvr/
  60596. // Definitions by: six a <https://github.com/lostfictions>
  60597. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  60598. interface VRDisplay extends EventTarget {
  60599. /**
  60600. * Dictionary of capabilities describing the VRDisplay.
  60601. */
  60602. readonly capabilities: VRDisplayCapabilities;
  60603. /**
  60604. * z-depth defining the far plane of the eye view frustum
  60605. * enables mapping of values in the render target depth
  60606. * attachment to scene coordinates. Initially set to 10000.0.
  60607. */
  60608. depthFar: number;
  60609. /**
  60610. * z-depth defining the near plane of the eye view frustum
  60611. * enables mapping of values in the render target depth
  60612. * attachment to scene coordinates. Initially set to 0.01.
  60613. */
  60614. depthNear: number;
  60615. /**
  60616. * An identifier for this distinct VRDisplay. Used as an
  60617. * association point in the Gamepad API.
  60618. */
  60619. readonly displayId: number;
  60620. /**
  60621. * A display name, a user-readable name identifying it.
  60622. */
  60623. readonly displayName: string;
  60624. readonly isConnected: boolean;
  60625. readonly isPresenting: boolean;
  60626. /**
  60627. * If this VRDisplay supports room-scale experiences, the optional
  60628. * stage attribute contains details on the room-scale parameters.
  60629. */
  60630. readonly stageParameters: VRStageParameters | null;
  60631. /**
  60632. * Passing the value returned by `requestAnimationFrame` to
  60633. * `cancelAnimationFrame` will unregister the callback.
  60634. * @param handle Define the hanle of the request to cancel
  60635. */
  60636. cancelAnimationFrame(handle: number): void;
  60637. /**
  60638. * Stops presenting to the VRDisplay.
  60639. * @returns a promise to know when it stopped
  60640. */
  60641. exitPresent(): Promise<void>;
  60642. /**
  60643. * Return the current VREyeParameters for the given eye.
  60644. * @param whichEye Define the eye we want the parameter for
  60645. * @returns the eye parameters
  60646. */
  60647. getEyeParameters(whichEye: string): VREyeParameters;
  60648. /**
  60649. * Populates the passed VRFrameData with the information required to render
  60650. * the current frame.
  60651. * @param frameData Define the data structure to populate
  60652. * @returns true if ok otherwise false
  60653. */
  60654. getFrameData(frameData: VRFrameData): boolean;
  60655. /**
  60656. * Get the layers currently being presented.
  60657. * @returns the list of VR layers
  60658. */
  60659. getLayers(): VRLayer[];
  60660. /**
  60661. * Return a VRPose containing the future predicted pose of the VRDisplay
  60662. * when the current frame will be presented. The value returned will not
  60663. * change until JavaScript has returned control to the browser.
  60664. *
  60665. * The VRPose will contain the position, orientation, velocity,
  60666. * and acceleration of each of these properties.
  60667. * @returns the pose object
  60668. */
  60669. getPose(): VRPose;
  60670. /**
  60671. * Return the current instantaneous pose of the VRDisplay, with no
  60672. * prediction applied.
  60673. * @returns the current instantaneous pose
  60674. */
  60675. getImmediatePose(): VRPose;
  60676. /**
  60677. * The callback passed to `requestAnimationFrame` will be called
  60678. * any time a new frame should be rendered. When the VRDisplay is
  60679. * presenting the callback will be called at the native refresh
  60680. * rate of the HMD. When not presenting this function acts
  60681. * identically to how window.requestAnimationFrame acts. Content should
  60682. * make no assumptions of frame rate or vsync behavior as the HMD runs
  60683. * asynchronously from other displays and at differing refresh rates.
  60684. * @param callback Define the eaction to run next frame
  60685. * @returns the request handle it
  60686. */
  60687. requestAnimationFrame(callback: FrameRequestCallback): number;
  60688. /**
  60689. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  60690. * Repeat calls while already presenting will update the VRLayers being displayed.
  60691. * @param layers Define the list of layer to present
  60692. * @returns a promise to know when the request has been fulfilled
  60693. */
  60694. requestPresent(layers: VRLayer[]): Promise<void>;
  60695. /**
  60696. * Reset the pose for this display, treating its current position and
  60697. * orientation as the "origin/zero" values. VRPose.position,
  60698. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  60699. * updated when calling resetPose(). This should be called in only
  60700. * sitting-space experiences.
  60701. */
  60702. resetPose(): void;
  60703. /**
  60704. * The VRLayer provided to the VRDisplay will be captured and presented
  60705. * in the HMD. Calling this function has the same effect on the source
  60706. * canvas as any other operation that uses its source image, and canvases
  60707. * created without preserveDrawingBuffer set to true will be cleared.
  60708. * @param pose Define the pose to submit
  60709. */
  60710. submitFrame(pose?: VRPose): void;
  60711. }
  60712. declare var VRDisplay: {
  60713. prototype: VRDisplay;
  60714. new(): VRDisplay;
  60715. };
  60716. interface VRLayer {
  60717. leftBounds?: number[] | Float32Array | null;
  60718. rightBounds?: number[] | Float32Array | null;
  60719. source?: HTMLCanvasElement | null;
  60720. }
  60721. interface VRDisplayCapabilities {
  60722. readonly canPresent: boolean;
  60723. readonly hasExternalDisplay: boolean;
  60724. readonly hasOrientation: boolean;
  60725. readonly hasPosition: boolean;
  60726. readonly maxLayers: number;
  60727. }
  60728. interface VREyeParameters {
  60729. /** @deprecated */
  60730. readonly fieldOfView: VRFieldOfView;
  60731. readonly offset: Float32Array;
  60732. readonly renderHeight: number;
  60733. readonly renderWidth: number;
  60734. }
  60735. interface VRFieldOfView {
  60736. readonly downDegrees: number;
  60737. readonly leftDegrees: number;
  60738. readonly rightDegrees: number;
  60739. readonly upDegrees: number;
  60740. }
  60741. interface VRFrameData {
  60742. readonly leftProjectionMatrix: Float32Array;
  60743. readonly leftViewMatrix: Float32Array;
  60744. readonly pose: VRPose;
  60745. readonly rightProjectionMatrix: Float32Array;
  60746. readonly rightViewMatrix: Float32Array;
  60747. readonly timestamp: number;
  60748. }
  60749. interface VRPose {
  60750. readonly angularAcceleration: Float32Array | null;
  60751. readonly angularVelocity: Float32Array | null;
  60752. readonly linearAcceleration: Float32Array | null;
  60753. readonly linearVelocity: Float32Array | null;
  60754. readonly orientation: Float32Array | null;
  60755. readonly position: Float32Array | null;
  60756. readonly timestamp: number;
  60757. }
  60758. interface VRStageParameters {
  60759. sittingToStandingTransform?: Float32Array;
  60760. sizeX?: number;
  60761. sizeY?: number;
  60762. }
  60763. interface Navigator {
  60764. getVRDisplays(): Promise<VRDisplay[]>;
  60765. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  60766. }
  60767. interface Window {
  60768. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  60769. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  60770. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  60771. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60772. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  60773. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  60774. }
  60775. interface Gamepad {
  60776. readonly displayId: number;
  60777. }
  60778. type XRSessionMode =
  60779. | "inline"
  60780. | "immersive-vr"
  60781. | "immersive-ar";
  60782. type XRReferenceSpaceType =
  60783. | "viewer"
  60784. | "local"
  60785. | "local-floor"
  60786. | "bounded-floor"
  60787. | "unbounded";
  60788. type XREnvironmentBlendMode =
  60789. | "opaque"
  60790. | "additive"
  60791. | "alpha-blend";
  60792. type XRVisibilityState =
  60793. | "visible"
  60794. | "visible-blurred"
  60795. | "hidden";
  60796. type XRHandedness =
  60797. | "none"
  60798. | "left"
  60799. | "right";
  60800. type XRTargetRayMode =
  60801. | "gaze"
  60802. | "tracked-pointer"
  60803. | "screen";
  60804. type XREye =
  60805. | "none"
  60806. | "left"
  60807. | "right";
  60808. interface XRSpace extends EventTarget {
  60809. }
  60810. interface XRRenderState {
  60811. depthNear?: number;
  60812. depthFar?: number;
  60813. inlineVerticalFieldOfView?: number;
  60814. baseLayer?: XRWebGLLayer;
  60815. }
  60816. interface XRInputSource {
  60817. handedness: XRHandedness;
  60818. targetRayMode: XRTargetRayMode;
  60819. targetRaySpace: XRSpace;
  60820. gripSpace: XRSpace | undefined;
  60821. gamepad: Gamepad | undefined;
  60822. profiles: Array<string>;
  60823. }
  60824. interface XRSession {
  60825. addEventListener: Function;
  60826. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  60827. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  60828. requestAnimationFrame: Function;
  60829. end(): Promise<void>;
  60830. renderState: XRRenderState;
  60831. inputSources: Array<XRInputSource>;
  60832. }
  60833. interface XRReferenceSpace extends XRSpace {
  60834. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  60835. onreset: any;
  60836. }
  60837. interface XRFrame {
  60838. session: XRSession;
  60839. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  60840. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  60841. }
  60842. interface XRViewerPose extends XRPose {
  60843. views: Array<XRView>;
  60844. }
  60845. interface XRPose {
  60846. transform: XRRigidTransform;
  60847. emulatedPosition: boolean;
  60848. }
  60849. declare var XRWebGLLayer: {
  60850. prototype: XRWebGLLayer;
  60851. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  60852. };
  60853. interface XRWebGLLayer {
  60854. framebuffer: WebGLFramebuffer;
  60855. framebufferWidth: number;
  60856. framebufferHeight: number;
  60857. getViewport: Function;
  60858. }
  60859. interface XRRigidTransform {
  60860. position: DOMPointReadOnly;
  60861. orientation: DOMPointReadOnly;
  60862. matrix: Float32Array;
  60863. inverse: XRRigidTransform;
  60864. }
  60865. interface XRView {
  60866. eye: XREye;
  60867. projectionMatrix: Float32Array;
  60868. transform: XRRigidTransform;
  60869. }
  60870. interface XRInputSourceChangeEvent {
  60871. session: XRSession;
  60872. removed: Array<XRInputSource>;
  60873. added: Array<XRInputSource>;
  60874. }
  60875. declare module BABYLON.GUI {
  60876. /**
  60877. * Class used to specific a value and its associated unit
  60878. */
  60879. export class ValueAndUnit {
  60880. /** defines the unit to store */
  60881. unit: number;
  60882. /** defines a boolean indicating if the value can be negative */
  60883. negativeValueAllowed: boolean;
  60884. private _value;
  60885. private _originalUnit;
  60886. /**
  60887. * Gets or sets a value indicating that this value will not scale accordingly with adaptive scaling property
  60888. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  60889. */
  60890. ignoreAdaptiveScaling: boolean;
  60891. /**
  60892. * Creates a new ValueAndUnit
  60893. * @param value defines the value to store
  60894. * @param unit defines the unit to store
  60895. * @param negativeValueAllowed defines a boolean indicating if the value can be negative
  60896. */
  60897. constructor(value: number,
  60898. /** defines the unit to store */
  60899. unit?: number,
  60900. /** defines a boolean indicating if the value can be negative */
  60901. negativeValueAllowed?: boolean);
  60902. /** Gets a boolean indicating if the value is a percentage */
  60903. readonly isPercentage: boolean;
  60904. /** Gets a boolean indicating if the value is store as pixel */
  60905. readonly isPixel: boolean;
  60906. /** Gets direct internal value */
  60907. readonly internalValue: number;
  60908. /**
  60909. * Gets value as pixel
  60910. * @param host defines the root host
  60911. * @param refValue defines the reference value for percentages
  60912. * @returns the value as pixel
  60913. */
  60914. getValueInPixel(host: AdvancedDynamicTexture, refValue: number): number;
  60915. /**
  60916. * Update the current value and unit. This should be done cautiously as the GUi won't be marked as dirty with this function.
  60917. * @param value defines the value to store
  60918. * @param unit defines the unit to store
  60919. * @returns the current ValueAndUnit
  60920. */
  60921. updateInPlace(value: number, unit?: number): ValueAndUnit;
  60922. /**
  60923. * Gets the value accordingly to its unit
  60924. * @param host defines the root host
  60925. * @returns the value
  60926. */
  60927. getValue(host: AdvancedDynamicTexture): number;
  60928. /**
  60929. * Gets a string representation of the value
  60930. * @param host defines the root host
  60931. * @param decimals defines an optional number of decimals to display
  60932. * @returns a string
  60933. */
  60934. toString(host: AdvancedDynamicTexture, decimals?: number): string;
  60935. /**
  60936. * Store a value parsed from a string
  60937. * @param source defines the source string
  60938. * @returns true if the value was successfully parsed
  60939. */
  60940. fromString(source: string | number): boolean;
  60941. private static _Regex;
  60942. private static _UNITMODE_PERCENTAGE;
  60943. private static _UNITMODE_PIXEL;
  60944. /** UNITMODE_PERCENTAGE */
  60945. static readonly UNITMODE_PERCENTAGE: number;
  60946. /** UNITMODE_PIXEL */
  60947. static readonly UNITMODE_PIXEL: number;
  60948. }
  60949. }
  60950. declare module BABYLON.GUI {
  60951. /**
  60952. * Define a style used by control to automatically setup properties based on a template.
  60953. * Only support font related properties so far
  60954. */
  60955. export class Style implements BABYLON.IDisposable {
  60956. private _fontFamily;
  60957. private _fontStyle;
  60958. private _fontWeight;
  60959. /** @hidden */ private _host: AdvancedDynamicTexture;
  60960. /** @hidden */ private _fontSize: ValueAndUnit;
  60961. /**
  60962. * BABYLON.Observable raised when the style values are changed
  60963. */
  60964. onChangedObservable: BABYLON.Observable<Style>;
  60965. /**
  60966. * Creates a new style object
  60967. * @param host defines the AdvancedDynamicTexture which hosts this style
  60968. */
  60969. constructor(host: AdvancedDynamicTexture);
  60970. /**
  60971. * Gets or sets the font size
  60972. */
  60973. fontSize: string | number;
  60974. /**
  60975. * Gets or sets the font family
  60976. */
  60977. fontFamily: string;
  60978. /**
  60979. * Gets or sets the font style
  60980. */
  60981. fontStyle: string;
  60982. /** Gets or sets font weight */
  60983. fontWeight: string;
  60984. /** Dispose all associated resources */
  60985. dispose(): void;
  60986. }
  60987. }
  60988. declare module BABYLON.GUI {
  60989. /**
  60990. * Class used to transport BABYLON.Vector2 information for pointer events
  60991. */
  60992. export class Vector2WithInfo extends BABYLON.Vector2 {
  60993. /** defines the current mouse button index */
  60994. buttonIndex: number;
  60995. /**
  60996. * Creates a new Vector2WithInfo
  60997. * @param source defines the vector2 data to transport
  60998. * @param buttonIndex defines the current mouse button index
  60999. */
  61000. constructor(source: BABYLON.Vector2,
  61001. /** defines the current mouse button index */
  61002. buttonIndex?: number);
  61003. }
  61004. /** Class used to provide 2D matrix features */
  61005. export class Matrix2D {
  61006. /** Gets the internal array of 6 floats used to store matrix data */
  61007. m: Float32Array;
  61008. /**
  61009. * Creates a new matrix
  61010. * @param m00 defines value for (0, 0)
  61011. * @param m01 defines value for (0, 1)
  61012. * @param m10 defines value for (1, 0)
  61013. * @param m11 defines value for (1, 1)
  61014. * @param m20 defines value for (2, 0)
  61015. * @param m21 defines value for (2, 1)
  61016. */
  61017. constructor(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number);
  61018. /**
  61019. * Fills the matrix from direct values
  61020. * @param m00 defines value for (0, 0)
  61021. * @param m01 defines value for (0, 1)
  61022. * @param m10 defines value for (1, 0)
  61023. * @param m11 defines value for (1, 1)
  61024. * @param m20 defines value for (2, 0)
  61025. * @param m21 defines value for (2, 1)
  61026. * @returns the current modified matrix
  61027. */
  61028. fromValues(m00: number, m01: number, m10: number, m11: number, m20: number, m21: number): Matrix2D;
  61029. /**
  61030. * Gets matrix determinant
  61031. * @returns the determinant
  61032. */
  61033. determinant(): number;
  61034. /**
  61035. * Inverses the matrix and stores it in a target matrix
  61036. * @param result defines the target matrix
  61037. * @returns the current matrix
  61038. */
  61039. invertToRef(result: Matrix2D): Matrix2D;
  61040. /**
  61041. * Multiplies the current matrix with another one
  61042. * @param other defines the second operand
  61043. * @param result defines the target matrix
  61044. * @returns the current matrix
  61045. */
  61046. multiplyToRef(other: Matrix2D, result: Matrix2D): Matrix2D;
  61047. /**
  61048. * Applies the current matrix to a set of 2 floats and stores the result in a vector2
  61049. * @param x defines the x coordinate to transform
  61050. * @param y defines the x coordinate to transform
  61051. * @param result defines the target vector2
  61052. * @returns the current matrix
  61053. */
  61054. transformCoordinates(x: number, y: number, result: BABYLON.Vector2): Matrix2D;
  61055. /**
  61056. * Creates an identity matrix
  61057. * @returns a new matrix
  61058. */
  61059. static Identity(): Matrix2D;
  61060. /**
  61061. * Creates a translation matrix and stores it in a target matrix
  61062. * @param x defines the x coordinate of the translation
  61063. * @param y defines the y coordinate of the translation
  61064. * @param result defines the target matrix
  61065. */
  61066. static TranslationToRef(x: number, y: number, result: Matrix2D): void;
  61067. /**
  61068. * Creates a scaling matrix and stores it in a target matrix
  61069. * @param x defines the x coordinate of the scaling
  61070. * @param y defines the y coordinate of the scaling
  61071. * @param result defines the target matrix
  61072. */
  61073. static ScalingToRef(x: number, y: number, result: Matrix2D): void;
  61074. /**
  61075. * Creates a rotation matrix and stores it in a target matrix
  61076. * @param angle defines the rotation angle
  61077. * @param result defines the target matrix
  61078. */
  61079. static RotationToRef(angle: number, result: Matrix2D): void;
  61080. private static _TempPreTranslationMatrix;
  61081. private static _TempPostTranslationMatrix;
  61082. private static _TempRotationMatrix;
  61083. private static _TempScalingMatrix;
  61084. private static _TempCompose0;
  61085. private static _TempCompose1;
  61086. private static _TempCompose2;
  61087. /**
  61088. * Composes a matrix from translation, rotation, scaling and parent matrix and stores it in a target matrix
  61089. * @param tx defines the x coordinate of the translation
  61090. * @param ty defines the y coordinate of the translation
  61091. * @param angle defines the rotation angle
  61092. * @param scaleX defines the x coordinate of the scaling
  61093. * @param scaleY defines the y coordinate of the scaling
  61094. * @param parentMatrix defines the parent matrix to multiply by (can be null)
  61095. * @param result defines the target matrix
  61096. */
  61097. static ComposeToRef(tx: number, ty: number, angle: number, scaleX: number, scaleY: number, parentMatrix: BABYLON.Nullable<Matrix2D>, result: Matrix2D): void;
  61098. }
  61099. }
  61100. declare module BABYLON.GUI {
  61101. /**
  61102. * Class used to store 2D control sizes
  61103. */
  61104. export class Measure {
  61105. /** defines left coordinate */
  61106. left: number;
  61107. /** defines top coordinate */
  61108. top: number;
  61109. /** defines width dimension */
  61110. width: number;
  61111. /** defines height dimension */
  61112. height: number;
  61113. /**
  61114. * Creates a new measure
  61115. * @param left defines left coordinate
  61116. * @param top defines top coordinate
  61117. * @param width defines width dimension
  61118. * @param height defines height dimension
  61119. */
  61120. constructor(
  61121. /** defines left coordinate */
  61122. left: number,
  61123. /** defines top coordinate */
  61124. top: number,
  61125. /** defines width dimension */
  61126. width: number,
  61127. /** defines height dimension */
  61128. height: number);
  61129. /**
  61130. * Copy from another measure
  61131. * @param other defines the other measure to copy from
  61132. */
  61133. copyFrom(other: Measure): void;
  61134. /**
  61135. * Copy from a group of 4 floats
  61136. * @param left defines left coordinate
  61137. * @param top defines top coordinate
  61138. * @param width defines width dimension
  61139. * @param height defines height dimension
  61140. */
  61141. copyFromFloats(left: number, top: number, width: number, height: number): void;
  61142. /**
  61143. * Computes the axis aligned bounding box measure for two given measures
  61144. * @param a Input measure
  61145. * @param b Input measure
  61146. * @param result the resulting bounding measure
  61147. */
  61148. static CombineToRef(a: Measure, b: Measure, result: Measure): void;
  61149. /**
  61150. * Computes the axis aligned bounding box of the measure after it is modified by a given transform
  61151. * @param transform the matrix to transform the measure before computing the AABB
  61152. * @param result the resulting AABB
  61153. */
  61154. transformToRef(transform: Matrix2D, result: Measure): void;
  61155. /**
  61156. * Check equality between this measure and another one
  61157. * @param other defines the other measures
  61158. * @returns true if both measures are equals
  61159. */
  61160. isEqualsTo(other: Measure): boolean;
  61161. /**
  61162. * Creates an empty measure
  61163. * @returns a new measure
  61164. */
  61165. static Empty(): Measure;
  61166. }
  61167. }
  61168. declare module BABYLON.GUI {
  61169. /**
  61170. * Interface used to define a control that can receive focus
  61171. */
  61172. export interface IFocusableControl {
  61173. /**
  61174. * Function called when the control receives the focus
  61175. */
  61176. onFocus(): void;
  61177. /**
  61178. * Function called when the control loses the focus
  61179. */
  61180. onBlur(): void;
  61181. /**
  61182. * Function called to let the control handle keyboard events
  61183. * @param evt defines the current keyboard event
  61184. */
  61185. processKeyboard(evt: KeyboardEvent): void;
  61186. /**
  61187. * Function called to get the list of controls that should not steal the focus from this control
  61188. * @returns an array of controls
  61189. */
  61190. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  61191. }
  61192. /**
  61193. * Class used to create texture to support 2D GUI elements
  61194. * @see http://doc.babylonjs.com/how_to/gui
  61195. */
  61196. export class AdvancedDynamicTexture extends BABYLON.DynamicTexture {
  61197. private _isDirty;
  61198. private _renderObserver;
  61199. private _resizeObserver;
  61200. private _preKeyboardObserver;
  61201. private _pointerMoveObserver;
  61202. private _pointerObserver;
  61203. private _canvasPointerOutObserver;
  61204. private _background;
  61205. /** @hidden */ private _rootContainer: Container;
  61206. /** @hidden */ private _lastPickedControl: Control;
  61207. /** @hidden */ private _lastControlOver: {
  61208. [pointerId: number]: Control;
  61209. };
  61210. /** @hidden */ private _lastControlDown: {
  61211. [pointerId: number]: Control;
  61212. };
  61213. /** @hidden */ private _capturingControl: {
  61214. [pointerId: number]: Control;
  61215. };
  61216. /** @hidden */ private _shouldBlockPointer: boolean;
  61217. /** @hidden */ private _layerToDispose: BABYLON.Nullable<BABYLON.Layer>;
  61218. /** @hidden */ private _linkedControls: Control[];
  61219. private _isFullscreen;
  61220. private _fullscreenViewport;
  61221. private _idealWidth;
  61222. private _idealHeight;
  61223. private _useSmallestIdeal;
  61224. private _renderAtIdealSize;
  61225. private _focusedControl;
  61226. private _blockNextFocusCheck;
  61227. private _renderScale;
  61228. private _rootCanvas;
  61229. private _cursorChanged;
  61230. /**
  61231. * Define type to string to ensure compatibility across browsers
  61232. * Safari doesn't support DataTransfer constructor
  61233. */
  61234. private _clipboardData;
  61235. /**
  61236. * BABYLON.Observable event triggered each time an clipboard event is received from the rendering canvas
  61237. */
  61238. onClipboardObservable: BABYLON.Observable<BABYLON.ClipboardInfo>;
  61239. /**
  61240. * BABYLON.Observable event triggered each time a pointer down is intercepted by a control
  61241. */
  61242. onControlPickedObservable: BABYLON.Observable<Control>;
  61243. /**
  61244. * BABYLON.Observable event triggered before layout is evaluated
  61245. */
  61246. onBeginLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61247. /**
  61248. * BABYLON.Observable event triggered after the layout was evaluated
  61249. */
  61250. onEndLayoutObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61251. /**
  61252. * BABYLON.Observable event triggered before the texture is rendered
  61253. */
  61254. onBeginRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61255. /**
  61256. * BABYLON.Observable event triggered after the texture was rendered
  61257. */
  61258. onEndRenderObservable: BABYLON.Observable<AdvancedDynamicTexture>;
  61259. /**
  61260. * Gets or sets a boolean defining if alpha is stored as premultiplied
  61261. */
  61262. premulAlpha: boolean;
  61263. /**
  61264. * Gets or sets a number used to scale rendering size (2 means that the texture will be twice bigger).
  61265. * Useful when you want more antialiasing
  61266. */
  61267. renderScale: number;
  61268. /** Gets or sets the background color */
  61269. background: string;
  61270. /**
  61271. * Gets or sets the ideal width used to design controls.
  61272. * The GUI will then rescale everything accordingly
  61273. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61274. */
  61275. idealWidth: number;
  61276. /**
  61277. * Gets or sets the ideal height used to design controls.
  61278. * The GUI will then rescale everything accordingly
  61279. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61280. */
  61281. idealHeight: number;
  61282. /**
  61283. * Gets or sets a boolean indicating if the smallest ideal value must be used if idealWidth and idealHeight are both set
  61284. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61285. */
  61286. useSmallestIdeal: boolean;
  61287. /**
  61288. * Gets or sets a boolean indicating if adaptive scaling must be used
  61289. * @see http://doc.babylonjs.com/how_to/gui#adaptive-scaling
  61290. */
  61291. renderAtIdealSize: boolean;
  61292. /**
  61293. * Gets the underlying layer used to render the texture when in fullscreen mode
  61294. */
  61295. readonly layer: BABYLON.Nullable<BABYLON.Layer>;
  61296. /**
  61297. * Gets the root container control
  61298. */
  61299. readonly rootContainer: Container;
  61300. /**
  61301. * Returns an array containing the root container.
  61302. * This is mostly used to let the Inspector introspects the ADT
  61303. * @returns an array containing the rootContainer
  61304. */
  61305. getChildren(): Array<Container>;
  61306. /**
  61307. * Will return all controls that are inside this texture
  61308. * @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
  61309. * @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
  61310. * @return all child controls
  61311. */
  61312. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61313. /**
  61314. * Gets or sets the current focused control
  61315. */
  61316. focusedControl: BABYLON.Nullable<IFocusableControl>;
  61317. /**
  61318. * Gets or sets a boolean indicating if the texture must be rendered in background or foreground when in fullscreen mode
  61319. */
  61320. isForeground: boolean;
  61321. /**
  61322. * Gets or set information about clipboardData
  61323. */
  61324. clipboardData: string;
  61325. /**
  61326. * Creates a new AdvancedDynamicTexture
  61327. * @param name defines the name of the texture
  61328. * @param width defines the width of the texture
  61329. * @param height defines the height of the texture
  61330. * @param scene defines the hosting scene
  61331. * @param generateMipMaps defines a boolean indicating if mipmaps must be generated (false by default)
  61332. * @param samplingMode defines the texture sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  61333. */
  61334. constructor(name: string, width: number | undefined, height: number | undefined, scene: BABYLON.Nullable<BABYLON.Scene>, generateMipMaps?: boolean, samplingMode?: number);
  61335. /**
  61336. * Get the current class name of the texture useful for serialization or dynamic coding.
  61337. * @returns "AdvancedDynamicTexture"
  61338. */
  61339. getClassName(): string;
  61340. /**
  61341. * Function used to execute a function on all controls
  61342. * @param func defines the function to execute
  61343. * @param container defines the container where controls belong. If null the root container will be used
  61344. */
  61345. executeOnAllControls(func: (control: Control) => void, container?: Container): void;
  61346. private _useInvalidateRectOptimization;
  61347. /**
  61348. * Gets or sets a boolean indicating if the InvalidateRect optimization should be turned on
  61349. */
  61350. useInvalidateRectOptimization: boolean;
  61351. private _invalidatedRectangle;
  61352. /**
  61353. * Invalidates a rectangle area on the gui texture
  61354. * @param invalidMinX left most position of the rectangle to invalidate in the texture
  61355. * @param invalidMinY top most position of the rectangle to invalidate in the texture
  61356. * @param invalidMaxX right most position of the rectangle to invalidate in the texture
  61357. * @param invalidMaxY bottom most position of the rectangle to invalidate in the texture
  61358. */
  61359. invalidateRect(invalidMinX: number, invalidMinY: number, invalidMaxX: number, invalidMaxY: number): void;
  61360. /**
  61361. * Marks the texture as dirty forcing a complete update
  61362. */
  61363. markAsDirty(): void;
  61364. /**
  61365. * Helper function used to create a new style
  61366. * @returns a new style
  61367. * @see http://doc.babylonjs.com/how_to/gui#styles
  61368. */
  61369. createStyle(): Style;
  61370. /**
  61371. * Adds a new control to the root container
  61372. * @param control defines the control to add
  61373. * @returns the current texture
  61374. */
  61375. addControl(control: Control): AdvancedDynamicTexture;
  61376. /**
  61377. * Removes a control from the root container
  61378. * @param control defines the control to remove
  61379. * @returns the current texture
  61380. */
  61381. removeControl(control: Control): AdvancedDynamicTexture;
  61382. /**
  61383. * Release all resources
  61384. */
  61385. dispose(): void;
  61386. private _onResize;
  61387. /** @hidden */ private _getGlobalViewport(scene: BABYLON.Scene): BABYLON.Viewport;
  61388. /**
  61389. * Get screen coordinates for a vector3
  61390. * @param position defines the position to project
  61391. * @param worldMatrix defines the world matrix to use
  61392. * @returns the projected position
  61393. */
  61394. getProjectedPosition(position: BABYLON.Vector3, worldMatrix: BABYLON.Matrix): BABYLON.Vector2;
  61395. private _checkUpdate;
  61396. private _clearMeasure;
  61397. private _render;
  61398. /** @hidden */ private _changeCursor(cursor: string): void;
  61399. /** @hidden */ private _registerLastControlDown(control: Control, pointerId: number): void;
  61400. private _doPicking;
  61401. /** @hidden */ private _cleanControlAfterRemovalFromList(list: {
  61402. [pointerId: number]: Control;
  61403. }, control: Control): void;
  61404. /** @hidden */ private _cleanControlAfterRemoval(control: Control): void;
  61405. /** Attach to all scene events required to support pointer events */
  61406. attach(): void;
  61407. /** @hidden */
  61408. private onClipboardCopy;
  61409. /** @hidden */
  61410. private onClipboardCut;
  61411. /** @hidden */
  61412. private onClipboardPaste;
  61413. /**
  61414. * Register the clipboard Events onto the canvas
  61415. */
  61416. registerClipboardEvents(): void;
  61417. /**
  61418. * Unregister the clipboard Events from the canvas
  61419. */
  61420. unRegisterClipboardEvents(): void;
  61421. /**
  61422. * Connect the texture to a hosting mesh to enable interactions
  61423. * @param mesh defines the mesh to attach to
  61424. * @param supportPointerMove defines a boolean indicating if pointer move events must be catched as well
  61425. */
  61426. attachToMesh(mesh: BABYLON.AbstractMesh, supportPointerMove?: boolean): void;
  61427. /**
  61428. * Move the focus to a specific control
  61429. * @param control defines the control which will receive the focus
  61430. */
  61431. moveFocusToControl(control: IFocusableControl): void;
  61432. private _manageFocus;
  61433. private _attachToOnPointerOut;
  61434. /**
  61435. * Creates a new AdvancedDynamicTexture in projected mode (ie. attached to a mesh)
  61436. * @param mesh defines the mesh which will receive the texture
  61437. * @param width defines the texture width (1024 by default)
  61438. * @param height defines the texture height (1024 by default)
  61439. * @param supportPointerMove defines a boolean indicating if the texture must capture move events (true by default)
  61440. * @param onlyAlphaTesting defines a boolean indicating that alpha blending will not be used (only alpha testing) (false by default)
  61441. * @returns a new AdvancedDynamicTexture
  61442. */
  61443. static CreateForMesh(mesh: BABYLON.AbstractMesh, width?: number, height?: number, supportPointerMove?: boolean, onlyAlphaTesting?: boolean): AdvancedDynamicTexture;
  61444. /**
  61445. * Creates a new AdvancedDynamicTexture in fullscreen mode.
  61446. * In this mode the texture will rely on a layer for its rendering.
  61447. * This allows it to be treated like any other layer.
  61448. * As such, if you have a multi camera setup, you can set the layerMask on the GUI as well.
  61449. * LayerMask is set through advancedTexture.layer.layerMask
  61450. * @param name defines name for the texture
  61451. * @param foreground defines a boolean indicating if the texture must be rendered in foreground (default is true)
  61452. * @param scene defines the hsoting scene
  61453. * @param sampling defines the texture sampling mode (Texture.BILINEAR_SAMPLINGMODE by default)
  61454. * @returns a new AdvancedDynamicTexture
  61455. */
  61456. static CreateFullscreenUI(name: string, foreground?: boolean, scene?: BABYLON.Nullable<BABYLON.Scene>, sampling?: number): AdvancedDynamicTexture;
  61457. }
  61458. }
  61459. declare module BABYLON.GUI {
  61460. /**
  61461. * Root class used for all 2D controls
  61462. * @see http://doc.babylonjs.com/how_to/gui#controls
  61463. */
  61464. export class Control {
  61465. /** defines the name of the control */
  61466. name?: string | undefined;
  61467. /**
  61468. * Gets or sets a boolean indicating if alpha must be an inherited value (false by default)
  61469. */
  61470. static AllowAlphaInheritance: boolean;
  61471. private _alpha;
  61472. private _alphaSet;
  61473. private _zIndex;
  61474. /** @hidden */ private _host: AdvancedDynamicTexture;
  61475. /** Gets or sets the control parent */
  61476. parent: BABYLON.Nullable<Container>;
  61477. /** @hidden */ private _currentMeasure: Measure;
  61478. private _fontFamily;
  61479. private _fontStyle;
  61480. private _fontWeight;
  61481. private _fontSize;
  61482. private _font;
  61483. /** @hidden */ private _width: ValueAndUnit;
  61484. /** @hidden */ private _height: ValueAndUnit;
  61485. /** @hidden */
  61486. protected _fontOffset: {
  61487. ascent: number;
  61488. height: number;
  61489. descent: number;
  61490. };
  61491. private _color;
  61492. private _style;
  61493. private _styleObserver;
  61494. /** @hidden */
  61495. protected _horizontalAlignment: number;
  61496. /** @hidden */
  61497. protected _verticalAlignment: number;
  61498. /** @hidden */
  61499. protected _isDirty: boolean;
  61500. /** @hidden */
  61501. protected _wasDirty: boolean;
  61502. /** @hidden */ private _tempParentMeasure: Measure;
  61503. /** @hidden */ private _prevCurrentMeasureTransformedIntoGlobalSpace: Measure;
  61504. /** @hidden */
  61505. protected _cachedParentMeasure: Measure;
  61506. private _paddingLeft;
  61507. private _paddingRight;
  61508. private _paddingTop;
  61509. private _paddingBottom;
  61510. /** @hidden */ private _left: ValueAndUnit;
  61511. /** @hidden */ private _top: ValueAndUnit;
  61512. private _scaleX;
  61513. private _scaleY;
  61514. private _rotation;
  61515. private _transformCenterX;
  61516. private _transformCenterY;
  61517. /** @hidden */ private _transformMatrix: Matrix2D;
  61518. /** @hidden */
  61519. protected _invertTransformMatrix: Matrix2D;
  61520. /** @hidden */
  61521. protected _transformedPosition: BABYLON.Vector2;
  61522. private _isMatrixDirty;
  61523. private _cachedOffsetX;
  61524. private _cachedOffsetY;
  61525. private _isVisible;
  61526. private _isHighlighted;
  61527. /** @hidden */ private _linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61528. private _fontSet;
  61529. private _dummyVector2;
  61530. private _downCount;
  61531. private _enterCount;
  61532. private _doNotRender;
  61533. private _downPointerIds;
  61534. protected _isEnabled: boolean;
  61535. protected _disabledColor: string;
  61536. /** @hidden */
  61537. protected _rebuildLayout: boolean;
  61538. /** @hidden */ private _isClipped: boolean;
  61539. /** @hidden */ private _tag: any;
  61540. /**
  61541. * 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
  61542. */
  61543. uniqueId: number;
  61544. /**
  61545. * Gets or sets an object used to store user defined information for the node
  61546. */
  61547. metadata: any;
  61548. /** Gets or sets a boolean indicating if the control can be hit with pointer events */
  61549. isHitTestVisible: boolean;
  61550. /** Gets or sets a boolean indicating if the control can block pointer events */
  61551. isPointerBlocker: boolean;
  61552. /** Gets or sets a boolean indicating if the control can be focusable */
  61553. isFocusInvisible: boolean;
  61554. /**
  61555. * Gets or sets a boolean indicating if the children are clipped to the current control bounds.
  61556. * 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
  61557. */
  61558. clipChildren: boolean;
  61559. /**
  61560. * Gets or sets a boolean indicating that control content must be clipped
  61561. * 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
  61562. */
  61563. clipContent: boolean;
  61564. /**
  61565. * Gets or sets a boolean indicating that the current control should cache its rendering (useful when the control does not change often)
  61566. */
  61567. useBitmapCache: boolean;
  61568. private _cacheData;
  61569. private _shadowOffsetX;
  61570. /** Gets or sets a value indicating the offset to apply on X axis to render the shadow */
  61571. shadowOffsetX: number;
  61572. private _shadowOffsetY;
  61573. /** Gets or sets a value indicating the offset to apply on Y axis to render the shadow */
  61574. shadowOffsetY: number;
  61575. private _shadowBlur;
  61576. /** Gets or sets a value indicating the amount of blur to use to render the shadow */
  61577. shadowBlur: number;
  61578. private _shadowColor;
  61579. /** Gets or sets a value indicating the color of the shadow (black by default ie. "#000") */
  61580. shadowColor: string;
  61581. /** Gets or sets the cursor to use when the control is hovered */
  61582. hoverCursor: string;
  61583. /** @hidden */
  61584. protected _linkOffsetX: ValueAndUnit;
  61585. /** @hidden */
  61586. protected _linkOffsetY: ValueAndUnit;
  61587. /** Gets the control type name */
  61588. readonly typeName: string;
  61589. /**
  61590. * Get the current class name of the control.
  61591. * @returns current class name
  61592. */
  61593. getClassName(): string;
  61594. /**
  61595. * An event triggered when the pointer move over the control.
  61596. */
  61597. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector2>;
  61598. /**
  61599. * An event triggered when the pointer move out of the control.
  61600. */
  61601. onPointerOutObservable: BABYLON.Observable<Control>;
  61602. /**
  61603. * An event triggered when the pointer taps the control
  61604. */
  61605. onPointerDownObservable: BABYLON.Observable<Vector2WithInfo>;
  61606. /**
  61607. * An event triggered when pointer up
  61608. */
  61609. onPointerUpObservable: BABYLON.Observable<Vector2WithInfo>;
  61610. /**
  61611. * An event triggered when a control is clicked on
  61612. */
  61613. onPointerClickObservable: BABYLON.Observable<Vector2WithInfo>;
  61614. /**
  61615. * An event triggered when pointer enters the control
  61616. */
  61617. onPointerEnterObservable: BABYLON.Observable<Control>;
  61618. /**
  61619. * An event triggered when the control is marked as dirty
  61620. */
  61621. onDirtyObservable: BABYLON.Observable<Control>;
  61622. /**
  61623. * An event triggered before drawing the control
  61624. */
  61625. onBeforeDrawObservable: BABYLON.Observable<Control>;
  61626. /**
  61627. * An event triggered after the control was drawn
  61628. */
  61629. onAfterDrawObservable: BABYLON.Observable<Control>;
  61630. /**
  61631. * Get the hosting AdvancedDynamicTexture
  61632. */
  61633. readonly host: AdvancedDynamicTexture;
  61634. /** Gets or set information about font offsets (used to render and align text) */
  61635. fontOffset: {
  61636. ascent: number;
  61637. height: number;
  61638. descent: number;
  61639. };
  61640. /** Gets or sets alpha value for the control (1 means opaque and 0 means entirely transparent) */
  61641. alpha: number;
  61642. /**
  61643. * Gets or sets a boolean indicating that we want to highlight the control (mostly for debugging purpose)
  61644. */
  61645. isHighlighted: boolean;
  61646. /** Gets or sets a value indicating the scale factor on X axis (1 by default)
  61647. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61648. */
  61649. scaleX: number;
  61650. /** Gets or sets a value indicating the scale factor on Y axis (1 by default)
  61651. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61652. */
  61653. scaleY: number;
  61654. /** Gets or sets the rotation angle (0 by default)
  61655. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61656. */
  61657. rotation: number;
  61658. /** Gets or sets the transformation center on Y axis (0 by default)
  61659. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61660. */
  61661. transformCenterY: number;
  61662. /** Gets or sets the transformation center on X axis (0 by default)
  61663. * @see http://doc.babylonjs.com/how_to/gui#rotation-and-scaling
  61664. */
  61665. transformCenterX: number;
  61666. /**
  61667. * Gets or sets the horizontal alignment
  61668. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61669. */
  61670. horizontalAlignment: number;
  61671. /**
  61672. * Gets or sets the vertical alignment
  61673. * @see http://doc.babylonjs.com/how_to/gui#alignments
  61674. */
  61675. verticalAlignment: number;
  61676. /**
  61677. * Gets or sets control width
  61678. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61679. */
  61680. width: string | number;
  61681. /**
  61682. * Gets or sets the control width in pixel
  61683. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61684. */
  61685. widthInPixels: number;
  61686. /**
  61687. * Gets or sets control height
  61688. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61689. */
  61690. height: string | number;
  61691. /**
  61692. * Gets or sets control height in pixel
  61693. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61694. */
  61695. heightInPixels: number;
  61696. /** Gets or set font family */
  61697. fontFamily: string;
  61698. /** Gets or sets font style */
  61699. fontStyle: string;
  61700. /** Gets or sets font weight */
  61701. fontWeight: string;
  61702. /**
  61703. * Gets or sets style
  61704. * @see http://doc.babylonjs.com/how_to/gui#styles
  61705. */
  61706. style: BABYLON.Nullable<Style>;
  61707. /** @hidden */ protected readonly _isFontSizeInPercentage: boolean;
  61708. /** Gets or sets font size in pixels */
  61709. fontSizeInPixels: number;
  61710. /** Gets or sets font size */
  61711. fontSize: string | number;
  61712. /** Gets or sets foreground color */
  61713. color: string;
  61714. /** Gets or sets z index which is used to reorder controls on the z axis */
  61715. zIndex: number;
  61716. /** Gets or sets a boolean indicating if the control can be rendered */
  61717. notRenderable: boolean;
  61718. /** Gets or sets a boolean indicating if the control is visible */
  61719. isVisible: boolean;
  61720. /** Gets a boolean indicating that the control needs to update its rendering */
  61721. readonly isDirty: boolean;
  61722. /**
  61723. * Gets the current linked mesh (or null if none)
  61724. */
  61725. readonly linkedMesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  61726. /**
  61727. * Gets or sets a value indicating the padding to use on the left of the control
  61728. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61729. */
  61730. paddingLeft: string | number;
  61731. /**
  61732. * Gets or sets a value indicating the padding in pixels to use on the left of the control
  61733. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61734. */
  61735. paddingLeftInPixels: number;
  61736. /**
  61737. * Gets or sets a value indicating the padding to use on the right of the control
  61738. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61739. */
  61740. paddingRight: string | number;
  61741. /**
  61742. * Gets or sets a value indicating the padding in pixels to use on the right of the control
  61743. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61744. */
  61745. paddingRightInPixels: number;
  61746. /**
  61747. * Gets or sets a value indicating the padding to use on the top of the control
  61748. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61749. */
  61750. paddingTop: string | number;
  61751. /**
  61752. * Gets or sets a value indicating the padding in pixels to use on the top of the control
  61753. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61754. */
  61755. paddingTopInPixels: number;
  61756. /**
  61757. * Gets or sets a value indicating the padding to use on the bottom of the control
  61758. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61759. */
  61760. paddingBottom: string | number;
  61761. /**
  61762. * Gets or sets a value indicating the padding in pixels to use on the bottom of the control
  61763. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61764. */
  61765. paddingBottomInPixels: number;
  61766. /**
  61767. * Gets or sets a value indicating the left coordinate of the control
  61768. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61769. */
  61770. left: string | number;
  61771. /**
  61772. * Gets or sets a value indicating the left coordinate in pixels of the control
  61773. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61774. */
  61775. leftInPixels: number;
  61776. /**
  61777. * Gets or sets a value indicating the top coordinate of the control
  61778. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61779. */
  61780. top: string | number;
  61781. /**
  61782. * Gets or sets a value indicating the top coordinate in pixels of the control
  61783. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  61784. */
  61785. topInPixels: number;
  61786. /**
  61787. * Gets or sets a value indicating the offset on X axis to the linked mesh
  61788. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61789. */
  61790. linkOffsetX: string | number;
  61791. /**
  61792. * Gets or sets a value indicating the offset in pixels on X axis to the linked mesh
  61793. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61794. */
  61795. linkOffsetXInPixels: number;
  61796. /**
  61797. * Gets or sets a value indicating the offset on Y axis to the linked mesh
  61798. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61799. */
  61800. linkOffsetY: string | number;
  61801. /**
  61802. * Gets or sets a value indicating the offset in pixels on Y axis to the linked mesh
  61803. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61804. */
  61805. linkOffsetYInPixels: number;
  61806. /** Gets the center coordinate on X axis */
  61807. readonly centerX: number;
  61808. /** Gets the center coordinate on Y axis */
  61809. readonly centerY: number;
  61810. /** Gets or sets if control is Enabled*/
  61811. isEnabled: boolean;
  61812. /** Gets or sets background color of control if it's disabled*/
  61813. disabledColor: string;
  61814. /**
  61815. * Creates a new control
  61816. * @param name defines the name of the control
  61817. */
  61818. constructor(
  61819. /** defines the name of the control */
  61820. name?: string | undefined);
  61821. /** @hidden */
  61822. protected _getTypeName(): string;
  61823. /**
  61824. * Gets the first ascendant in the hierarchy of the given type
  61825. * @param className defines the required type
  61826. * @returns the ascendant or null if not found
  61827. */
  61828. getAscendantOfClass(className: string): BABYLON.Nullable<Control>;
  61829. /** @hidden */ private _resetFontCache(): void;
  61830. /**
  61831. * Determines if a container is an ascendant of the current control
  61832. * @param container defines the container to look for
  61833. * @returns true if the container is one of the ascendant of the control
  61834. */
  61835. isAscendant(container: Control): boolean;
  61836. /**
  61837. * Gets coordinates in local control space
  61838. * @param globalCoordinates defines the coordinates to transform
  61839. * @returns the new coordinates in local space
  61840. */
  61841. getLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61842. /**
  61843. * Gets coordinates in local control space
  61844. * @param globalCoordinates defines the coordinates to transform
  61845. * @param result defines the target vector2 where to store the result
  61846. * @returns the current control
  61847. */
  61848. getLocalCoordinatesToRef(globalCoordinates: BABYLON.Vector2, result: BABYLON.Vector2): Control;
  61849. /**
  61850. * Gets coordinates in parent local control space
  61851. * @param globalCoordinates defines the coordinates to transform
  61852. * @returns the new coordinates in parent local space
  61853. */
  61854. getParentLocalCoordinates(globalCoordinates: BABYLON.Vector2): BABYLON.Vector2;
  61855. /**
  61856. * Move the current control to a vector3 position projected onto the screen.
  61857. * @param position defines the target position
  61858. * @param scene defines the hosting scene
  61859. */
  61860. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene): void;
  61861. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  61862. /**
  61863. * Will return all controls that have this control as ascendant
  61864. * @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
  61865. * @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
  61866. * @return all child controls
  61867. */
  61868. getDescendants(directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): Control[];
  61869. /**
  61870. * Link current control with a target mesh
  61871. * @param mesh defines the mesh to link with
  61872. * @see http://doc.babylonjs.com/how_to/gui#tracking-positions
  61873. */
  61874. linkWithMesh(mesh: BABYLON.Nullable<BABYLON.AbstractMesh>): void;
  61875. /** @hidden */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3): void;
  61876. /** @hidden */ private _offsetLeft(offset: number): void;
  61877. /** @hidden */ private _offsetTop(offset: number): void;
  61878. /** @hidden */ private _markMatrixAsDirty(): void;
  61879. /** @hidden */ private _flagDescendantsAsMatrixDirty(): void;
  61880. /** @hidden */ private _intersectsRect(rect: Measure): boolean;
  61881. /** @hidden */
  61882. protected invalidateRect(): void;
  61883. /** @hidden */ private _markAsDirty(force?: boolean): void;
  61884. /** @hidden */ private _markAllAsDirty(): void;
  61885. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  61886. /** @hidden */
  61887. protected _transform(context?: CanvasRenderingContext2D): void;
  61888. /** @hidden */ private _renderHighlight(context: CanvasRenderingContext2D): void;
  61889. /** @hidden */ private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  61890. /** @hidden */
  61891. protected _applyStates(context: CanvasRenderingContext2D): void;
  61892. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  61893. /** @hidden */
  61894. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61895. protected _evaluateClippingState(parentMeasure: Measure): void;
  61896. /** @hidden */ private _measure(): void;
  61897. /** @hidden */
  61898. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61899. /** @hidden */
  61900. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61901. /** @hidden */
  61902. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  61903. /** @hidden */
  61904. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  61905. private static _ClipMeasure;
  61906. private _tmpMeasureA;
  61907. private _clip;
  61908. /** @hidden */ private _render(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): boolean;
  61909. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: BABYLON.Nullable<Measure>): void;
  61910. /**
  61911. * Tests if a given coordinates belong to the current control
  61912. * @param x defines x coordinate to test
  61913. * @param y defines y coordinate to test
  61914. * @returns true if the coordinates are inside the control
  61915. */
  61916. contains(x: number, y: number): boolean;
  61917. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  61918. /** @hidden */ private _onPointerMove(target: Control, coordinates: BABYLON.Vector2, pointerId: number): void;
  61919. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  61920. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  61921. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  61922. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  61923. /** @hidden */ private _forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  61924. /** @hidden */ private _processObservables(type: number, x: number, y: number, pointerId: number, buttonIndex: number): boolean;
  61925. private _prepareFont;
  61926. /** Releases associated resources */
  61927. dispose(): void;
  61928. private static _HORIZONTAL_ALIGNMENT_LEFT;
  61929. private static _HORIZONTAL_ALIGNMENT_RIGHT;
  61930. private static _HORIZONTAL_ALIGNMENT_CENTER;
  61931. private static _VERTICAL_ALIGNMENT_TOP;
  61932. private static _VERTICAL_ALIGNMENT_BOTTOM;
  61933. private static _VERTICAL_ALIGNMENT_CENTER;
  61934. /** HORIZONTAL_ALIGNMENT_LEFT */
  61935. static readonly HORIZONTAL_ALIGNMENT_LEFT: number;
  61936. /** HORIZONTAL_ALIGNMENT_RIGHT */
  61937. static readonly HORIZONTAL_ALIGNMENT_RIGHT: number;
  61938. /** HORIZONTAL_ALIGNMENT_CENTER */
  61939. static readonly HORIZONTAL_ALIGNMENT_CENTER: number;
  61940. /** VERTICAL_ALIGNMENT_TOP */
  61941. static readonly VERTICAL_ALIGNMENT_TOP: number;
  61942. /** VERTICAL_ALIGNMENT_BOTTOM */
  61943. static readonly VERTICAL_ALIGNMENT_BOTTOM: number;
  61944. /** VERTICAL_ALIGNMENT_CENTER */
  61945. static readonly VERTICAL_ALIGNMENT_CENTER: number;
  61946. private static _FontHeightSizes;
  61947. /** @hidden */ private static _GetFontOffset(font: string): {
  61948. ascent: number;
  61949. height: number;
  61950. descent: number;
  61951. };
  61952. /**
  61953. * Creates a stack panel that can be used to render headers
  61954. * @param control defines the control to associate with the header
  61955. * @param text defines the text of the header
  61956. * @param size defines the size of the header
  61957. * @param options defines options used to configure the header
  61958. * @returns a new StackPanel
  61959. * @ignore
  61960. * @hidden
  61961. */
  61962. static AddHeader: (control: Control, text: string, size: string | number, options: {
  61963. isHorizontal: boolean;
  61964. controlFirst: boolean;
  61965. }) => any;
  61966. /** @hidden */
  61967. protected static drawEllipse(x: number, y: number, width: number, height: number, context: CanvasRenderingContext2D): void;
  61968. }
  61969. }
  61970. declare module BABYLON.GUI {
  61971. /**
  61972. * Root class for 2D containers
  61973. * @see http://doc.babylonjs.com/how_to/gui#containers
  61974. */
  61975. export class Container extends Control {
  61976. name?: string | undefined;
  61977. /** @hidden */
  61978. protected _children: Control[];
  61979. /** @hidden */
  61980. protected _measureForChildren: Measure;
  61981. /** @hidden */
  61982. protected _background: string;
  61983. /** @hidden */
  61984. protected _adaptWidthToChildren: boolean;
  61985. /** @hidden */
  61986. protected _adaptHeightToChildren: boolean;
  61987. /**
  61988. * Gets or sets a boolean indicating that layout cycle errors should be displayed on the console
  61989. */
  61990. logLayoutCycleErrors: boolean;
  61991. /**
  61992. * Gets or sets the number of layout cycles (a change involved by a control while evaluating the layout) allowed
  61993. */
  61994. maxLayoutCycle: number;
  61995. /** Gets or sets a boolean indicating if the container should try to adapt to its children height */
  61996. adaptHeightToChildren: boolean;
  61997. /** Gets or sets a boolean indicating if the container should try to adapt to its children width */
  61998. adaptWidthToChildren: boolean;
  61999. /** Gets or sets background color */
  62000. background: string;
  62001. /** Gets the list of children */
  62002. readonly children: Control[];
  62003. /**
  62004. * Creates a new Container
  62005. * @param name defines the name of the container
  62006. */
  62007. constructor(name?: string | undefined);
  62008. protected _getTypeName(): string; private _flagDescendantsAsMatrixDirty(): void;
  62009. /**
  62010. * Gets a child using its name
  62011. * @param name defines the child name to look for
  62012. * @returns the child control if found
  62013. */
  62014. getChildByName(name: string): BABYLON.Nullable<Control>;
  62015. /**
  62016. * Gets a child using its type and its name
  62017. * @param name defines the child name to look for
  62018. * @param type defines the child type to look for
  62019. * @returns the child control if found
  62020. */
  62021. getChildByType(name: string, type: string): BABYLON.Nullable<Control>;
  62022. /**
  62023. * Search for a specific control in children
  62024. * @param control defines the control to look for
  62025. * @returns true if the control is in child list
  62026. */
  62027. containsControl(control: Control): boolean;
  62028. /**
  62029. * Adds a new control to the current container
  62030. * @param control defines the control to add
  62031. * @returns the current container
  62032. */
  62033. addControl(control: BABYLON.Nullable<Control>): Container;
  62034. /**
  62035. * Removes all controls from the current container
  62036. * @returns the current container
  62037. */
  62038. clearControls(): Container;
  62039. /**
  62040. * Removes a control from the current container
  62041. * @param control defines the control to remove
  62042. * @returns the current container
  62043. */
  62044. removeControl(control: Control): Container;
  62045. /** @hidden */ private _reOrderControl(control: Control): void;
  62046. /** @hidden */ private _offsetLeft(offset: number): void;
  62047. /** @hidden */ private _offsetTop(offset: number): void;
  62048. /** @hidden */ private _markAllAsDirty(): void;
  62049. /** @hidden */
  62050. protected _localDraw(context: CanvasRenderingContext2D): void;
  62051. /** @hidden */ private _link(host: AdvancedDynamicTexture): void;
  62052. /** @hidden */
  62053. protected _beforeLayout(): void;
  62054. /** @hidden */
  62055. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62056. /** @hidden */ private _layout(parentMeasure: Measure, context: CanvasRenderingContext2D): boolean;
  62057. protected _postMeasure(): void;
  62058. /** @hidden */ private _draw(context: CanvasRenderingContext2D, invalidatedRectangle?: Measure): void;
  62059. /** @hidden */ private _getDescendants(results: Control[], directDescendantsOnly?: boolean, predicate?: (control: Control) => boolean): void;
  62060. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62061. /** @hidden */
  62062. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62063. /** Releases associated resources */
  62064. dispose(): void;
  62065. }
  62066. }
  62067. declare module BABYLON.GUI {
  62068. /** Class used to create rectangle container */
  62069. export class Rectangle extends Container {
  62070. name?: string | undefined;
  62071. private _thickness;
  62072. private _cornerRadius;
  62073. /** Gets or sets border thickness */
  62074. thickness: number;
  62075. /** Gets or sets the corner radius angle */
  62076. cornerRadius: number;
  62077. /**
  62078. * Creates a new Rectangle
  62079. * @param name defines the control name
  62080. */
  62081. constructor(name?: string | undefined);
  62082. protected _getTypeName(): string;
  62083. protected _localDraw(context: CanvasRenderingContext2D): void;
  62084. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62085. private _drawRoundedRect;
  62086. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62087. }
  62088. }
  62089. declare module BABYLON.GUI {
  62090. /**
  62091. * Enum that determines the text-wrapping mode to use.
  62092. */
  62093. export enum TextWrapping {
  62094. /**
  62095. * Clip the text when it's larger than Control.width; this is the default mode.
  62096. */
  62097. Clip = 0,
  62098. /**
  62099. * Wrap the text word-wise, i.e. try to add line-breaks at word boundary to fit within Control.width.
  62100. */
  62101. WordWrap = 1,
  62102. /**
  62103. * Ellipsize the text, i.e. shrink with trailing … when text is larger than Control.width.
  62104. */
  62105. Ellipsis = 2
  62106. }
  62107. /**
  62108. * Class used to create text block control
  62109. */
  62110. export class TextBlock extends Control {
  62111. /**
  62112. * Defines the name of the control
  62113. */
  62114. name?: string | undefined;
  62115. private _text;
  62116. private _textWrapping;
  62117. private _textHorizontalAlignment;
  62118. private _textVerticalAlignment;
  62119. private _lines;
  62120. private _resizeToFit;
  62121. private _lineSpacing;
  62122. private _outlineWidth;
  62123. private _outlineColor;
  62124. /**
  62125. * An event triggered after the text is changed
  62126. */
  62127. onTextChangedObservable: BABYLON.Observable<TextBlock>;
  62128. /**
  62129. * An event triggered after the text was broken up into lines
  62130. */
  62131. onLinesReadyObservable: BABYLON.Observable<TextBlock>;
  62132. /**
  62133. * Return the line list (you may need to use the onLinesReadyObservable to make sure the list is ready)
  62134. */
  62135. readonly lines: any[];
  62136. /**
  62137. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62138. */
  62139. /**
  62140. * Gets or sets an boolean indicating that the TextBlock will be resized to fit container
  62141. */
  62142. resizeToFit: boolean;
  62143. /**
  62144. * Gets or sets a boolean indicating if text must be wrapped
  62145. */
  62146. /**
  62147. * Gets or sets a boolean indicating if text must be wrapped
  62148. */
  62149. textWrapping: TextWrapping | boolean;
  62150. /**
  62151. * Gets or sets text to display
  62152. */
  62153. /**
  62154. * Gets or sets text to display
  62155. */
  62156. text: string;
  62157. /**
  62158. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62159. */
  62160. /**
  62161. * Gets or sets text horizontal alignment (BABYLON.GUI.Control.HORIZONTAL_ALIGNMENT_CENTER by default)
  62162. */
  62163. textHorizontalAlignment: number;
  62164. /**
  62165. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62166. */
  62167. /**
  62168. * Gets or sets text vertical alignment (BABYLON.GUI.Control.VERTICAL_ALIGNMENT_CENTER by default)
  62169. */
  62170. textVerticalAlignment: number;
  62171. /**
  62172. * Gets or sets line spacing value
  62173. */
  62174. /**
  62175. * Gets or sets line spacing value
  62176. */
  62177. lineSpacing: string | number;
  62178. /**
  62179. * Gets or sets outlineWidth of the text to display
  62180. */
  62181. /**
  62182. * Gets or sets outlineWidth of the text to display
  62183. */
  62184. outlineWidth: number;
  62185. /**
  62186. * Gets or sets outlineColor of the text to display
  62187. */
  62188. /**
  62189. * Gets or sets outlineColor of the text to display
  62190. */
  62191. outlineColor: string;
  62192. /**
  62193. * Creates a new TextBlock object
  62194. * @param name defines the name of the control
  62195. * @param text defines the text to display (emptry string by default)
  62196. */
  62197. constructor(
  62198. /**
  62199. * Defines the name of the control
  62200. */
  62201. name?: string | undefined, text?: string);
  62202. protected _getTypeName(): string;
  62203. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62204. private _drawText;
  62205. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  62206. protected _applyStates(context: CanvasRenderingContext2D): void;
  62207. protected _breakLines(refWidth: number, context: CanvasRenderingContext2D): object[];
  62208. protected _parseLine(line: string | undefined, context: CanvasRenderingContext2D): object;
  62209. protected _parseLineEllipsis(line: string | undefined, width: number, context: CanvasRenderingContext2D): object;
  62210. protected _parseLineWordWrap(line: string | undefined, width: number, context: CanvasRenderingContext2D): object[];
  62211. protected _renderLines(context: CanvasRenderingContext2D): void;
  62212. /**
  62213. * Given a width constraint applied on the text block, find the expected height
  62214. * @returns expected height
  62215. */
  62216. computeExpectedHeight(): number;
  62217. dispose(): void;
  62218. }
  62219. }
  62220. declare module BABYLON.GUI {
  62221. /**
  62222. * Class used to create 2D images
  62223. */
  62224. export class Image extends Control {
  62225. name?: string | undefined;
  62226. private static _WorkingCanvas;
  62227. private _domImage;
  62228. private _imageWidth;
  62229. private _imageHeight;
  62230. private _loaded;
  62231. private _stretch;
  62232. private _source;
  62233. private _autoScale;
  62234. private _sourceLeft;
  62235. private _sourceTop;
  62236. private _sourceWidth;
  62237. private _sourceHeight;
  62238. private _cellWidth;
  62239. private _cellHeight;
  62240. private _cellId;
  62241. private _populateNinePatchSlicesFromImage;
  62242. private _sliceLeft;
  62243. private _sliceRight;
  62244. private _sliceTop;
  62245. private _sliceBottom;
  62246. private _detectPointerOnOpaqueOnly;
  62247. /**
  62248. * BABYLON.Observable notified when the content is loaded
  62249. */
  62250. onImageLoadedObservable: BABYLON.Observable<Image>;
  62251. /**
  62252. * Gets a boolean indicating that the content is loaded
  62253. */
  62254. readonly isLoaded: boolean;
  62255. /**
  62256. * Gets or sets a boolean indicating if nine patch slices (left, top, right, bottom) should be read from image data
  62257. */
  62258. populateNinePatchSlicesFromImage: boolean;
  62259. /**
  62260. * Gets or sets a boolean indicating if pointers should only be validated on pixels with alpha > 0.
  62261. * Beware using this as this will comsume more memory as the image has to be stored twice
  62262. */
  62263. detectPointerOnOpaqueOnly: boolean;
  62264. /**
  62265. * Gets or sets the left value for slicing (9-patch)
  62266. */
  62267. sliceLeft: number;
  62268. /**
  62269. * Gets or sets the right value for slicing (9-patch)
  62270. */
  62271. sliceRight: number;
  62272. /**
  62273. * Gets or sets the top value for slicing (9-patch)
  62274. */
  62275. sliceTop: number;
  62276. /**
  62277. * Gets or sets the bottom value for slicing (9-patch)
  62278. */
  62279. sliceBottom: number;
  62280. /**
  62281. * Gets or sets the left coordinate in the source image
  62282. */
  62283. sourceLeft: number;
  62284. /**
  62285. * Gets or sets the top coordinate in the source image
  62286. */
  62287. sourceTop: number;
  62288. /**
  62289. * Gets or sets the width to capture in the source image
  62290. */
  62291. sourceWidth: number;
  62292. /**
  62293. * Gets or sets the height to capture in the source image
  62294. */
  62295. sourceHeight: number;
  62296. /**
  62297. * Gets or sets a boolean indicating if the image can force its container to adapt its size
  62298. * @see http://doc.babylonjs.com/how_to/gui#image
  62299. */
  62300. autoScale: boolean;
  62301. /** Gets or sets the streching mode used by the image */
  62302. stretch: number;
  62303. /**
  62304. * Gets or sets the internal DOM image used to render the control
  62305. */
  62306. domImage: HTMLImageElement;
  62307. private _onImageLoaded;
  62308. private _extractNinePatchSliceDataFromImage;
  62309. /**
  62310. * Gets or sets image source url
  62311. */
  62312. source: BABYLON.Nullable<string>;
  62313. /**
  62314. * Gets or sets the cell width to use when animation sheet is enabled
  62315. * @see http://doc.babylonjs.com/how_to/gui#image
  62316. */
  62317. cellWidth: number;
  62318. /**
  62319. * Gets or sets the cell height to use when animation sheet is enabled
  62320. * @see http://doc.babylonjs.com/how_to/gui#image
  62321. */
  62322. cellHeight: number;
  62323. /**
  62324. * Gets or sets the cell id to use (this will turn on the animation sheet mode)
  62325. * @see http://doc.babylonjs.com/how_to/gui#image
  62326. */
  62327. cellId: number;
  62328. /**
  62329. * Creates a new Image
  62330. * @param name defines the control name
  62331. * @param url defines the image url
  62332. */
  62333. constructor(name?: string | undefined, url?: BABYLON.Nullable<string>);
  62334. /**
  62335. * Tests if a given coordinates belong to the current control
  62336. * @param x defines x coordinate to test
  62337. * @param y defines y coordinate to test
  62338. * @returns true if the coordinates are inside the control
  62339. */
  62340. contains(x: number, y: number): boolean;
  62341. protected _getTypeName(): string;
  62342. /** Force the control to synchronize with its content */
  62343. synchronizeSizeWithContent(): void;
  62344. protected _processMeasures(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62345. private _prepareWorkingCanvasForOpaqueDetection;
  62346. private _drawImage; private _draw(context: CanvasRenderingContext2D): void;
  62347. private _renderCornerPatch;
  62348. private _renderNinePatch;
  62349. dispose(): void;
  62350. /** STRETCH_NONE */
  62351. static readonly STRETCH_NONE: number;
  62352. /** STRETCH_FILL */
  62353. static readonly STRETCH_FILL: number;
  62354. /** STRETCH_UNIFORM */
  62355. static readonly STRETCH_UNIFORM: number;
  62356. /** STRETCH_EXTEND */
  62357. static readonly STRETCH_EXTEND: number;
  62358. /** NINE_PATCH */
  62359. static readonly STRETCH_NINE_PATCH: number;
  62360. }
  62361. }
  62362. declare module BABYLON.GUI {
  62363. /**
  62364. * Class used to create 2D buttons
  62365. */
  62366. export class Button extends Rectangle {
  62367. name?: string | undefined;
  62368. /**
  62369. * Function called to generate a pointer enter animation
  62370. */
  62371. pointerEnterAnimation: () => void;
  62372. /**
  62373. * Function called to generate a pointer out animation
  62374. */
  62375. pointerOutAnimation: () => void;
  62376. /**
  62377. * Function called to generate a pointer down animation
  62378. */
  62379. pointerDownAnimation: () => void;
  62380. /**
  62381. * Function called to generate a pointer up animation
  62382. */
  62383. pointerUpAnimation: () => void;
  62384. /**
  62385. * Gets or sets a boolean indicating that the button will let internal controls handle picking instead of doing it directly using its bounding info
  62386. */
  62387. delegatePickingToChildren: boolean;
  62388. private _image;
  62389. /**
  62390. * Returns the image part of the button (if any)
  62391. */
  62392. readonly image: BABYLON.Nullable<Image>;
  62393. private _textBlock;
  62394. /**
  62395. * Returns the image part of the button (if any)
  62396. */
  62397. readonly textBlock: BABYLON.Nullable<TextBlock>;
  62398. /**
  62399. * Creates a new Button
  62400. * @param name defines the name of the button
  62401. */
  62402. constructor(name?: string | undefined);
  62403. protected _getTypeName(): string;
  62404. /** @hidden */ private _processPicking(x: number, y: number, type: number, pointerId: number, buttonIndex: number): boolean;
  62405. /** @hidden */ private _onPointerEnter(target: Control): boolean;
  62406. /** @hidden */ private _onPointerOut(target: Control, force?: boolean): void;
  62407. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62408. /** @hidden */ private _onPointerUp(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  62409. /**
  62410. * Creates a new button made with an image and a text
  62411. * @param name defines the name of the button
  62412. * @param text defines the text of the button
  62413. * @param imageUrl defines the url of the image
  62414. * @returns a new Button
  62415. */
  62416. static CreateImageButton(name: string, text: string, imageUrl: string): Button;
  62417. /**
  62418. * Creates a new button made with an image
  62419. * @param name defines the name of the button
  62420. * @param imageUrl defines the url of the image
  62421. * @returns a new Button
  62422. */
  62423. static CreateImageOnlyButton(name: string, imageUrl: string): Button;
  62424. /**
  62425. * Creates a new button made with a text
  62426. * @param name defines the name of the button
  62427. * @param text defines the text of the button
  62428. * @returns a new Button
  62429. */
  62430. static CreateSimpleButton(name: string, text: string): Button;
  62431. /**
  62432. * Creates a new button made with an image and a centered text
  62433. * @param name defines the name of the button
  62434. * @param text defines the text of the button
  62435. * @param imageUrl defines the url of the image
  62436. * @returns a new Button
  62437. */
  62438. static CreateImageWithCenterTextButton(name: string, text: string, imageUrl: string): Button;
  62439. }
  62440. }
  62441. declare module BABYLON.GUI {
  62442. /**
  62443. * Class used to create a 2D stack panel container
  62444. */
  62445. export class StackPanel extends Container {
  62446. name?: string | undefined;
  62447. private _isVertical;
  62448. private _manualWidth;
  62449. private _manualHeight;
  62450. private _doNotTrackManualChanges;
  62451. /**
  62452. * Gets or sets a boolean indicating that layou warnings should be ignored
  62453. */
  62454. ignoreLayoutWarnings: boolean;
  62455. /** Gets or sets a boolean indicating if the stack panel is vertical or horizontal*/
  62456. isVertical: boolean;
  62457. /**
  62458. * Gets or sets panel width.
  62459. * This value should not be set when in horizontal mode as it will be computed automatically
  62460. */
  62461. width: string | number;
  62462. /**
  62463. * Gets or sets panel height.
  62464. * This value should not be set when in vertical mode as it will be computed automatically
  62465. */
  62466. height: string | number;
  62467. /**
  62468. * Creates a new StackPanel
  62469. * @param name defines control name
  62470. */
  62471. constructor(name?: string | undefined);
  62472. protected _getTypeName(): string;
  62473. /** @hidden */
  62474. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62475. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62476. protected _postMeasure(): void;
  62477. }
  62478. }
  62479. declare module BABYLON.GUI {
  62480. /**
  62481. * Class used to represent a 2D checkbox
  62482. */
  62483. export class Checkbox extends Control {
  62484. name?: string | undefined;
  62485. private _isChecked;
  62486. private _background;
  62487. private _checkSizeRatio;
  62488. private _thickness;
  62489. /** Gets or sets border thickness */
  62490. thickness: number;
  62491. /**
  62492. * BABYLON.Observable raised when isChecked property changes
  62493. */
  62494. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  62495. /** Gets or sets a value indicating the ratio between overall size and check size */
  62496. checkSizeRatio: number;
  62497. /** Gets or sets background color */
  62498. background: string;
  62499. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  62500. isChecked: boolean;
  62501. /**
  62502. * Creates a new CheckBox
  62503. * @param name defines the control name
  62504. */
  62505. constructor(name?: string | undefined);
  62506. protected _getTypeName(): string;
  62507. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  62508. /** @hidden */ private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  62509. /**
  62510. * Utility function to easily create a checkbox with a header
  62511. * @param title defines the label to use for the header
  62512. * @param onValueChanged defines the callback to call when value changes
  62513. * @returns a StackPanel containing the checkbox and a textBlock
  62514. */
  62515. static AddCheckBoxWithHeader(title: string, onValueChanged: (value: boolean) => void): StackPanel;
  62516. }
  62517. }
  62518. declare module BABYLON.GUI {
  62519. /**
  62520. * Class used to store key control properties
  62521. */
  62522. export class KeyPropertySet {
  62523. /** Width */
  62524. width?: string;
  62525. /** Height */
  62526. height?: string;
  62527. /** Left padding */
  62528. paddingLeft?: string;
  62529. /** Right padding */
  62530. paddingRight?: string;
  62531. /** Top padding */
  62532. paddingTop?: string;
  62533. /** Bottom padding */
  62534. paddingBottom?: string;
  62535. /** Foreground color */
  62536. color?: string;
  62537. /** Background color */
  62538. background?: string;
  62539. }
  62540. /**
  62541. * Class used to create virtual keyboard
  62542. */
  62543. export class VirtualKeyboard extends StackPanel {
  62544. /** BABYLON.Observable raised when a key is pressed */
  62545. onKeyPressObservable: BABYLON.Observable<string>;
  62546. /** Gets or sets default key button width */
  62547. defaultButtonWidth: string;
  62548. /** Gets or sets default key button height */
  62549. defaultButtonHeight: string;
  62550. /** Gets or sets default key button left padding */
  62551. defaultButtonPaddingLeft: string;
  62552. /** Gets or sets default key button right padding */
  62553. defaultButtonPaddingRight: string;
  62554. /** Gets or sets default key button top padding */
  62555. defaultButtonPaddingTop: string;
  62556. /** Gets or sets default key button bottom padding */
  62557. defaultButtonPaddingBottom: string;
  62558. /** Gets or sets default key button foreground color */
  62559. defaultButtonColor: string;
  62560. /** Gets or sets default key button background color */
  62561. defaultButtonBackground: string;
  62562. /** Gets or sets shift button foreground color */
  62563. shiftButtonColor: string;
  62564. /** Gets or sets shift button thickness*/
  62565. selectedShiftThickness: number;
  62566. /** Gets shift key state */
  62567. shiftState: number;
  62568. protected _getTypeName(): string;
  62569. private _createKey;
  62570. /**
  62571. * Adds a new row of keys
  62572. * @param keys defines the list of keys to add
  62573. * @param propertySets defines the associated property sets
  62574. */
  62575. addKeysRow(keys: Array<string>, propertySets?: Array<KeyPropertySet>): void;
  62576. /**
  62577. * Set the shift key to a specific state
  62578. * @param shiftState defines the new shift state
  62579. */
  62580. applyShiftState(shiftState: number): void;
  62581. private _currentlyConnectedInputText;
  62582. private _connectedInputTexts;
  62583. private _onKeyPressObserver;
  62584. /** Gets the input text control currently attached to the keyboard */
  62585. readonly connectedInputText: BABYLON.Nullable<InputText>;
  62586. /**
  62587. * Connects the keyboard with an input text control
  62588. *
  62589. * @param input defines the target control
  62590. */
  62591. connect(input: InputText): void;
  62592. /**
  62593. * Disconnects the keyboard from connected InputText controls
  62594. *
  62595. * @param input optionally defines a target control, otherwise all are disconnected
  62596. */
  62597. disconnect(input?: InputText): void;
  62598. private _removeConnectedInputObservables;
  62599. /**
  62600. * Release all resources
  62601. */
  62602. dispose(): void;
  62603. /**
  62604. * Creates a new keyboard using a default layout
  62605. *
  62606. * @param name defines control name
  62607. * @returns a new VirtualKeyboard
  62608. */
  62609. static CreateDefaultLayout(name?: string): VirtualKeyboard;
  62610. }
  62611. }
  62612. declare module BABYLON.GUI {
  62613. /**
  62614. * Class used to create input text control
  62615. */
  62616. export class InputText extends Control implements IFocusableControl {
  62617. name?: string | undefined;
  62618. private _text;
  62619. private _placeholderText;
  62620. private _background;
  62621. private _focusedBackground;
  62622. private _focusedColor;
  62623. private _placeholderColor;
  62624. private _thickness;
  62625. private _margin;
  62626. private _autoStretchWidth;
  62627. private _maxWidth;
  62628. private _isFocused;
  62629. private _blinkTimeout;
  62630. private _blinkIsEven;
  62631. private _cursorOffset;
  62632. private _scrollLeft;
  62633. private _textWidth;
  62634. private _clickedCoordinate;
  62635. private _deadKey;
  62636. private _addKey;
  62637. private _currentKey;
  62638. private _isTextHighlightOn;
  62639. private _textHighlightColor;
  62640. private _highligherOpacity;
  62641. private _highlightedText;
  62642. private _startHighlightIndex;
  62643. private _endHighlightIndex;
  62644. private _cursorIndex;
  62645. private _onFocusSelectAll;
  62646. private _isPointerDown;
  62647. private _onClipboardObserver;
  62648. private _onPointerDblTapObserver;
  62649. /** @hidden */ private _connectedVirtualKeyboard: BABYLON.Nullable<VirtualKeyboard>;
  62650. /** Gets or sets a string representing the message displayed on mobile when the control gets the focus */
  62651. promptMessage: string;
  62652. /** Force disable prompt on mobile device */
  62653. disableMobilePrompt: boolean;
  62654. /** BABYLON.Observable raised when the text changes */
  62655. onTextChangedObservable: BABYLON.Observable<InputText>;
  62656. /** BABYLON.Observable raised just before an entered character is to be added */
  62657. onBeforeKeyAddObservable: BABYLON.Observable<InputText>;
  62658. /** BABYLON.Observable raised when the control gets the focus */
  62659. onFocusObservable: BABYLON.Observable<InputText>;
  62660. /** BABYLON.Observable raised when the control loses the focus */
  62661. onBlurObservable: BABYLON.Observable<InputText>;
  62662. /**Observable raised when the text is highlighted */
  62663. onTextHighlightObservable: BABYLON.Observable<InputText>;
  62664. /**Observable raised when copy event is triggered */
  62665. onTextCopyObservable: BABYLON.Observable<InputText>;
  62666. /** BABYLON.Observable raised when cut event is triggered */
  62667. onTextCutObservable: BABYLON.Observable<InputText>;
  62668. /** BABYLON.Observable raised when paste event is triggered */
  62669. onTextPasteObservable: BABYLON.Observable<InputText>;
  62670. /** BABYLON.Observable raised when a key event was processed */
  62671. onKeyboardEventProcessedObservable: BABYLON.Observable<KeyboardEvent>;
  62672. /** Gets or sets the maximum width allowed by the control */
  62673. maxWidth: string | number;
  62674. /** Gets the maximum width allowed by the control in pixels */
  62675. readonly maxWidthInPixels: number;
  62676. /** Gets or sets the text highlighter transparency; default: 0.4 */
  62677. highligherOpacity: number;
  62678. /** Gets or sets a boolean indicating whether to select complete text by default on input focus */
  62679. onFocusSelectAll: boolean;
  62680. /** Gets or sets the text hightlight color */
  62681. textHighlightColor: string;
  62682. /** Gets or sets control margin */
  62683. margin: string;
  62684. /** Gets control margin in pixels */
  62685. readonly marginInPixels: number;
  62686. /** Gets or sets a boolean indicating if the control can auto stretch its width to adapt to the text */
  62687. autoStretchWidth: boolean;
  62688. /** Gets or sets border thickness */
  62689. thickness: number;
  62690. /** Gets or sets the background color when focused */
  62691. focusedBackground: string;
  62692. /** Gets or sets the background color when focused */
  62693. focusedColor: string;
  62694. /** Gets or sets the background color */
  62695. background: string;
  62696. /** Gets or sets the placeholder color */
  62697. placeholderColor: string;
  62698. /** Gets or sets the text displayed when the control is empty */
  62699. placeholderText: string;
  62700. /** Gets or sets the dead key flag */
  62701. deadKey: boolean;
  62702. /** Gets or sets the highlight text */
  62703. highlightedText: string;
  62704. /** Gets or sets if the current key should be added */
  62705. addKey: boolean;
  62706. /** Gets or sets the value of the current key being entered */
  62707. currentKey: string;
  62708. /** Gets or sets the text displayed in the control */
  62709. text: string;
  62710. /** Gets or sets control width */
  62711. width: string | number;
  62712. /**
  62713. * Creates a new InputText
  62714. * @param name defines the control name
  62715. * @param text defines the text of the control
  62716. */
  62717. constructor(name?: string | undefined, text?: string);
  62718. /** @hidden */
  62719. onBlur(): void;
  62720. /** @hidden */
  62721. onFocus(): void;
  62722. protected _getTypeName(): string;
  62723. /**
  62724. * Function called to get the list of controls that should not steal the focus from this control
  62725. * @returns an array of controls
  62726. */
  62727. keepsFocusWith(): BABYLON.Nullable<Control[]>;
  62728. /** @hidden */
  62729. processKey(keyCode: number, key?: string, evt?: KeyboardEvent): void;
  62730. /** @hidden */
  62731. private _updateValueFromCursorIndex;
  62732. /** @hidden */
  62733. private _processDblClick;
  62734. /** @hidden */
  62735. private _selectAllText;
  62736. /**
  62737. * Handles the keyboard event
  62738. * @param evt Defines the KeyboardEvent
  62739. */
  62740. processKeyboard(evt: KeyboardEvent): void;
  62741. /** @hidden */
  62742. private _onCopyText;
  62743. /** @hidden */
  62744. private _onCutText;
  62745. /** @hidden */
  62746. 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;
  62747. protected _beforeRenderText(text: string): string;
  62748. dispose(): void;
  62749. }
  62750. }
  62751. declare module BABYLON.GUI {
  62752. /**
  62753. * Class used to create a 2D grid container
  62754. */
  62755. export class Grid extends Container {
  62756. name?: string | undefined;
  62757. private _rowDefinitions;
  62758. private _columnDefinitions;
  62759. private _cells;
  62760. private _childControls;
  62761. /**
  62762. * Gets the number of columns
  62763. */
  62764. readonly columnCount: number;
  62765. /**
  62766. * Gets the number of rows
  62767. */
  62768. readonly rowCount: number;
  62769. /** Gets the list of children */
  62770. readonly children: Control[];
  62771. /** Gets the list of cells (e.g. the containers) */
  62772. readonly cells: {
  62773. [key: string]: Container;
  62774. };
  62775. /**
  62776. * Gets the definition of a specific row
  62777. * @param index defines the index of the row
  62778. * @returns the row definition
  62779. */
  62780. getRowDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62781. /**
  62782. * Gets the definition of a specific column
  62783. * @param index defines the index of the column
  62784. * @returns the column definition
  62785. */
  62786. getColumnDefinition(index: number): BABYLON.Nullable<ValueAndUnit>;
  62787. /**
  62788. * Adds a new row to the grid
  62789. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62790. * @param isPixel defines if the height is expressed in pixel (or in percentage)
  62791. * @returns the current grid
  62792. */
  62793. addRowDefinition(height: number, isPixel?: boolean): Grid;
  62794. /**
  62795. * Adds a new column to the grid
  62796. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62797. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62798. * @returns the current grid
  62799. */
  62800. addColumnDefinition(width: number, isPixel?: boolean): Grid;
  62801. /**
  62802. * Update a row definition
  62803. * @param index defines the index of the row to update
  62804. * @param height defines the height of the row (either in pixel or a value between 0 and 1)
  62805. * @param isPixel defines if the weight is expressed in pixel (or in percentage)
  62806. * @returns the current grid
  62807. */
  62808. setRowDefinition(index: number, height: number, isPixel?: boolean): Grid;
  62809. /**
  62810. * Update a column definition
  62811. * @param index defines the index of the column to update
  62812. * @param width defines the width of the column (either in pixel or a value between 0 and 1)
  62813. * @param isPixel defines if the width is expressed in pixel (or in percentage)
  62814. * @returns the current grid
  62815. */
  62816. setColumnDefinition(index: number, width: number, isPixel?: boolean): Grid;
  62817. /**
  62818. * Gets the list of children stored in a specific cell
  62819. * @param row defines the row to check
  62820. * @param column defines the column to check
  62821. * @returns the list of controls
  62822. */
  62823. getChildrenAt(row: number, column: number): BABYLON.Nullable<Array<Control>>;
  62824. /**
  62825. * Gets a string representing the child cell info (row x column)
  62826. * @param child defines the control to get info from
  62827. * @returns a string containing the child cell info (row x column)
  62828. */
  62829. getChildCellInfo(child: Control): string;
  62830. private _removeCell;
  62831. private _offsetCell;
  62832. /**
  62833. * Remove a column definition at specified index
  62834. * @param index defines the index of the column to remove
  62835. * @returns the current grid
  62836. */
  62837. removeColumnDefinition(index: number): Grid;
  62838. /**
  62839. * Remove a row definition at specified index
  62840. * @param index defines the index of the row to remove
  62841. * @returns the current grid
  62842. */
  62843. removeRowDefinition(index: number): Grid;
  62844. /**
  62845. * Adds a new control to the current grid
  62846. * @param control defines the control to add
  62847. * @param row defines the row where to add the control (0 by default)
  62848. * @param column defines the column where to add the control (0 by default)
  62849. * @returns the current grid
  62850. */
  62851. addControl(control: Control, row?: number, column?: number): Grid;
  62852. /**
  62853. * Removes a control from the current container
  62854. * @param control defines the control to remove
  62855. * @returns the current container
  62856. */
  62857. removeControl(control: Control): Container;
  62858. /**
  62859. * Creates a new Grid
  62860. * @param name defines control name
  62861. */
  62862. constructor(name?: string | undefined);
  62863. protected _getTypeName(): string;
  62864. protected _getGridDefinitions(definitionCallback: (lefts: number[], tops: number[], widths: number[], heights: number[]) => void): void;
  62865. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _flagDescendantsAsMatrixDirty(): void; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  62866. /** Releases associated resources */
  62867. dispose(): void;
  62868. }
  62869. }
  62870. declare module BABYLON.GUI {
  62871. /** Class used to create color pickers */
  62872. export class ColorPicker extends Control {
  62873. name?: string | undefined;
  62874. private static _Epsilon;
  62875. private _colorWheelCanvas;
  62876. private _value;
  62877. private _tmpColor;
  62878. private _pointerStartedOnSquare;
  62879. private _pointerStartedOnWheel;
  62880. private _squareLeft;
  62881. private _squareTop;
  62882. private _squareSize;
  62883. private _h;
  62884. private _s;
  62885. private _v;
  62886. private _lastPointerDownID;
  62887. /**
  62888. * BABYLON.Observable raised when the value changes
  62889. */
  62890. onValueChangedObservable: BABYLON.Observable<BABYLON.Color3>;
  62891. /** Gets or sets the color of the color picker */
  62892. value: BABYLON.Color3;
  62893. /**
  62894. * Gets or sets control width
  62895. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62896. */
  62897. width: string | number;
  62898. /**
  62899. * Gets or sets control height
  62900. * @see http://doc.babylonjs.com/how_to/gui#position-and-size
  62901. */
  62902. /** Gets or sets control height */
  62903. height: string | number;
  62904. /** Gets or sets control size */
  62905. size: string | number;
  62906. /**
  62907. * Creates a new ColorPicker
  62908. * @param name defines the control name
  62909. */
  62910. constructor(name?: string | undefined);
  62911. protected _getTypeName(): string;
  62912. /** @hidden */
  62913. protected _preMeasure(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62914. private _updateSquareProps;
  62915. private _drawGradientSquare;
  62916. private _drawCircle;
  62917. private _createColorWheelCanvas;
  62918. /** @hidden */ private _draw(context: CanvasRenderingContext2D): void;
  62919. private _pointerIsDown;
  62920. private _updateValueFromPointer;
  62921. private _isPointOnSquare;
  62922. 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;
  62923. /**
  62924. * This function expands the color picker by creating a color picker dialog with manual
  62925. * color value input and the ability to save colors into an array to be used later in
  62926. * subsequent launches of the dialogue.
  62927. * @param advancedTexture defines the AdvancedDynamicTexture the dialog is assigned to
  62928. * @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.
  62929. * @returns picked color as a hex string and the saved colors array as hex strings.
  62930. */
  62931. static ShowPickerDialogAsync(advancedTexture: AdvancedDynamicTexture, options: {
  62932. pickerWidth?: string;
  62933. pickerHeight?: string;
  62934. headerHeight?: string;
  62935. lastColor?: string;
  62936. swatchLimit?: number;
  62937. numSwatchesPerLine?: number;
  62938. savedColors?: Array<string>;
  62939. }): Promise<{
  62940. savedColors?: string[];
  62941. pickedColor: string;
  62942. }>;
  62943. }
  62944. }
  62945. declare module BABYLON.GUI {
  62946. /** Class used to create 2D ellipse containers */
  62947. export class Ellipse extends Container {
  62948. name?: string | undefined;
  62949. private _thickness;
  62950. /** Gets or sets border thickness */
  62951. thickness: number;
  62952. /**
  62953. * Creates a new Ellipse
  62954. * @param name defines the control name
  62955. */
  62956. constructor(name?: string | undefined);
  62957. protected _getTypeName(): string;
  62958. protected _localDraw(context: CanvasRenderingContext2D): void;
  62959. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  62960. protected _clipForChildren(context: CanvasRenderingContext2D): void;
  62961. }
  62962. }
  62963. declare module BABYLON.GUI {
  62964. /**
  62965. * Class used to create a password control
  62966. */
  62967. export class InputPassword extends InputText {
  62968. protected _beforeRenderText(text: string): string;
  62969. }
  62970. }
  62971. declare module BABYLON.GUI {
  62972. /** Class used to render 2D lines */
  62973. export class Line extends Control {
  62974. name?: string | undefined;
  62975. private _lineWidth;
  62976. private _x1;
  62977. private _y1;
  62978. private _x2;
  62979. private _y2;
  62980. private _dash;
  62981. private _connectedControl;
  62982. private _connectedControlDirtyObserver;
  62983. /** Gets or sets the dash pattern */
  62984. dash: Array<number>;
  62985. /** Gets or sets the control connected with the line end */
  62986. connectedControl: Control;
  62987. /** Gets or sets start coordinates on X axis */
  62988. x1: string | number;
  62989. /** Gets or sets start coordinates on Y axis */
  62990. y1: string | number;
  62991. /** Gets or sets end coordinates on X axis */
  62992. x2: string | number;
  62993. /** Gets or sets end coordinates on Y axis */
  62994. y2: string | number;
  62995. /** Gets or sets line width */
  62996. lineWidth: number;
  62997. /** Gets or sets horizontal alignment */
  62998. horizontalAlignment: number;
  62999. /** Gets or sets vertical alignment */
  63000. verticalAlignment: number;
  63001. private readonly _effectiveX2;
  63002. private readonly _effectiveY2;
  63003. /**
  63004. * Creates a new Line
  63005. * @param name defines the control name
  63006. */
  63007. constructor(name?: string | undefined);
  63008. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _measure(): void;
  63009. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63010. /**
  63011. * Move one end of the line given 3D cartesian coordinates.
  63012. * @param position Targeted world position
  63013. * @param scene BABYLON.Scene
  63014. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63015. */
  63016. moveToVector3(position: BABYLON.Vector3, scene: BABYLON.Scene, end?: boolean): void;
  63017. /**
  63018. * Move one end of the line to a position in screen absolute space.
  63019. * @param projectedPosition Position in screen absolute space (X, Y)
  63020. * @param end (opt) Set to true to assign x2 and y2 coordinates of the line. Default assign to x1 and y1.
  63021. */ private _moveToProjectedPosition(projectedPosition: BABYLON.Vector3, end?: boolean): void;
  63022. }
  63023. }
  63024. declare module BABYLON.GUI {
  63025. /**
  63026. * Class used to store a point for a MultiLine object.
  63027. * The point can be pure 2D coordinates, a mesh or a control
  63028. */
  63029. export class MultiLinePoint {
  63030. private _multiLine;
  63031. private _x;
  63032. private _y;
  63033. private _control;
  63034. private _mesh;
  63035. private _controlObserver;
  63036. private _meshObserver;
  63037. /** @hidden */ private _point: BABYLON.Vector2;
  63038. /**
  63039. * Creates a new MultiLinePoint
  63040. * @param multiLine defines the source MultiLine object
  63041. */
  63042. constructor(multiLine: MultiLine);
  63043. /** Gets or sets x coordinate */
  63044. x: string | number;
  63045. /** Gets or sets y coordinate */
  63046. y: string | number;
  63047. /** Gets or sets the control associated with this point */
  63048. control: BABYLON.Nullable<Control>;
  63049. /** Gets or sets the mesh associated with this point */
  63050. mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63051. /** Resets links */
  63052. resetLinks(): void;
  63053. /**
  63054. * Gets a translation vector
  63055. * @returns the translation vector
  63056. */
  63057. translate(): BABYLON.Vector2;
  63058. private _translatePoint;
  63059. /** Release associated resources */
  63060. dispose(): void;
  63061. }
  63062. }
  63063. declare module BABYLON.GUI {
  63064. /**
  63065. * Class used to create multi line control
  63066. */
  63067. export class MultiLine extends Control {
  63068. name?: string | undefined;
  63069. private _lineWidth;
  63070. private _dash;
  63071. private _points;
  63072. private _minX;
  63073. private _minY;
  63074. private _maxX;
  63075. private _maxY;
  63076. /**
  63077. * Creates a new MultiLine
  63078. * @param name defines the control name
  63079. */
  63080. constructor(name?: string | undefined);
  63081. /** Gets or sets dash pattern */
  63082. dash: Array<number>;
  63083. /**
  63084. * Gets point stored at specified index
  63085. * @param index defines the index to look for
  63086. * @returns the requested point if found
  63087. */
  63088. getAt(index: number): MultiLinePoint;
  63089. /** Function called when a point is updated */
  63090. onPointUpdate: () => void;
  63091. /**
  63092. * Adds new points to the point collection
  63093. * @param items defines the list of items (mesh, control or 2d coordiantes) to add
  63094. * @returns the list of created MultiLinePoint
  63095. */
  63096. add(...items: (AbstractMesh | Control | {
  63097. x: string | number;
  63098. y: string | number;
  63099. })[]): MultiLinePoint[];
  63100. /**
  63101. * Adds a new point to the point collection
  63102. * @param item defines the item (mesh, control or 2d coordiantes) to add
  63103. * @returns the created MultiLinePoint
  63104. */
  63105. push(item?: (AbstractMesh | Control | {
  63106. x: string | number;
  63107. y: string | number;
  63108. })): MultiLinePoint;
  63109. /**
  63110. * Remove a specific value or point from the active point collection
  63111. * @param value defines the value or point to remove
  63112. */
  63113. remove(value: number | MultiLinePoint): void;
  63114. /**
  63115. * Resets this object to initial state (no point)
  63116. */
  63117. reset(): void;
  63118. /**
  63119. * Resets all links
  63120. */
  63121. resetLinks(): void;
  63122. /** Gets or sets line width */
  63123. lineWidth: number;
  63124. horizontalAlignment: number;
  63125. verticalAlignment: number;
  63126. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63127. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void; private _measure(): void;
  63128. protected _computeAlignment(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63129. dispose(): void;
  63130. }
  63131. }
  63132. declare module BABYLON.GUI {
  63133. /**
  63134. * Class used to create radio button controls
  63135. */
  63136. export class RadioButton extends Control {
  63137. name?: string | undefined;
  63138. private _isChecked;
  63139. private _background;
  63140. private _checkSizeRatio;
  63141. private _thickness;
  63142. /** Gets or sets border thickness */
  63143. thickness: number;
  63144. /** Gets or sets group name */
  63145. group: string;
  63146. /** BABYLON.Observable raised when isChecked is changed */
  63147. onIsCheckedChangedObservable: BABYLON.Observable<boolean>;
  63148. /** Gets or sets a value indicating the ratio between overall size and check size */
  63149. checkSizeRatio: number;
  63150. /** Gets or sets background color */
  63151. background: string;
  63152. /** Gets or sets a boolean indicating if the checkbox is checked or not */
  63153. isChecked: boolean;
  63154. /**
  63155. * Creates a new RadioButton
  63156. * @param name defines the control name
  63157. */
  63158. constructor(name?: string | undefined);
  63159. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63160. /**
  63161. * Utility function to easily create a radio button with a header
  63162. * @param title defines the label to use for the header
  63163. * @param group defines the group to use for the radio button
  63164. * @param isChecked defines the initial state of the radio button
  63165. * @param onValueChanged defines the callback to call when value changes
  63166. * @returns a StackPanel containing the radio button and a textBlock
  63167. */
  63168. static AddRadioButtonWithHeader(title: string, group: string, isChecked: boolean, onValueChanged: (button: RadioButton, value: boolean) => void): StackPanel;
  63169. }
  63170. }
  63171. declare module BABYLON.GUI {
  63172. /**
  63173. * Class used to create slider controls
  63174. */
  63175. export class BaseSlider extends Control {
  63176. name?: string | undefined;
  63177. protected _thumbWidth: ValueAndUnit;
  63178. private _minimum;
  63179. private _maximum;
  63180. private _value;
  63181. private _isVertical;
  63182. protected _barOffset: ValueAndUnit;
  63183. private _isThumbClamped;
  63184. protected _displayThumb: boolean;
  63185. private _step;
  63186. private _lastPointerDownID;
  63187. protected _effectiveBarOffset: number;
  63188. protected _renderLeft: number;
  63189. protected _renderTop: number;
  63190. protected _renderWidth: number;
  63191. protected _renderHeight: number;
  63192. protected _backgroundBoxLength: number;
  63193. protected _backgroundBoxThickness: number;
  63194. protected _effectiveThumbThickness: number;
  63195. /** BABYLON.Observable raised when the sldier value changes */
  63196. onValueChangedObservable: BABYLON.Observable<number>;
  63197. /** Gets or sets a boolean indicating if the thumb must be rendered */
  63198. displayThumb: boolean;
  63199. /** Gets or sets a step to apply to values (0 by default) */
  63200. step: number;
  63201. /** Gets or sets main bar offset (ie. the margin applied to the value bar) */
  63202. barOffset: string | number;
  63203. /** Gets main bar offset in pixels*/
  63204. readonly barOffsetInPixels: number;
  63205. /** Gets or sets thumb width */
  63206. thumbWidth: string | number;
  63207. /** Gets thumb width in pixels */
  63208. readonly thumbWidthInPixels: number;
  63209. /** Gets or sets minimum value */
  63210. minimum: number;
  63211. /** Gets or sets maximum value */
  63212. maximum: number;
  63213. /** Gets or sets current value */
  63214. value: number;
  63215. /**Gets or sets a boolean indicating if the slider should be vertical or horizontal */
  63216. isVertical: boolean;
  63217. /** Gets or sets a value indicating if the thumb can go over main bar extends */
  63218. isThumbClamped: boolean;
  63219. /**
  63220. * Creates a new BaseSlider
  63221. * @param name defines the control name
  63222. */
  63223. constructor(name?: string | undefined);
  63224. protected _getTypeName(): string;
  63225. protected _getThumbPosition(): number;
  63226. protected _getThumbThickness(type: string): number;
  63227. protected _prepareRenderingData(type: string): void;
  63228. private _pointerIsDown;
  63229. /** @hidden */
  63230. 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;
  63231. }
  63232. }
  63233. declare module BABYLON.GUI {
  63234. /**
  63235. * Class used to create slider controls
  63236. */
  63237. export class Slider extends BaseSlider {
  63238. name?: string | undefined;
  63239. private _background;
  63240. private _borderColor;
  63241. private _isThumbCircle;
  63242. protected _displayValueBar: boolean;
  63243. /** Gets or sets a boolean indicating if the value bar must be rendered */
  63244. displayValueBar: boolean;
  63245. /** Gets or sets border color */
  63246. borderColor: string;
  63247. /** Gets or sets background color */
  63248. background: string;
  63249. /** Gets or sets a boolean indicating if the thumb should be round or square */
  63250. isThumbCircle: boolean;
  63251. /**
  63252. * Creates a new Slider
  63253. * @param name defines the control name
  63254. */
  63255. constructor(name?: string | undefined);
  63256. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63257. }
  63258. }
  63259. declare module BABYLON.GUI {
  63260. /** Class used to create a RadioGroup
  63261. * which contains groups of radio buttons
  63262. */
  63263. export class SelectorGroup {
  63264. /** name of SelectorGroup */
  63265. name: string;
  63266. private _groupPanel;
  63267. private _selectors;
  63268. private _groupHeader;
  63269. /**
  63270. * Creates a new SelectorGroup
  63271. * @param name of group, used as a group heading
  63272. */
  63273. constructor(
  63274. /** name of SelectorGroup */
  63275. name: string);
  63276. /** Gets the groupPanel of the SelectorGroup */
  63277. readonly groupPanel: StackPanel;
  63278. /** Gets the selectors array */
  63279. readonly selectors: StackPanel[];
  63280. /** Gets and sets the group header */
  63281. header: string;
  63282. /** @hidden */
  63283. private _addGroupHeader;
  63284. /** @hidden*/ private _getSelector(selectorNb: number): StackPanel | undefined;
  63285. /** Removes the selector at the given position
  63286. * @param selectorNb the position of the selector within the group
  63287. */
  63288. removeSelector(selectorNb: number): void;
  63289. }
  63290. /** Class used to create a CheckboxGroup
  63291. * which contains groups of checkbox buttons
  63292. */
  63293. export class CheckboxGroup extends SelectorGroup {
  63294. /** Adds a checkbox as a control
  63295. * @param text is the label for the selector
  63296. * @param func is the function called when the Selector is checked
  63297. * @param checked is true when Selector is checked
  63298. */
  63299. addCheckbox(text: string, func?: (s: boolean) => void, checked?: boolean): void;
  63300. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  63301. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  63302. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  63303. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63304. }
  63305. /** Class used to create a RadioGroup
  63306. * which contains groups of radio buttons
  63307. */
  63308. export class RadioGroup extends SelectorGroup {
  63309. private _selectNb;
  63310. /** Adds a radio button as a control
  63311. * @param label is the label for the selector
  63312. * @param func is the function called when the Selector is checked
  63313. * @param checked is true when Selector is checked
  63314. */
  63315. addRadio(label: string, func?: (n: number) => void, checked?: boolean): void;
  63316. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  63317. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  63318. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  63319. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63320. }
  63321. /** Class used to create a SliderGroup
  63322. * which contains groups of slider buttons
  63323. */
  63324. export class SliderGroup extends SelectorGroup {
  63325. /**
  63326. * Adds a slider to the SelectorGroup
  63327. * @param label is the label for the SliderBar
  63328. * @param func is the function called when the Slider moves
  63329. * @param unit is a string describing the units used, eg degrees or metres
  63330. * @param min is the minimum value for the Slider
  63331. * @param max is the maximum value for the Slider
  63332. * @param value is the start value for the Slider between min and max
  63333. * @param onValueChange is the function used to format the value displayed, eg radians to degrees
  63334. */
  63335. addSlider(label: string, func?: (v: number) => void, unit?: string, min?: number, max?: number, value?: number, onValueChange?: (v: number) => number): void;
  63336. /** @hidden */ private _setSelectorLabel(selectorNb: number, label: string): void;
  63337. /** @hidden */ private _setSelectorLabelColor(selectorNb: number, color: string): void;
  63338. /** @hidden */ private _setSelectorButtonColor(selectorNb: number, color: string): void;
  63339. /** @hidden */ private _setSelectorButtonBackground(selectorNb: number, color: string): void;
  63340. }
  63341. /** Class used to hold the controls for the checkboxes, radio buttons and sliders
  63342. * @see http://doc.babylonjs.com/how_to/selector
  63343. */
  63344. export class SelectionPanel extends Rectangle {
  63345. /** name of SelectionPanel */
  63346. name: string;
  63347. /** an array of SelectionGroups */
  63348. groups: SelectorGroup[];
  63349. private _panel;
  63350. private _buttonColor;
  63351. private _buttonBackground;
  63352. private _headerColor;
  63353. private _barColor;
  63354. private _barHeight;
  63355. private _spacerHeight;
  63356. private _labelColor;
  63357. private _groups;
  63358. private _bars;
  63359. /**
  63360. * Creates a new SelectionPanel
  63361. * @param name of SelectionPanel
  63362. * @param groups is an array of SelectionGroups
  63363. */
  63364. constructor(
  63365. /** name of SelectionPanel */
  63366. name: string,
  63367. /** an array of SelectionGroups */
  63368. groups?: SelectorGroup[]);
  63369. protected _getTypeName(): string;
  63370. /** Gets or sets the headerColor */
  63371. headerColor: string;
  63372. private _setHeaderColor;
  63373. /** Gets or sets the button color */
  63374. buttonColor: string;
  63375. private _setbuttonColor;
  63376. /** Gets or sets the label color */
  63377. labelColor: string;
  63378. private _setLabelColor;
  63379. /** Gets or sets the button background */
  63380. buttonBackground: string;
  63381. private _setButtonBackground;
  63382. /** Gets or sets the color of separator bar */
  63383. barColor: string;
  63384. private _setBarColor;
  63385. /** Gets or sets the height of separator bar */
  63386. barHeight: string;
  63387. private _setBarHeight;
  63388. /** Gets or sets the height of spacers*/
  63389. spacerHeight: string;
  63390. private _setSpacerHeight;
  63391. /** Adds a bar between groups */
  63392. private _addSpacer;
  63393. /** Add a group to the selection panel
  63394. * @param group is the selector group to add
  63395. */
  63396. addGroup(group: SelectorGroup): void;
  63397. /** Remove the group from the given position
  63398. * @param groupNb is the position of the group in the list
  63399. */
  63400. removeGroup(groupNb: number): void;
  63401. /** Change a group header label
  63402. * @param label is the new group header label
  63403. * @param groupNb is the number of the group to relabel
  63404. * */
  63405. setHeaderName(label: string, groupNb: number): void;
  63406. /** Change selector label to the one given
  63407. * @param label is the new selector label
  63408. * @param groupNb is the number of the groupcontaining the selector
  63409. * @param selectorNb is the number of the selector within a group to relabel
  63410. * */
  63411. relabel(label: string, groupNb: number, selectorNb: number): void;
  63412. /** For a given group position remove the selector at the given position
  63413. * @param groupNb is the number of the group to remove the selector from
  63414. * @param selectorNb is the number of the selector within the group
  63415. */
  63416. removeFromGroupSelector(groupNb: number, selectorNb: number): void;
  63417. /** For a given group position of correct type add a checkbox button
  63418. * @param groupNb is the number of the group to remove the selector from
  63419. * @param label is the label for the selector
  63420. * @param func is the function called when the Selector is checked
  63421. * @param checked is true when Selector is checked
  63422. */
  63423. addToGroupCheckbox(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63424. /** For a given group position of correct type add a radio button
  63425. * @param groupNb is the number of the group to remove the selector from
  63426. * @param label is the label for the selector
  63427. * @param func is the function called when the Selector is checked
  63428. * @param checked is true when Selector is checked
  63429. */
  63430. addToGroupRadio(groupNb: number, label: string, func?: () => void, checked?: boolean): void;
  63431. /**
  63432. * For a given slider group add a slider
  63433. * @param groupNb is the number of the group to add the slider to
  63434. * @param label is the label for the Slider
  63435. * @param func is the function called when the Slider moves
  63436. * @param unit is a string describing the units used, eg degrees or metres
  63437. * @param min is the minimum value for the Slider
  63438. * @param max is the maximum value for the Slider
  63439. * @param value is the start value for the Slider between min and max
  63440. * @param onVal is the function used to format the value displayed, eg radians to degrees
  63441. */
  63442. addToGroupSlider(groupNb: number, label: string, func?: () => void, unit?: string, min?: number, max?: number, value?: number, onVal?: (v: number) => number): void;
  63443. }
  63444. }
  63445. declare module BABYLON.GUI {
  63446. /**
  63447. * Class used to hold a the container for ScrollViewer
  63448. * @hidden
  63449. */
  63450. export class _ScrollViewerWindow extends Container {
  63451. parentClientWidth: number;
  63452. parentClientHeight: number;
  63453. /**
  63454. * Creates a new ScrollViewerWindow
  63455. * @param name of ScrollViewerWindow
  63456. */
  63457. constructor(name?: string);
  63458. protected _getTypeName(): string;
  63459. /** @hidden */
  63460. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63461. protected _postMeasure(): void;
  63462. }
  63463. }
  63464. declare module BABYLON.GUI {
  63465. /**
  63466. * Class used to create slider controls
  63467. */
  63468. export class ScrollBar extends BaseSlider {
  63469. name?: string | undefined;
  63470. private _background;
  63471. private _borderColor;
  63472. private _thumbMeasure;
  63473. /** Gets or sets border color */
  63474. borderColor: string;
  63475. /** Gets or sets background color */
  63476. background: string;
  63477. /**
  63478. * Creates a new Slider
  63479. * @param name defines the control name
  63480. */
  63481. constructor(name?: string | undefined);
  63482. protected _getTypeName(): string;
  63483. protected _getThumbThickness(): number; private _draw(context: CanvasRenderingContext2D): void;
  63484. private _first;
  63485. private _originX;
  63486. private _originY;
  63487. /** @hidden */
  63488. protected _updateValueFromPointer(x: number, y: number): void; private _onPointerDown(target: Control, coordinates: BABYLON.Vector2, pointerId: number, buttonIndex: number): boolean;
  63489. }
  63490. }
  63491. declare module BABYLON.GUI {
  63492. /**
  63493. * Class used to hold a viewer window and sliders in a grid
  63494. */
  63495. export class ScrollViewer extends Rectangle {
  63496. private _grid;
  63497. private _horizontalBarSpace;
  63498. private _verticalBarSpace;
  63499. private _dragSpace;
  63500. private _horizontalBar;
  63501. private _verticalBar;
  63502. private _barColor;
  63503. private _barBackground;
  63504. private _barSize;
  63505. private _endLeft;
  63506. private _endTop;
  63507. private _window;
  63508. private _pointerIsOver;
  63509. private _wheelPrecision;
  63510. private _onPointerObserver;
  63511. private _clientWidth;
  63512. private _clientHeight;
  63513. /**
  63514. * Gets the horizontal scrollbar
  63515. */
  63516. readonly horizontalBar: ScrollBar;
  63517. /**
  63518. * Gets the vertical scrollbar
  63519. */
  63520. readonly verticalBar: ScrollBar;
  63521. /**
  63522. * Adds a new control to the current container
  63523. * @param control defines the control to add
  63524. * @returns the current container
  63525. */
  63526. addControl(control: BABYLON.Nullable<Control>): Container;
  63527. /**
  63528. * Removes a control from the current container
  63529. * @param control defines the control to remove
  63530. * @returns the current container
  63531. */
  63532. removeControl(control: Control): Container;
  63533. /** Gets the list of children */
  63534. readonly children: Control[]; private _flagDescendantsAsMatrixDirty(): void;
  63535. /**
  63536. * Creates a new ScrollViewer
  63537. * @param name of ScrollViewer
  63538. */
  63539. constructor(name?: string);
  63540. /** Reset the scroll viewer window to initial size */
  63541. resetWindow(): void;
  63542. protected _getTypeName(): string;
  63543. private _buildClientSizes;
  63544. protected _additionalProcessing(parentMeasure: Measure, context: CanvasRenderingContext2D): void;
  63545. protected _postMeasure(): void;
  63546. /**
  63547. * Gets or sets the mouse wheel precision
  63548. * from 0 to 1 with a default value of 0.05
  63549. * */
  63550. wheelPrecision: number;
  63551. /** Gets or sets the bar color */
  63552. barColor: string;
  63553. /** Gets or sets the size of the bar */
  63554. barSize: number;
  63555. /** Gets or sets the bar background */
  63556. barBackground: string;
  63557. /** @hidden */
  63558. private _updateScroller; private _link(host: AdvancedDynamicTexture): void;
  63559. /** @hidden */
  63560. private _attachWheel; private _renderHighlightSpecific(context: CanvasRenderingContext2D): void;
  63561. /** Releases associated resources */
  63562. dispose(): void;
  63563. }
  63564. }
  63565. declare module BABYLON.GUI {
  63566. /** Class used to render a grid */
  63567. export class DisplayGrid extends Control {
  63568. name?: string | undefined;
  63569. private _cellWidth;
  63570. private _cellHeight;
  63571. private _minorLineTickness;
  63572. private _minorLineColor;
  63573. private _majorLineTickness;
  63574. private _majorLineColor;
  63575. private _majorLineFrequency;
  63576. private _background;
  63577. private _displayMajorLines;
  63578. private _displayMinorLines;
  63579. /** Gets or sets a boolean indicating if minor lines must be rendered (true by default)) */
  63580. displayMinorLines: boolean;
  63581. /** Gets or sets a boolean indicating if major lines must be rendered (true by default)) */
  63582. displayMajorLines: boolean;
  63583. /** Gets or sets background color (Black by default) */
  63584. background: string;
  63585. /** Gets or sets the width of each cell (20 by default) */
  63586. cellWidth: number;
  63587. /** Gets or sets the height of each cell (20 by default) */
  63588. cellHeight: number;
  63589. /** Gets or sets the tickness of minor lines (1 by default) */
  63590. minorLineTickness: number;
  63591. /** Gets or sets the color of minor lines (DarkGray by default) */
  63592. minorLineColor: string;
  63593. /** Gets or sets the tickness of major lines (2 by default) */
  63594. majorLineTickness: number;
  63595. /** Gets or sets the color of major lines (White by default) */
  63596. majorLineColor: string;
  63597. /** Gets or sets the frequency of major lines (default is 1 every 5 minor lines)*/
  63598. majorLineFrequency: number;
  63599. /**
  63600. * Creates a new GridDisplayRectangle
  63601. * @param name defines the control name
  63602. */
  63603. constructor(name?: string | undefined); private _draw(context: CanvasRenderingContext2D): void;
  63604. protected _getTypeName(): string;
  63605. }
  63606. }
  63607. declare module BABYLON.GUI {
  63608. /**
  63609. * Class used to create slider controls based on images
  63610. */
  63611. export class ImageBasedSlider extends BaseSlider {
  63612. name?: string | undefined;
  63613. private _backgroundImage;
  63614. private _thumbImage;
  63615. private _valueBarImage;
  63616. private _tempMeasure;
  63617. displayThumb: boolean;
  63618. /**
  63619. * Gets or sets the image used to render the background
  63620. */
  63621. backgroundImage: Image;
  63622. /**
  63623. * Gets or sets the image used to render the value bar
  63624. */
  63625. valueBarImage: Image;
  63626. /**
  63627. * Gets or sets the image used to render the thumb
  63628. */
  63629. thumbImage: Image;
  63630. /**
  63631. * Creates a new ImageBasedSlider
  63632. * @param name defines the control name
  63633. */
  63634. constructor(name?: string | undefined);
  63635. protected _getTypeName(): string; private _draw(context: CanvasRenderingContext2D): void;
  63636. }
  63637. }
  63638. declare module BABYLON.GUI {
  63639. /**
  63640. * Forcing an export so that this code will execute
  63641. * @hidden
  63642. */
  63643. const name = "Statics";
  63644. }
  63645. declare module BABYLON.GUI {
  63646. /**
  63647. * This class can be used to get instrumentation data from a AdvancedDynamicTexture object
  63648. */
  63649. export class AdvancedDynamicTextureInstrumentation implements BABYLON.IDisposable {
  63650. /**
  63651. * Define the instrumented AdvancedDynamicTexture.
  63652. */
  63653. texture: AdvancedDynamicTexture;
  63654. private _captureRenderTime;
  63655. private _renderTime;
  63656. private _captureLayoutTime;
  63657. private _layoutTime;
  63658. private _onBeginRenderObserver;
  63659. private _onEndRenderObserver;
  63660. private _onBeginLayoutObserver;
  63661. private _onEndLayoutObserver;
  63662. /**
  63663. * Gets the perf counter used to capture render time
  63664. */
  63665. readonly renderTimeCounter: BABYLON.PerfCounter;
  63666. /**
  63667. * Gets the perf counter used to capture layout time
  63668. */
  63669. readonly layoutTimeCounter: BABYLON.PerfCounter;
  63670. /**
  63671. * Enable or disable the render time capture
  63672. */
  63673. captureRenderTime: boolean;
  63674. /**
  63675. * Enable or disable the layout time capture
  63676. */
  63677. captureLayoutTime: boolean;
  63678. /**
  63679. * Instantiates a new advanced dynamic texture instrumentation.
  63680. * This class can be used to get instrumentation data from an AdvancedDynamicTexture object
  63681. * @param texture Defines the AdvancedDynamicTexture to instrument
  63682. */
  63683. constructor(
  63684. /**
  63685. * Define the instrumented AdvancedDynamicTexture.
  63686. */
  63687. texture: AdvancedDynamicTexture);
  63688. /**
  63689. * Dispose and release associated resources.
  63690. */
  63691. dispose(): void;
  63692. }
  63693. }
  63694. declare module BABYLON.GUI {
  63695. /**
  63696. * Class used to create containers for controls
  63697. */
  63698. export class Container3D extends Control3D {
  63699. private _blockLayout;
  63700. /**
  63701. * Gets the list of child controls
  63702. */
  63703. protected _children: Control3D[];
  63704. /**
  63705. * Gets the list of child controls
  63706. */
  63707. readonly children: Array<Control3D>;
  63708. /**
  63709. * Gets or sets a boolean indicating if the layout must be blocked (default is false).
  63710. * This is helpful to optimize layout operation when adding multiple children in a row
  63711. */
  63712. blockLayout: boolean;
  63713. /**
  63714. * Creates a new container
  63715. * @param name defines the container name
  63716. */
  63717. constructor(name?: string);
  63718. /**
  63719. * Force the container to update the layout. Please note that it will not take blockLayout property in account
  63720. * @returns the current container
  63721. */
  63722. updateLayout(): Container3D;
  63723. /**
  63724. * Gets a boolean indicating if the given control is in the children of this control
  63725. * @param control defines the control to check
  63726. * @returns true if the control is in the child list
  63727. */
  63728. containsControl(control: Control3D): boolean;
  63729. /**
  63730. * Adds a control to the children of this control
  63731. * @param control defines the control to add
  63732. * @returns the current container
  63733. */
  63734. addControl(control: Control3D): Container3D;
  63735. /**
  63736. * This function will be called everytime a new control is added
  63737. */
  63738. protected _arrangeChildren(): void;
  63739. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63740. /**
  63741. * Removes a control from the children of this control
  63742. * @param control defines the control to remove
  63743. * @returns the current container
  63744. */
  63745. removeControl(control: Control3D): Container3D;
  63746. protected _getTypeName(): string;
  63747. /**
  63748. * Releases all associated resources
  63749. */
  63750. dispose(): void;
  63751. /** Control rotation will remain unchanged */
  63752. static readonly UNSET_ORIENTATION: number;
  63753. /** Control will rotate to make it look at sphere central axis */
  63754. static readonly FACEORIGIN_ORIENTATION: number;
  63755. /** Control will rotate to make it look back at sphere central axis */
  63756. static readonly FACEORIGINREVERSED_ORIENTATION: number;
  63757. /** Control will rotate to look at z axis (0, 0, 1) */
  63758. static readonly FACEFORWARD_ORIENTATION: number;
  63759. /** Control will rotate to look at negative z axis (0, 0, -1) */
  63760. static readonly FACEFORWARDREVERSED_ORIENTATION: number;
  63761. }
  63762. }
  63763. declare module BABYLON.GUI {
  63764. /**
  63765. * Class used to manage 3D user interface
  63766. * @see http://doc.babylonjs.com/how_to/gui3d
  63767. */
  63768. export class GUI3DManager implements BABYLON.IDisposable {
  63769. private _scene;
  63770. private _sceneDisposeObserver;
  63771. private _utilityLayer;
  63772. private _rootContainer;
  63773. private _pointerObserver;
  63774. private _pointerOutObserver;
  63775. /** @hidden */ private _lastPickedControl: Control3D;
  63776. /** @hidden */ private _lastControlOver: {
  63777. [pointerId: number]: Control3D;
  63778. };
  63779. /** @hidden */ private _lastControlDown: {
  63780. [pointerId: number]: Control3D;
  63781. };
  63782. /**
  63783. * BABYLON.Observable raised when the point picked by the pointer events changed
  63784. */
  63785. onPickedPointChangedObservable: BABYLON.Observable<BABYLON.Nullable<BABYLON.Vector3>>;
  63786. /** @hidden */ private _sharedMaterials: {
  63787. [key: string]: BABYLON.Material;
  63788. };
  63789. /** Gets the hosting scene */
  63790. readonly scene: BABYLON.Scene;
  63791. /** Gets associated utility layer */
  63792. readonly utilityLayer: BABYLON.Nullable<BABYLON.UtilityLayerRenderer>;
  63793. /**
  63794. * Creates a new GUI3DManager
  63795. * @param scene
  63796. */
  63797. constructor(scene?: BABYLON.Scene);
  63798. private _handlePointerOut;
  63799. private _doPicking;
  63800. /**
  63801. * Gets the root container
  63802. */
  63803. readonly rootContainer: Container3D;
  63804. /**
  63805. * Gets a boolean indicating if the given control is in the root child list
  63806. * @param control defines the control to check
  63807. * @returns true if the control is in the root child list
  63808. */
  63809. containsControl(control: Control3D): boolean;
  63810. /**
  63811. * Adds a control to the root child list
  63812. * @param control defines the control to add
  63813. * @returns the current manager
  63814. */
  63815. addControl(control: Control3D): GUI3DManager;
  63816. /**
  63817. * Removes a control from the root child list
  63818. * @param control defines the control to remove
  63819. * @returns the current container
  63820. */
  63821. removeControl(control: Control3D): GUI3DManager;
  63822. /**
  63823. * Releases all associated resources
  63824. */
  63825. dispose(): void;
  63826. }
  63827. }
  63828. declare module BABYLON.GUI {
  63829. /**
  63830. * Class used to transport BABYLON.Vector3 information for pointer events
  63831. */
  63832. export class Vector3WithInfo extends BABYLON.Vector3 {
  63833. /** defines the current mouse button index */
  63834. buttonIndex: number;
  63835. /**
  63836. * Creates a new Vector3WithInfo
  63837. * @param source defines the vector3 data to transport
  63838. * @param buttonIndex defines the current mouse button index
  63839. */
  63840. constructor(source: BABYLON.Vector3,
  63841. /** defines the current mouse button index */
  63842. buttonIndex?: number);
  63843. }
  63844. }
  63845. declare module BABYLON.GUI {
  63846. /**
  63847. * Class used as base class for controls
  63848. */
  63849. export class Control3D implements BABYLON.IDisposable, BABYLON.IBehaviorAware<Control3D> {
  63850. /** Defines the control name */
  63851. name?: string | undefined;
  63852. /** @hidden */ private _host: GUI3DManager;
  63853. private _node;
  63854. private _downCount;
  63855. private _enterCount;
  63856. private _downPointerIds;
  63857. private _isVisible;
  63858. /** Gets or sets the control position in world space */
  63859. position: BABYLON.Vector3;
  63860. /** Gets or sets the control scaling in world space */
  63861. scaling: BABYLON.Vector3;
  63862. /** Callback used to start pointer enter animation */
  63863. pointerEnterAnimation: () => void;
  63864. /** Callback used to start pointer out animation */
  63865. pointerOutAnimation: () => void;
  63866. /** Callback used to start pointer down animation */
  63867. pointerDownAnimation: () => void;
  63868. /** Callback used to start pointer up animation */
  63869. pointerUpAnimation: () => void;
  63870. /**
  63871. * An event triggered when the pointer move over the control
  63872. */
  63873. onPointerMoveObservable: BABYLON.Observable<BABYLON.Vector3>;
  63874. /**
  63875. * An event triggered when the pointer move out of the control
  63876. */
  63877. onPointerOutObservable: BABYLON.Observable<Control3D>;
  63878. /**
  63879. * An event triggered when the pointer taps the control
  63880. */
  63881. onPointerDownObservable: BABYLON.Observable<Vector3WithInfo>;
  63882. /**
  63883. * An event triggered when pointer is up
  63884. */
  63885. onPointerUpObservable: BABYLON.Observable<Vector3WithInfo>;
  63886. /**
  63887. * An event triggered when a control is clicked on (with a mouse)
  63888. */
  63889. onPointerClickObservable: BABYLON.Observable<Vector3WithInfo>;
  63890. /**
  63891. * An event triggered when pointer enters the control
  63892. */
  63893. onPointerEnterObservable: BABYLON.Observable<Control3D>;
  63894. /**
  63895. * Gets or sets the parent container
  63896. */
  63897. parent: BABYLON.Nullable<Container3D>;
  63898. private _behaviors;
  63899. /**
  63900. * Gets the list of attached behaviors
  63901. * @see http://doc.babylonjs.com/features/behaviour
  63902. */
  63903. readonly behaviors: BABYLON.Behavior<Control3D>[];
  63904. /**
  63905. * Attach a behavior to the control
  63906. * @see http://doc.babylonjs.com/features/behaviour
  63907. * @param behavior defines the behavior to attach
  63908. * @returns the current control
  63909. */
  63910. addBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63911. /**
  63912. * Remove an attached behavior
  63913. * @see http://doc.babylonjs.com/features/behaviour
  63914. * @param behavior defines the behavior to attach
  63915. * @returns the current control
  63916. */
  63917. removeBehavior(behavior: BABYLON.Behavior<Control3D>): Control3D;
  63918. /**
  63919. * Gets an attached behavior by name
  63920. * @param name defines the name of the behavior to look for
  63921. * @see http://doc.babylonjs.com/features/behaviour
  63922. * @returns null if behavior was not found else the requested behavior
  63923. */
  63924. getBehaviorByName(name: string): BABYLON.Nullable<BABYLON.Behavior<Control3D>>;
  63925. /** Gets or sets a boolean indicating if the control is visible */
  63926. isVisible: boolean;
  63927. /**
  63928. * Creates a new control
  63929. * @param name defines the control name
  63930. */
  63931. constructor(
  63932. /** Defines the control name */
  63933. name?: string | undefined);
  63934. /**
  63935. * Gets a string representing the class name
  63936. */
  63937. readonly typeName: string;
  63938. /**
  63939. * Get the current class name of the control.
  63940. * @returns current class name
  63941. */
  63942. getClassName(): string;
  63943. protected _getTypeName(): string;
  63944. /**
  63945. * Gets the transform node used by this control
  63946. */
  63947. readonly node: BABYLON.Nullable<BABYLON.TransformNode>;
  63948. /**
  63949. * Gets the mesh used to render this control
  63950. */
  63951. readonly mesh: BABYLON.Nullable<BABYLON.AbstractMesh>;
  63952. /**
  63953. * Link the control as child of the given node
  63954. * @param node defines the node to link to. Use null to unlink the control
  63955. * @returns the current control
  63956. */
  63957. linkToTransformNode(node: BABYLON.Nullable<BABYLON.TransformNode>): Control3D;
  63958. /** @hidden **/ private _prepareNode(scene: BABYLON.Scene): void;
  63959. /**
  63960. * Node creation.
  63961. * Can be overriden by children
  63962. * @param scene defines the scene where the node must be attached
  63963. * @returns the attached node or null if none. Must return a BABYLON.Mesh or BABYLON.AbstractMesh if there is an atttached visible object
  63964. */
  63965. protected _createNode(scene: BABYLON.Scene): BABYLON.Nullable<BABYLON.TransformNode>;
  63966. /**
  63967. * Affect a material to the given mesh
  63968. * @param mesh defines the mesh which will represent the control
  63969. */
  63970. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  63971. /** @hidden */ private _onPointerMove(target: Control3D, coordinates: BABYLON.Vector3): void;
  63972. /** @hidden */ private _onPointerEnter(target: Control3D): boolean;
  63973. /** @hidden */ private _onPointerOut(target: Control3D): void;
  63974. /** @hidden */ private _onPointerDown(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63975. /** @hidden */ private _onPointerUp(target: Control3D, coordinates: BABYLON.Vector3, pointerId: number, buttonIndex: number, notifyClick: boolean): void;
  63976. /** @hidden */
  63977. forcePointerUp(pointerId?: BABYLON.Nullable<number>): void;
  63978. /** @hidden */ private _processObservables(type: number, pickedPoint: BABYLON.Vector3, pointerId: number, buttonIndex: number): boolean;
  63979. /** @hidden */ private _disposeNode(): void;
  63980. /**
  63981. * Releases all associated resources
  63982. */
  63983. dispose(): void;
  63984. }
  63985. }
  63986. declare module BABYLON.GUI {
  63987. /**
  63988. * Class used as a root to all buttons
  63989. */
  63990. export class AbstractButton3D extends Control3D {
  63991. /**
  63992. * Creates a new button
  63993. * @param name defines the control name
  63994. */
  63995. constructor(name?: string);
  63996. protected _getTypeName(): string;
  63997. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  63998. }
  63999. }
  64000. declare module BABYLON.GUI {
  64001. /**
  64002. * Class used to create a button in 3D
  64003. */
  64004. export class Button3D extends AbstractButton3D {
  64005. /** @hidden */
  64006. protected _currentMaterial: BABYLON.Material;
  64007. private _facadeTexture;
  64008. private _content;
  64009. private _contentResolution;
  64010. private _contentScaleRatio;
  64011. /**
  64012. * Gets or sets the texture resolution used to render content (512 by default)
  64013. */
  64014. contentResolution: BABYLON.int;
  64015. /**
  64016. * Gets or sets the texture scale ratio used to render content (2 by default)
  64017. */
  64018. contentScaleRatio: number;
  64019. protected _disposeFacadeTexture(): void;
  64020. protected _resetContent(): void;
  64021. /**
  64022. * Creates a new button
  64023. * @param name defines the control name
  64024. */
  64025. constructor(name?: string);
  64026. /**
  64027. * Gets or sets the GUI 2D content used to display the button's facade
  64028. */
  64029. content: Control;
  64030. /**
  64031. * Apply the facade texture (created from the content property).
  64032. * This function can be overloaded by child classes
  64033. * @param facadeTexture defines the AdvancedDynamicTexture to use
  64034. */
  64035. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64036. protected _getTypeName(): string;
  64037. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64038. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64039. /**
  64040. * Releases all associated resources
  64041. */
  64042. dispose(): void;
  64043. }
  64044. }
  64045. declare module BABYLON.GUI {
  64046. /**
  64047. * Abstract class used to create a container panel deployed on the surface of a volume
  64048. */
  64049. export abstract class VolumeBasedPanel extends Container3D {
  64050. private _columns;
  64051. private _rows;
  64052. private _rowThenColum;
  64053. private _orientation;
  64054. protected _cellWidth: number;
  64055. protected _cellHeight: number;
  64056. /**
  64057. * Gets or sets the distance between elements
  64058. */
  64059. margin: number;
  64060. /**
  64061. * Gets or sets the orientation to apply to all controls (BABYLON.Container3D.FaceOriginReversedOrientation by default)
  64062. * | Value | Type | Description |
  64063. * | ----- | ----------------------------------- | ----------- |
  64064. * | 0 | UNSET_ORIENTATION | Control rotation will remain unchanged |
  64065. * | 1 | FACEORIGIN_ORIENTATION | Control will rotate to make it look at sphere central axis |
  64066. * | 2 | FACEORIGINREVERSED_ORIENTATION | Control will rotate to make it look back at sphere central axis |
  64067. * | 3 | FACEFORWARD_ORIENTATION | Control will rotate to look at z axis (0, 0, 1) |
  64068. * | 4 | FACEFORWARDREVERSED_ORIENTATION | Control will rotate to look at negative z axis (0, 0, -1) |
  64069. */
  64070. orientation: number;
  64071. /**
  64072. * Gets or sets the number of columns requested (10 by default).
  64073. * The panel will automatically compute the number of rows based on number of child controls.
  64074. */
  64075. columns: BABYLON.int;
  64076. /**
  64077. * Gets or sets a the number of rows requested.
  64078. * The panel will automatically compute the number of columns based on number of child controls.
  64079. */
  64080. rows: BABYLON.int;
  64081. /**
  64082. * Creates new VolumeBasedPanel
  64083. */
  64084. constructor();
  64085. protected _arrangeChildren(): void;
  64086. /** Child classes must implement this function to provide correct control positioning */
  64087. protected abstract _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64088. /** Child classes can implement this function to provide additional processing */
  64089. protected _finalProcessing(): void;
  64090. }
  64091. }
  64092. declare module BABYLON.GUI {
  64093. /**
  64094. * Class used to create a container panel deployed on the surface of a cylinder
  64095. */
  64096. export class CylinderPanel extends VolumeBasedPanel {
  64097. private _radius;
  64098. /**
  64099. * Gets or sets the radius of the cylinder where to project controls (5 by default)
  64100. */
  64101. radius: BABYLON.float;
  64102. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64103. private _cylindricalMapping;
  64104. }
  64105. }
  64106. declare module BABYLON.GUI {
  64107. /** @hidden */
  64108. export var fluentVertexShader: {
  64109. name: string;
  64110. shader: string;
  64111. };
  64112. }
  64113. declare module BABYLON.GUI {
  64114. /** @hidden */
  64115. export var fluentPixelShader: {
  64116. name: string;
  64117. shader: string;
  64118. };
  64119. }
  64120. declare module BABYLON.GUI {
  64121. /** @hidden */
  64122. export class FluentMaterialDefines extends BABYLON.MaterialDefines {
  64123. INNERGLOW: boolean;
  64124. BORDER: boolean;
  64125. HOVERLIGHT: boolean;
  64126. TEXTURE: boolean;
  64127. constructor();
  64128. }
  64129. /**
  64130. * Class used to render controls with fluent desgin
  64131. */
  64132. export class FluentMaterial extends BABYLON.PushMaterial {
  64133. /**
  64134. * Gets or sets inner glow intensity. A value of 0 means no glow (default is 0.5)
  64135. */
  64136. innerGlowColorIntensity: number;
  64137. /**
  64138. * Gets or sets the inner glow color (white by default)
  64139. */
  64140. innerGlowColor: BABYLON.Color3;
  64141. /**
  64142. * Gets or sets alpha value (default is 1.0)
  64143. */
  64144. alpha: number;
  64145. /**
  64146. * Gets or sets the albedo color (Default is BABYLON.Color3(0.3, 0.35, 0.4))
  64147. */
  64148. albedoColor: BABYLON.Color3;
  64149. /**
  64150. * Gets or sets a boolean indicating if borders must be rendered (default is false)
  64151. */
  64152. renderBorders: boolean;
  64153. /**
  64154. * Gets or sets border width (default is 0.5)
  64155. */
  64156. borderWidth: number;
  64157. /**
  64158. * Gets or sets a value indicating the smoothing value applied to border edges (0.02 by default)
  64159. */
  64160. edgeSmoothingValue: number;
  64161. /**
  64162. * Gets or sets the minimum value that can be applied to border width (default is 0.1)
  64163. */
  64164. borderMinValue: number;
  64165. /**
  64166. * Gets or sets a boolean indicating if hover light must be rendered (default is false)
  64167. */
  64168. renderHoverLight: boolean;
  64169. /**
  64170. * Gets or sets the radius used to render the hover light (default is 1.0)
  64171. */
  64172. hoverRadius: number;
  64173. /**
  64174. * Gets or sets the color used to render the hover light (default is BABYLON.Color4(0.3, 0.3, 0.3, 1.0))
  64175. */
  64176. hoverColor: BABYLON.Color4;
  64177. /**
  64178. * Gets or sets the hover light position in world space (default is BABYLON.Vector3.Zero())
  64179. */
  64180. hoverPosition: BABYLON.Vector3;
  64181. private _albedoTexture;
  64182. /** Gets or sets the texture to use for albedo color */
  64183. albedoTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  64184. /**
  64185. * Creates a new Fluent material
  64186. * @param name defines the name of the material
  64187. * @param scene defines the hosting scene
  64188. */
  64189. constructor(name: string, scene: BABYLON.Scene);
  64190. needAlphaBlending(): boolean;
  64191. needAlphaTesting(): boolean;
  64192. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  64193. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  64194. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  64195. getActiveTextures(): BABYLON.BaseTexture[];
  64196. hasTexture(texture: BABYLON.BaseTexture): boolean;
  64197. dispose(forceDisposeEffect?: boolean): void;
  64198. clone(name: string): FluentMaterial;
  64199. serialize(): any;
  64200. getClassName(): string;
  64201. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FluentMaterial;
  64202. }
  64203. }
  64204. declare module BABYLON.GUI {
  64205. /**
  64206. * Class used to create a holographic button in 3D
  64207. */
  64208. export class HolographicButton extends Button3D {
  64209. private _backPlate;
  64210. private _textPlate;
  64211. private _frontPlate;
  64212. private _text;
  64213. private _imageUrl;
  64214. private _shareMaterials;
  64215. private _frontMaterial;
  64216. private _backMaterial;
  64217. private _plateMaterial;
  64218. private _pickedPointObserver;
  64219. private _tooltipFade;
  64220. private _tooltipTextBlock;
  64221. private _tooltipTexture;
  64222. private _tooltipMesh;
  64223. private _tooltipHoverObserver;
  64224. private _tooltipOutObserver;
  64225. private _disposeTooltip;
  64226. /**
  64227. * Text to be displayed on the tooltip shown when hovering on the button. When set to null tooltip is disabled. (Default: null)
  64228. */
  64229. tooltipText: BABYLON.Nullable<string>;
  64230. /**
  64231. * Gets or sets text for the button
  64232. */
  64233. text: string;
  64234. /**
  64235. * Gets or sets the image url for the button
  64236. */
  64237. imageUrl: string;
  64238. /**
  64239. * Gets the back material used by this button
  64240. */
  64241. readonly backMaterial: FluentMaterial;
  64242. /**
  64243. * Gets the front material used by this button
  64244. */
  64245. readonly frontMaterial: FluentMaterial;
  64246. /**
  64247. * Gets the plate material used by this button
  64248. */
  64249. readonly plateMaterial: BABYLON.StandardMaterial;
  64250. /**
  64251. * Gets a boolean indicating if this button shares its material with other HolographicButtons
  64252. */
  64253. readonly shareMaterials: boolean;
  64254. /**
  64255. * Creates a new button
  64256. * @param name defines the control name
  64257. */
  64258. constructor(name?: string, shareMaterials?: boolean);
  64259. protected _getTypeName(): string;
  64260. private _rebuildContent;
  64261. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64262. protected _applyFacade(facadeTexture: AdvancedDynamicTexture): void;
  64263. private _createBackMaterial;
  64264. private _createFrontMaterial;
  64265. private _createPlateMaterial;
  64266. protected _affectMaterial(mesh: BABYLON.Mesh): void;
  64267. /**
  64268. * Releases all associated resources
  64269. */
  64270. dispose(): void;
  64271. }
  64272. }
  64273. declare module BABYLON.GUI {
  64274. /**
  64275. * Class used to create an interactable object. It's a 3D button using a mesh coming from the current scene
  64276. */
  64277. export class MeshButton3D extends Button3D {
  64278. /** @hidden */
  64279. protected _currentMesh: BABYLON.Mesh;
  64280. /**
  64281. * Creates a new 3D button based on a mesh
  64282. * @param mesh mesh to become a 3D button
  64283. * @param name defines the control name
  64284. */
  64285. constructor(mesh: BABYLON.Mesh, name?: string);
  64286. protected _getTypeName(): string;
  64287. protected _createNode(scene: BABYLON.Scene): BABYLON.TransformNode;
  64288. protected _affectMaterial(mesh: BABYLON.AbstractMesh): void;
  64289. }
  64290. }
  64291. declare module BABYLON.GUI {
  64292. /**
  64293. * Class used to create a container panel deployed on the surface of a plane
  64294. */
  64295. export class PlanePanel extends VolumeBasedPanel {
  64296. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64297. }
  64298. }
  64299. declare module BABYLON.GUI {
  64300. /**
  64301. * Class used to create a container panel where items get randomized planar mapping
  64302. */
  64303. export class ScatterPanel extends VolumeBasedPanel {
  64304. private _iteration;
  64305. /**
  64306. * Gets or sets the number of iteration to use to scatter the controls (100 by default)
  64307. */
  64308. iteration: BABYLON.float;
  64309. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64310. private _scatterMapping;
  64311. protected _finalProcessing(): void;
  64312. }
  64313. }
  64314. declare module BABYLON.GUI {
  64315. /**
  64316. * Class used to create a container panel deployed on the surface of a sphere
  64317. */
  64318. export class SpherePanel extends VolumeBasedPanel {
  64319. private _radius;
  64320. /**
  64321. * Gets or sets the radius of the sphere where to project controls (5 by default)
  64322. */
  64323. radius: BABYLON.float;
  64324. protected _mapGridNode(control: Control3D, nodePosition: BABYLON.Vector3): void;
  64325. private _sphericalMapping;
  64326. }
  64327. }
  64328. declare module BABYLON.GUI {
  64329. /**
  64330. * Class used to create a stack panel in 3D on XY plane
  64331. */
  64332. export class StackPanel3D extends Container3D {
  64333. private _isVertical;
  64334. /**
  64335. * Gets or sets a boolean indicating if the stack panel is vertical or horizontal (horizontal by default)
  64336. */
  64337. isVertical: boolean;
  64338. /**
  64339. * Gets or sets the distance between elements
  64340. */
  64341. margin: number;
  64342. /**
  64343. * Creates new StackPanel
  64344. * @param isVertical
  64345. */
  64346. constructor(isVertical?: boolean);
  64347. protected _arrangeChildren(): void;
  64348. }
  64349. }
  64350. declare module BABYLON {
  64351. /**
  64352. * Mode that determines the coordinate system to use.
  64353. */
  64354. export enum GLTFLoaderCoordinateSystemMode {
  64355. /**
  64356. * Automatically convert the glTF right-handed data to the appropriate system based on the current coordinate system mode of the scene.
  64357. */
  64358. AUTO = 0,
  64359. /**
  64360. * Sets the useRightHandedSystem flag on the scene.
  64361. */
  64362. FORCE_RIGHT_HANDED = 1
  64363. }
  64364. /**
  64365. * Mode that determines what animations will start.
  64366. */
  64367. export enum GLTFLoaderAnimationStartMode {
  64368. /**
  64369. * No animation will start.
  64370. */
  64371. NONE = 0,
  64372. /**
  64373. * The first animation will start.
  64374. */
  64375. FIRST = 1,
  64376. /**
  64377. * All animations will start.
  64378. */
  64379. ALL = 2
  64380. }
  64381. /**
  64382. * Interface that contains the data for the glTF asset.
  64383. */
  64384. export interface IGLTFLoaderData {
  64385. /**
  64386. * Object that represents the glTF JSON.
  64387. */
  64388. json: Object;
  64389. /**
  64390. * The BIN chunk of a binary glTF.
  64391. */
  64392. bin: Nullable<ArrayBufferView>;
  64393. }
  64394. /**
  64395. * Interface for extending the loader.
  64396. */
  64397. export interface IGLTFLoaderExtension {
  64398. /**
  64399. * The name of this extension.
  64400. */
  64401. readonly name: string;
  64402. /**
  64403. * Defines whether this extension is enabled.
  64404. */
  64405. enabled: boolean;
  64406. }
  64407. /**
  64408. * Loader state.
  64409. */
  64410. export enum GLTFLoaderState {
  64411. /**
  64412. * The asset is loading.
  64413. */
  64414. LOADING = 0,
  64415. /**
  64416. * The asset is ready for rendering.
  64417. */
  64418. READY = 1,
  64419. /**
  64420. * The asset is completely loaded.
  64421. */
  64422. COMPLETE = 2
  64423. }
  64424. /** @hidden */
  64425. export interface IGLTFLoader extends IDisposable {
  64426. readonly state: Nullable<GLTFLoaderState>;
  64427. importMeshAsync: (meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<{
  64428. meshes: AbstractMesh[];
  64429. particleSystems: IParticleSystem[];
  64430. skeletons: Skeleton[];
  64431. animationGroups: AnimationGroup[];
  64432. }>;
  64433. loadAsync: (scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string) => Promise<void>;
  64434. }
  64435. /**
  64436. * File loader for loading glTF files into a scene.
  64437. */
  64438. export class GLTFFileLoader implements IDisposable, ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  64439. /** @hidden */ private static _CreateGLTF1Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64440. /** @hidden */ private static _CreateGLTF2Loader: (parent: GLTFFileLoader) => IGLTFLoader;
  64441. /**
  64442. * Raised when the asset has been parsed
  64443. */
  64444. onParsedObservable: Observable<IGLTFLoaderData>;
  64445. private _onParsedObserver;
  64446. /**
  64447. * Raised when the asset has been parsed
  64448. */
  64449. onParsed: (loaderData: IGLTFLoaderData) => void;
  64450. /**
  64451. * 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.
  64452. * Textures always loads asynchronously. For example, the success callback can compute the bounding information of the loaded meshes when incremental loading is disabled.
  64453. * Defaults to true.
  64454. * @hidden
  64455. */
  64456. static IncrementalLoading: boolean;
  64457. /**
  64458. * Set this property to true in order to work with homogeneous coordinates, available with some converters and exporters.
  64459. * Defaults to false. See https://en.wikipedia.org/wiki/Homogeneous_coordinates.
  64460. * @hidden
  64461. */
  64462. static HomogeneousCoordinates: boolean;
  64463. /**
  64464. * The coordinate system mode. Defaults to AUTO.
  64465. */
  64466. coordinateSystemMode: GLTFLoaderCoordinateSystemMode;
  64467. /**
  64468. * The animation start mode. Defaults to FIRST.
  64469. */
  64470. animationStartMode: GLTFLoaderAnimationStartMode;
  64471. /**
  64472. * Defines if the loader should compile materials before raising the success callback. Defaults to false.
  64473. */
  64474. compileMaterials: boolean;
  64475. /**
  64476. * Defines if the loader should also compile materials with clip planes. Defaults to false.
  64477. */
  64478. useClipPlane: boolean;
  64479. /**
  64480. * Defines if the loader should compile shadow generators before raising the success callback. Defaults to false.
  64481. */
  64482. compileShadowGenerators: boolean;
  64483. /**
  64484. * Defines if the Alpha blended materials are only applied as coverage.
  64485. * If false, (default) The luminance of each pixel will reduce its opacity to simulate the behaviour of most physical materials.
  64486. * If true, no extra effects are applied to transparent pixels.
  64487. */
  64488. transparencyAsCoverage: boolean;
  64489. /**
  64490. * Function called before loading a url referenced by the asset.
  64491. */
  64492. preprocessUrlAsync: (url: string) => Promise<string>;
  64493. /**
  64494. * Observable raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64495. */
  64496. readonly onMeshLoadedObservable: Observable<AbstractMesh>;
  64497. private _onMeshLoadedObserver;
  64498. /**
  64499. * Callback raised when the loader creates a mesh after parsing the glTF properties of the mesh.
  64500. */
  64501. onMeshLoaded: (mesh: AbstractMesh) => void;
  64502. /**
  64503. * Observable raised when the loader creates a texture after parsing the glTF properties of the texture.
  64504. */
  64505. readonly onTextureLoadedObservable: Observable<BaseTexture>;
  64506. private _onTextureLoadedObserver;
  64507. /**
  64508. * Callback raised when the loader creates a texture after parsing the glTF properties of the texture.
  64509. */
  64510. onTextureLoaded: (texture: BaseTexture) => void;
  64511. /**
  64512. * Observable raised when the loader creates a material after parsing the glTF properties of the material.
  64513. */
  64514. readonly onMaterialLoadedObservable: Observable<Material>;
  64515. private _onMaterialLoadedObserver;
  64516. /**
  64517. * Callback raised when the loader creates a material after parsing the glTF properties of the material.
  64518. */
  64519. onMaterialLoaded: (material: Material) => void;
  64520. /**
  64521. * Observable raised when the loader creates a camera after parsing the glTF properties of the camera.
  64522. */
  64523. readonly onCameraLoadedObservable: Observable<Camera>;
  64524. private _onCameraLoadedObserver;
  64525. /**
  64526. * Callback raised when the loader creates a camera after parsing the glTF properties of the camera.
  64527. */
  64528. onCameraLoaded: (camera: Camera) => void;
  64529. /**
  64530. * Observable raised when the asset is completely loaded, immediately before the loader is disposed.
  64531. * For assets with LODs, raised when all of the LODs are complete.
  64532. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64533. */
  64534. readonly onCompleteObservable: Observable<void>;
  64535. private _onCompleteObserver;
  64536. /**
  64537. * Callback raised when the asset is completely loaded, immediately before the loader is disposed.
  64538. * For assets with LODs, raised when all of the LODs are complete.
  64539. * For assets without LODs, raised when the model is complete, immediately after the loader resolves the returned promise.
  64540. */
  64541. onComplete: () => void;
  64542. /**
  64543. * Observable raised when an error occurs.
  64544. */
  64545. readonly onErrorObservable: Observable<any>;
  64546. private _onErrorObserver;
  64547. /**
  64548. * Callback raised when an error occurs.
  64549. */
  64550. onError: (reason: any) => void;
  64551. /**
  64552. * Observable raised after the loader is disposed.
  64553. */
  64554. readonly onDisposeObservable: Observable<void>;
  64555. private _onDisposeObserver;
  64556. /**
  64557. * Callback raised after the loader is disposed.
  64558. */
  64559. onDispose: () => void;
  64560. /**
  64561. * Observable raised after a loader extension is created.
  64562. * Set additional options for a loader extension in this event.
  64563. */
  64564. readonly onExtensionLoadedObservable: Observable<IGLTFLoaderExtension>;
  64565. private _onExtensionLoadedObserver;
  64566. /**
  64567. * Callback raised after a loader extension is created.
  64568. */
  64569. onExtensionLoaded: (extension: IGLTFLoaderExtension) => void;
  64570. /**
  64571. * Defines if the loader logging is enabled.
  64572. */
  64573. loggingEnabled: boolean;
  64574. /**
  64575. * Defines if the loader should capture performance counters.
  64576. */
  64577. capturePerformanceCounters: boolean;
  64578. /**
  64579. * Defines if the loader should validate the asset.
  64580. */
  64581. validate: boolean;
  64582. /**
  64583. * Observable raised after validation when validate is set to true. The event data is the result of the validation.
  64584. */
  64585. readonly onValidatedObservable: Observable<BABYLON.GLTF2.IGLTFValidationResults>;
  64586. private _onValidatedObserver;
  64587. /**
  64588. * Callback raised after a loader extension is created.
  64589. */
  64590. onValidated: (results: BABYLON.GLTF2.IGLTFValidationResults) => void;
  64591. private _loader;
  64592. /**
  64593. * Name of the loader ("gltf")
  64594. */
  64595. name: string;
  64596. /**
  64597. * Supported file extensions of the loader (.gltf, .glb)
  64598. */
  64599. extensions: ISceneLoaderPluginExtensions;
  64600. /**
  64601. * Disposes the loader, releases resources during load, and cancels any outstanding requests.
  64602. */
  64603. dispose(): void;
  64604. /** @hidden */ private _clear(): void;
  64605. /**
  64606. * Imports one or more meshes from the loaded glTF data and adds them to the scene
  64607. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  64608. * @param scene the scene the meshes should be added to
  64609. * @param data the glTF data to load
  64610. * @param rootUrl root url to load from
  64611. * @param onProgress event that fires when loading progress has occured
  64612. * @param fileName Defines the name of the file to load
  64613. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  64614. */
  64615. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  64616. meshes: AbstractMesh[];
  64617. particleSystems: IParticleSystem[];
  64618. skeletons: Skeleton[];
  64619. animationGroups: AnimationGroup[];
  64620. }>;
  64621. /**
  64622. * Imports all objects from the loaded glTF data and adds them to the scene
  64623. * @param scene the scene the objects should be added to
  64624. * @param data the glTF data to load
  64625. * @param rootUrl root url to load from
  64626. * @param onProgress event that fires when loading progress has occured
  64627. * @param fileName Defines the name of the file to load
  64628. * @returns a promise which completes when objects have been loaded to the scene
  64629. */
  64630. loadAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  64631. /**
  64632. * Load into an asset container.
  64633. * @param scene The scene to load into
  64634. * @param data The data to import
  64635. * @param rootUrl The root url for scene and resources
  64636. * @param onProgress The callback when the load progresses
  64637. * @param fileName Defines the name of the file to load
  64638. * @returns The loaded asset container
  64639. */
  64640. loadAssetContainerAsync(scene: Scene, data: string | ArrayBuffer, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  64641. /**
  64642. * If the data string can be loaded directly.
  64643. * @param data string contianing the file data
  64644. * @returns if the data can be loaded directly
  64645. */
  64646. canDirectLoad(data: string): boolean;
  64647. /**
  64648. * Rewrites a url by combining a root url and response url.
  64649. */
  64650. rewriteRootURL: (rootUrl: string, responseURL?: string) => string;
  64651. /**
  64652. * Instantiates a glTF file loader plugin.
  64653. * @returns the created plugin
  64654. */
  64655. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  64656. /**
  64657. * The loader state or null if the loader is not active.
  64658. */
  64659. readonly loaderState: Nullable<GLTFLoaderState>;
  64660. /**
  64661. * Returns a promise that resolves when the asset is completely loaded.
  64662. * @returns a promise that resolves when the asset is completely loaded.
  64663. */
  64664. whenCompleteAsync(): Promise<void>;
  64665. private _parseAsync;
  64666. private _validateAsync;
  64667. private _getLoader;
  64668. private _unpackBinary;
  64669. private _unpackBinaryV1;
  64670. private _unpackBinaryV2;
  64671. private static _parseVersion;
  64672. private static _compareVersion;
  64673. private static _decodeBufferToText;
  64674. private static readonly _logSpaces;
  64675. private _logIndentLevel;
  64676. private _loggingEnabled;
  64677. /** @hidden */ private _log: (message: string) => void;
  64678. /** @hidden */ private _logOpen(message: string): void;
  64679. /** @hidden */ private _logClose(): void;
  64680. private _logEnabled;
  64681. private _logDisabled;
  64682. private _capturePerformanceCounters;
  64683. /** @hidden */ private _startPerformanceCounter: (counterName: string) => void;
  64684. /** @hidden */ private _endPerformanceCounter: (counterName: string) => void;
  64685. private _startPerformanceCounterEnabled;
  64686. private _startPerformanceCounterDisabled;
  64687. private _endPerformanceCounterEnabled;
  64688. private _endPerformanceCounterDisabled;
  64689. }
  64690. }
  64691. declare module BABYLON.GLTF1 {
  64692. /**
  64693. * Enums
  64694. * @hidden
  64695. */
  64696. export enum EComponentType {
  64697. BYTE = 5120,
  64698. UNSIGNED_BYTE = 5121,
  64699. SHORT = 5122,
  64700. UNSIGNED_SHORT = 5123,
  64701. FLOAT = 5126
  64702. }
  64703. /** @hidden */
  64704. export enum EShaderType {
  64705. FRAGMENT = 35632,
  64706. VERTEX = 35633
  64707. }
  64708. /** @hidden */
  64709. export enum EParameterType {
  64710. BYTE = 5120,
  64711. UNSIGNED_BYTE = 5121,
  64712. SHORT = 5122,
  64713. UNSIGNED_SHORT = 5123,
  64714. INT = 5124,
  64715. UNSIGNED_INT = 5125,
  64716. FLOAT = 5126,
  64717. FLOAT_VEC2 = 35664,
  64718. FLOAT_VEC3 = 35665,
  64719. FLOAT_VEC4 = 35666,
  64720. INT_VEC2 = 35667,
  64721. INT_VEC3 = 35668,
  64722. INT_VEC4 = 35669,
  64723. BOOL = 35670,
  64724. BOOL_VEC2 = 35671,
  64725. BOOL_VEC3 = 35672,
  64726. BOOL_VEC4 = 35673,
  64727. FLOAT_MAT2 = 35674,
  64728. FLOAT_MAT3 = 35675,
  64729. FLOAT_MAT4 = 35676,
  64730. SAMPLER_2D = 35678
  64731. }
  64732. /** @hidden */
  64733. export enum ETextureWrapMode {
  64734. CLAMP_TO_EDGE = 33071,
  64735. MIRRORED_REPEAT = 33648,
  64736. REPEAT = 10497
  64737. }
  64738. /** @hidden */
  64739. export enum ETextureFilterType {
  64740. NEAREST = 9728,
  64741. LINEAR = 9728,
  64742. NEAREST_MIPMAP_NEAREST = 9984,
  64743. LINEAR_MIPMAP_NEAREST = 9985,
  64744. NEAREST_MIPMAP_LINEAR = 9986,
  64745. LINEAR_MIPMAP_LINEAR = 9987
  64746. }
  64747. /** @hidden */
  64748. export enum ETextureFormat {
  64749. ALPHA = 6406,
  64750. RGB = 6407,
  64751. RGBA = 6408,
  64752. LUMINANCE = 6409,
  64753. LUMINANCE_ALPHA = 6410
  64754. }
  64755. /** @hidden */
  64756. export enum ECullingType {
  64757. FRONT = 1028,
  64758. BACK = 1029,
  64759. FRONT_AND_BACK = 1032
  64760. }
  64761. /** @hidden */
  64762. export enum EBlendingFunction {
  64763. ZERO = 0,
  64764. ONE = 1,
  64765. SRC_COLOR = 768,
  64766. ONE_MINUS_SRC_COLOR = 769,
  64767. DST_COLOR = 774,
  64768. ONE_MINUS_DST_COLOR = 775,
  64769. SRC_ALPHA = 770,
  64770. ONE_MINUS_SRC_ALPHA = 771,
  64771. DST_ALPHA = 772,
  64772. ONE_MINUS_DST_ALPHA = 773,
  64773. CONSTANT_COLOR = 32769,
  64774. ONE_MINUS_CONSTANT_COLOR = 32770,
  64775. CONSTANT_ALPHA = 32771,
  64776. ONE_MINUS_CONSTANT_ALPHA = 32772,
  64777. SRC_ALPHA_SATURATE = 776
  64778. }
  64779. /** @hidden */
  64780. export interface IGLTFProperty {
  64781. extensions?: {
  64782. [key: string]: any;
  64783. };
  64784. extras?: Object;
  64785. }
  64786. /** @hidden */
  64787. export interface IGLTFChildRootProperty extends IGLTFProperty {
  64788. name?: string;
  64789. }
  64790. /** @hidden */
  64791. export interface IGLTFAccessor extends IGLTFChildRootProperty {
  64792. bufferView: string;
  64793. byteOffset: number;
  64794. byteStride: number;
  64795. count: number;
  64796. type: string;
  64797. componentType: EComponentType;
  64798. max?: number[];
  64799. min?: number[];
  64800. name?: string;
  64801. }
  64802. /** @hidden */
  64803. export interface IGLTFBufferView extends IGLTFChildRootProperty {
  64804. buffer: string;
  64805. byteOffset: number;
  64806. byteLength: number;
  64807. byteStride: number;
  64808. target?: number;
  64809. }
  64810. /** @hidden */
  64811. export interface IGLTFBuffer extends IGLTFChildRootProperty {
  64812. uri: string;
  64813. byteLength?: number;
  64814. type?: string;
  64815. }
  64816. /** @hidden */
  64817. export interface IGLTFShader extends IGLTFChildRootProperty {
  64818. uri: string;
  64819. type: EShaderType;
  64820. }
  64821. /** @hidden */
  64822. export interface IGLTFProgram extends IGLTFChildRootProperty {
  64823. attributes: string[];
  64824. fragmentShader: string;
  64825. vertexShader: string;
  64826. }
  64827. /** @hidden */
  64828. export interface IGLTFTechniqueParameter {
  64829. type: number;
  64830. count?: number;
  64831. semantic?: string;
  64832. node?: string;
  64833. value?: number | boolean | string | Array<any>;
  64834. source?: string;
  64835. babylonValue?: any;
  64836. }
  64837. /** @hidden */
  64838. export interface IGLTFTechniqueCommonProfile {
  64839. lightingModel: string;
  64840. texcoordBindings: Object;
  64841. parameters?: Array<any>;
  64842. }
  64843. /** @hidden */
  64844. export interface IGLTFTechniqueStatesFunctions {
  64845. blendColor?: number[];
  64846. blendEquationSeparate?: number[];
  64847. blendFuncSeparate?: number[];
  64848. colorMask: boolean[];
  64849. cullFace: number[];
  64850. }
  64851. /** @hidden */
  64852. export interface IGLTFTechniqueStates {
  64853. enable: number[];
  64854. functions: IGLTFTechniqueStatesFunctions;
  64855. }
  64856. /** @hidden */
  64857. export interface IGLTFTechnique extends IGLTFChildRootProperty {
  64858. parameters: {
  64859. [key: string]: IGLTFTechniqueParameter;
  64860. };
  64861. program: string;
  64862. attributes: {
  64863. [key: string]: string;
  64864. };
  64865. uniforms: {
  64866. [key: string]: string;
  64867. };
  64868. states: IGLTFTechniqueStates;
  64869. }
  64870. /** @hidden */
  64871. export interface IGLTFMaterial extends IGLTFChildRootProperty {
  64872. technique?: string;
  64873. values: string[];
  64874. }
  64875. /** @hidden */
  64876. export interface IGLTFMeshPrimitive extends IGLTFProperty {
  64877. attributes: {
  64878. [key: string]: string;
  64879. };
  64880. indices: string;
  64881. material: string;
  64882. mode?: number;
  64883. }
  64884. /** @hidden */
  64885. export interface IGLTFMesh extends IGLTFChildRootProperty {
  64886. primitives: IGLTFMeshPrimitive[];
  64887. }
  64888. /** @hidden */
  64889. export interface IGLTFImage extends IGLTFChildRootProperty {
  64890. uri: string;
  64891. }
  64892. /** @hidden */
  64893. export interface IGLTFSampler extends IGLTFChildRootProperty {
  64894. magFilter?: number;
  64895. minFilter?: number;
  64896. wrapS?: number;
  64897. wrapT?: number;
  64898. }
  64899. /** @hidden */
  64900. export interface IGLTFTexture extends IGLTFChildRootProperty {
  64901. sampler: string;
  64902. source: string;
  64903. format?: ETextureFormat;
  64904. internalFormat?: ETextureFormat;
  64905. target?: number;
  64906. type?: number;
  64907. babylonTexture?: Texture;
  64908. }
  64909. /** @hidden */
  64910. export interface IGLTFAmbienLight {
  64911. color?: number[];
  64912. }
  64913. /** @hidden */
  64914. export interface IGLTFDirectionalLight {
  64915. color?: number[];
  64916. }
  64917. /** @hidden */
  64918. export interface IGLTFPointLight {
  64919. color?: number[];
  64920. constantAttenuation?: number;
  64921. linearAttenuation?: number;
  64922. quadraticAttenuation?: number;
  64923. }
  64924. /** @hidden */
  64925. export interface IGLTFSpotLight {
  64926. color?: number[];
  64927. constantAttenuation?: number;
  64928. fallOfAngle?: number;
  64929. fallOffExponent?: number;
  64930. linearAttenuation?: number;
  64931. quadraticAttenuation?: number;
  64932. }
  64933. /** @hidden */
  64934. export interface IGLTFLight extends IGLTFChildRootProperty {
  64935. type: string;
  64936. }
  64937. /** @hidden */
  64938. export interface IGLTFCameraOrthographic {
  64939. xmag: number;
  64940. ymag: number;
  64941. zfar: number;
  64942. znear: number;
  64943. }
  64944. /** @hidden */
  64945. export interface IGLTFCameraPerspective {
  64946. aspectRatio: number;
  64947. yfov: number;
  64948. zfar: number;
  64949. znear: number;
  64950. }
  64951. /** @hidden */
  64952. export interface IGLTFCamera extends IGLTFChildRootProperty {
  64953. type: string;
  64954. }
  64955. /** @hidden */
  64956. export interface IGLTFAnimationChannelTarget {
  64957. id: string;
  64958. path: string;
  64959. }
  64960. /** @hidden */
  64961. export interface IGLTFAnimationChannel {
  64962. sampler: string;
  64963. target: IGLTFAnimationChannelTarget;
  64964. }
  64965. /** @hidden */
  64966. export interface IGLTFAnimationSampler {
  64967. input: string;
  64968. output: string;
  64969. interpolation?: string;
  64970. }
  64971. /** @hidden */
  64972. export interface IGLTFAnimation extends IGLTFChildRootProperty {
  64973. channels?: IGLTFAnimationChannel[];
  64974. parameters?: {
  64975. [key: string]: string;
  64976. };
  64977. samplers?: {
  64978. [key: string]: IGLTFAnimationSampler;
  64979. };
  64980. }
  64981. /** @hidden */
  64982. export interface IGLTFNodeInstanceSkin {
  64983. skeletons: string[];
  64984. skin: string;
  64985. meshes: string[];
  64986. }
  64987. /** @hidden */
  64988. export interface IGLTFSkins extends IGLTFChildRootProperty {
  64989. bindShapeMatrix: number[];
  64990. inverseBindMatrices: string;
  64991. jointNames: string[];
  64992. babylonSkeleton?: Skeleton;
  64993. }
  64994. /** @hidden */
  64995. export interface IGLTFNode extends IGLTFChildRootProperty {
  64996. camera?: string;
  64997. children: string[];
  64998. skin?: string;
  64999. jointName?: string;
  65000. light?: string;
  65001. matrix: number[];
  65002. mesh?: string;
  65003. meshes?: string[];
  65004. rotation?: number[];
  65005. scale?: number[];
  65006. translation?: number[];
  65007. babylonNode?: Node;
  65008. }
  65009. /** @hidden */
  65010. export interface IGLTFScene extends IGLTFChildRootProperty {
  65011. nodes: string[];
  65012. }
  65013. /** @hidden */
  65014. export interface IGLTFRuntime {
  65015. extensions: {
  65016. [key: string]: any;
  65017. };
  65018. accessors: {
  65019. [key: string]: IGLTFAccessor;
  65020. };
  65021. buffers: {
  65022. [key: string]: IGLTFBuffer;
  65023. };
  65024. bufferViews: {
  65025. [key: string]: IGLTFBufferView;
  65026. };
  65027. meshes: {
  65028. [key: string]: IGLTFMesh;
  65029. };
  65030. lights: {
  65031. [key: string]: IGLTFLight;
  65032. };
  65033. cameras: {
  65034. [key: string]: IGLTFCamera;
  65035. };
  65036. nodes: {
  65037. [key: string]: IGLTFNode;
  65038. };
  65039. images: {
  65040. [key: string]: IGLTFImage;
  65041. };
  65042. textures: {
  65043. [key: string]: IGLTFTexture;
  65044. };
  65045. shaders: {
  65046. [key: string]: IGLTFShader;
  65047. };
  65048. programs: {
  65049. [key: string]: IGLTFProgram;
  65050. };
  65051. samplers: {
  65052. [key: string]: IGLTFSampler;
  65053. };
  65054. techniques: {
  65055. [key: string]: IGLTFTechnique;
  65056. };
  65057. materials: {
  65058. [key: string]: IGLTFMaterial;
  65059. };
  65060. animations: {
  65061. [key: string]: IGLTFAnimation;
  65062. };
  65063. skins: {
  65064. [key: string]: IGLTFSkins;
  65065. };
  65066. currentScene?: Object;
  65067. scenes: {
  65068. [key: string]: IGLTFScene;
  65069. };
  65070. extensionsUsed: string[];
  65071. extensionsRequired?: string[];
  65072. buffersCount: number;
  65073. shaderscount: number;
  65074. scene: Scene;
  65075. rootUrl: string;
  65076. loadedBufferCount: number;
  65077. loadedBufferViews: {
  65078. [name: string]: ArrayBufferView;
  65079. };
  65080. loadedShaderCount: number;
  65081. importOnlyMeshes: boolean;
  65082. importMeshesNames?: string[];
  65083. dummyNodes: Node[];
  65084. }
  65085. /** @hidden */
  65086. export interface INodeToRoot {
  65087. bone: Bone;
  65088. node: IGLTFNode;
  65089. id: string;
  65090. }
  65091. /** @hidden */
  65092. export interface IJointNode {
  65093. node: IGLTFNode;
  65094. id: string;
  65095. }
  65096. }
  65097. declare module BABYLON.GLTF1 {
  65098. /**
  65099. * Utils functions for GLTF
  65100. * @hidden
  65101. */
  65102. export class GLTFUtils {
  65103. /**
  65104. * Sets the given "parameter" matrix
  65105. * @param scene: the Scene object
  65106. * @param source: the source node where to pick the matrix
  65107. * @param parameter: the GLTF technique parameter
  65108. * @param uniformName: the name of the shader's uniform
  65109. * @param shaderMaterial: the shader material
  65110. */
  65111. static SetMatrix(scene: Scene, source: Node, parameter: IGLTFTechniqueParameter, uniformName: string, shaderMaterial: ShaderMaterial | Effect): void;
  65112. /**
  65113. * Sets the given "parameter" matrix
  65114. * @param shaderMaterial: the shader material
  65115. * @param uniform: the name of the shader's uniform
  65116. * @param value: the value of the uniform
  65117. * @param type: the uniform's type (EParameterType FLOAT, VEC2, VEC3 or VEC4)
  65118. */
  65119. static SetUniform(shaderMaterial: ShaderMaterial | Effect, uniform: string, value: any, type: number): boolean;
  65120. /**
  65121. * Returns the wrap mode of the texture
  65122. * @param mode: the mode value
  65123. */
  65124. static GetWrapMode(mode: number): number;
  65125. /**
  65126. * Returns the byte stride giving an accessor
  65127. * @param accessor: the GLTF accessor objet
  65128. */
  65129. static GetByteStrideFromType(accessor: IGLTFAccessor): number;
  65130. /**
  65131. * Returns the texture filter mode giving a mode value
  65132. * @param mode: the filter mode value
  65133. */
  65134. static GetTextureFilterMode(mode: number): ETextureFilterType;
  65135. static GetBufferFromBufferView(gltfRuntime: IGLTFRuntime, bufferView: IGLTFBufferView, byteOffset: number, byteLength: number, componentType: EComponentType): ArrayBufferView;
  65136. /**
  65137. * Returns a buffer from its accessor
  65138. * @param gltfRuntime: the GLTF runtime
  65139. * @param accessor: the GLTF accessor
  65140. */
  65141. static GetBufferFromAccessor(gltfRuntime: IGLTFRuntime, accessor: IGLTFAccessor): any;
  65142. /**
  65143. * Decodes a buffer view into a string
  65144. * @param view: the buffer view
  65145. */
  65146. static DecodeBufferToText(view: ArrayBufferView): string;
  65147. /**
  65148. * Returns the default material of gltf. Related to
  65149. * https://github.com/KhronosGroup/glTF/tree/master/specification/1.0#appendix-a-default-material
  65150. * @param scene: the Babylon.js scene
  65151. */
  65152. static GetDefaultMaterial(scene: Scene): ShaderMaterial;
  65153. private static _DefaultMaterial;
  65154. }
  65155. }
  65156. declare module BABYLON.GLTF1 {
  65157. /**
  65158. * Implementation of the base glTF spec
  65159. * @hidden
  65160. */
  65161. export class GLTFLoaderBase {
  65162. static CreateRuntime(parsedData: any, scene: Scene, rootUrl: string): IGLTFRuntime;
  65163. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65164. static LoadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: Nullable<ArrayBufferView>) => void, onError: (message: string) => void): void;
  65165. static CreateTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: Nullable<ArrayBufferView>, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65166. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string | ArrayBuffer) => void, onError?: (message: string) => void): void;
  65167. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65168. }
  65169. /**
  65170. * glTF V1 Loader
  65171. * @hidden
  65172. */
  65173. export class GLTFLoader implements IGLTFLoader {
  65174. static Extensions: {
  65175. [name: string]: GLTFLoaderExtension;
  65176. };
  65177. static RegisterExtension(extension: GLTFLoaderExtension): void;
  65178. state: Nullable<GLTFLoaderState>;
  65179. dispose(): void;
  65180. private _importMeshAsync;
  65181. /**
  65182. * Imports one or more meshes from a loaded gltf file and adds them to the scene
  65183. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  65184. * @param scene the scene the meshes should be added to
  65185. * @param data gltf data containing information of the meshes in a loaded file
  65186. * @param rootUrl root url to load from
  65187. * @param onProgress event that fires when loading progress has occured
  65188. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  65189. */
  65190. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<{
  65191. meshes: AbstractMesh[];
  65192. particleSystems: IParticleSystem[];
  65193. skeletons: Skeleton[];
  65194. animationGroups: AnimationGroup[];
  65195. }>;
  65196. private _loadAsync;
  65197. /**
  65198. * Imports all objects from a loaded gltf file and adds them to the scene
  65199. * @param scene the scene the objects should be added to
  65200. * @param data gltf data containing information of the meshes in a loaded file
  65201. * @param rootUrl root url to load from
  65202. * @param onProgress event that fires when loading progress has occured
  65203. * @returns a promise which completes when objects have been loaded to the scene
  65204. */
  65205. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void): Promise<void>;
  65206. private _loadShadersAsync;
  65207. private _loadBuffersAsync;
  65208. private _createNodes;
  65209. }
  65210. /** @hidden */
  65211. export abstract class GLTFLoaderExtension {
  65212. private _name;
  65213. constructor(name: string);
  65214. readonly name: string;
  65215. /**
  65216. * Defines an override for loading the runtime
  65217. * Return true to stop further extensions from loading the runtime
  65218. */
  65219. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): boolean;
  65220. /**
  65221. * Defines an onverride for creating gltf runtime
  65222. * Return true to stop further extensions from creating the runtime
  65223. */
  65224. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): boolean;
  65225. /**
  65226. * Defines an override for loading buffers
  65227. * Return true to stop further extensions from loading this buffer
  65228. */
  65229. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): boolean;
  65230. /**
  65231. * Defines an override for loading texture buffers
  65232. * Return true to stop further extensions from loading this texture data
  65233. */
  65234. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65235. /**
  65236. * Defines an override for creating textures
  65237. * Return true to stop further extensions from loading this texture
  65238. */
  65239. createTextureAsync(gltfRuntime: IGLTFRuntime, id: string, buffer: ArrayBufferView, onSuccess: (texture: Texture) => void, onError: (message: string) => void): boolean;
  65240. /**
  65241. * Defines an override for loading shader strings
  65242. * Return true to stop further extensions from loading this shader data
  65243. */
  65244. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65245. /**
  65246. * Defines an override for loading materials
  65247. * Return true to stop further extensions from loading this material
  65248. */
  65249. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65250. static LoadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess?: (gltfRuntime: IGLTFRuntime) => void, onError?: (message: string) => void): void;
  65251. static LoadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError?: (message: string) => void): void;
  65252. static LoadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (bufferView: ArrayBufferView) => void, onError: (message: string) => void, onProgress?: () => void): void;
  65253. static LoadTextureAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (texture: Texture) => void, onError: (message: string) => void): void;
  65254. static LoadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderData: string | ArrayBuffer) => void, onError: (message: string) => void): void;
  65255. static LoadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): void;
  65256. private static LoadTextureBufferAsync;
  65257. private static CreateTextureAsync;
  65258. private static ApplyExtensions;
  65259. }
  65260. }
  65261. declare module BABYLON.GLTF1 {
  65262. /** @hidden */
  65263. export class GLTFBinaryExtension extends GLTFLoaderExtension {
  65264. private _bin;
  65265. constructor();
  65266. loadRuntimeAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onSuccess: (gltfRuntime: IGLTFRuntime) => void, onError: (message: string) => void): boolean;
  65267. loadBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65268. loadTextureBufferAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (buffer: ArrayBufferView) => void, onError: (message: string) => void): boolean;
  65269. loadShaderStringAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (shaderString: string) => void, onError: (message: string) => void): boolean;
  65270. }
  65271. }
  65272. declare module BABYLON.GLTF1 {
  65273. /** @hidden */
  65274. export class GLTFMaterialsCommonExtension extends GLTFLoaderExtension {
  65275. constructor();
  65276. loadRuntimeExtensionsAsync(gltfRuntime: IGLTFRuntime, onSuccess: () => void, onError: (message: string) => void): boolean;
  65277. loadMaterialAsync(gltfRuntime: IGLTFRuntime, id: string, onSuccess: (material: Material) => void, onError: (message: string) => void): boolean;
  65278. private _loadTexture;
  65279. }
  65280. }
  65281. declare module BABYLON.GLTF2.Loader {
  65282. /**
  65283. * Loader interface with an index field.
  65284. */
  65285. export interface IArrayItem {
  65286. /**
  65287. * The index of this item in the array.
  65288. */
  65289. index: number;
  65290. }
  65291. /**
  65292. * Loader interface with additional members.
  65293. */
  65294. export interface IAccessor extends BABYLON.GLTF2.IAccessor, IArrayItem {
  65295. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65296. /** @hidden */ private _babylonVertexBuffer?: Promise<VertexBuffer>;
  65297. }
  65298. /**
  65299. * Loader interface with additional members.
  65300. */
  65301. export interface IAnimationChannel extends BABYLON.GLTF2.IAnimationChannel, IArrayItem {
  65302. }
  65303. /** @hidden */
  65304. export interface _IAnimationSamplerData {
  65305. input: Float32Array;
  65306. interpolation: BABYLON.GLTF2.AnimationSamplerInterpolation;
  65307. output: Float32Array;
  65308. }
  65309. /**
  65310. * Loader interface with additional members.
  65311. */
  65312. export interface IAnimationSampler extends BABYLON.GLTF2.IAnimationSampler, IArrayItem {
  65313. /** @hidden */ private _data?: Promise<_IAnimationSamplerData>;
  65314. }
  65315. /**
  65316. * Loader interface with additional members.
  65317. */
  65318. export interface IAnimation extends BABYLON.GLTF2.IAnimation, IArrayItem {
  65319. channels: IAnimationChannel[];
  65320. samplers: IAnimationSampler[];
  65321. /** @hidden */ private _babylonAnimationGroup?: AnimationGroup;
  65322. }
  65323. /**
  65324. * Loader interface with additional members.
  65325. */
  65326. export interface IBuffer extends BABYLON.GLTF2.IBuffer, IArrayItem {
  65327. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65328. }
  65329. /**
  65330. * Loader interface with additional members.
  65331. */
  65332. export interface IBufferView extends BABYLON.GLTF2.IBufferView, IArrayItem {
  65333. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65334. /** @hidden */ private _babylonBuffer?: Promise<Buffer>;
  65335. }
  65336. /**
  65337. * Loader interface with additional members.
  65338. */
  65339. export interface ICamera extends BABYLON.GLTF2.ICamera, IArrayItem {
  65340. }
  65341. /**
  65342. * Loader interface with additional members.
  65343. */
  65344. export interface IImage extends BABYLON.GLTF2.IImage, IArrayItem {
  65345. /** @hidden */ private _data?: Promise<ArrayBufferView>;
  65346. }
  65347. /**
  65348. * Loader interface with additional members.
  65349. */
  65350. export interface IMaterialNormalTextureInfo extends BABYLON.GLTF2.IMaterialNormalTextureInfo, ITextureInfo {
  65351. }
  65352. /**
  65353. * Loader interface with additional members.
  65354. */
  65355. export interface IMaterialOcclusionTextureInfo extends BABYLON.GLTF2.IMaterialOcclusionTextureInfo, ITextureInfo {
  65356. }
  65357. /**
  65358. * Loader interface with additional members.
  65359. */
  65360. export interface IMaterialPbrMetallicRoughness extends BABYLON.GLTF2.IMaterialPbrMetallicRoughness {
  65361. baseColorTexture?: ITextureInfo;
  65362. metallicRoughnessTexture?: ITextureInfo;
  65363. }
  65364. /**
  65365. * Loader interface with additional members.
  65366. */
  65367. export interface IMaterial extends BABYLON.GLTF2.IMaterial, IArrayItem {
  65368. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  65369. normalTexture?: IMaterialNormalTextureInfo;
  65370. occlusionTexture?: IMaterialOcclusionTextureInfo;
  65371. emissiveTexture?: ITextureInfo;
  65372. /** @hidden */ private _data?: {
  65373. [babylonDrawMode: number]: {
  65374. babylonMaterial: Material;
  65375. babylonMeshes: AbstractMesh[];
  65376. promise: Promise<void>;
  65377. };
  65378. };
  65379. }
  65380. /**
  65381. * Loader interface with additional members.
  65382. */
  65383. export interface IMesh extends BABYLON.GLTF2.IMesh, IArrayItem {
  65384. primitives: IMeshPrimitive[];
  65385. }
  65386. /**
  65387. * Loader interface with additional members.
  65388. */
  65389. export interface IMeshPrimitive extends BABYLON.GLTF2.IMeshPrimitive, IArrayItem {
  65390. /** @hidden */ private _instanceData?: {
  65391. babylonSourceMesh: Mesh;
  65392. promise: Promise<any>;
  65393. };
  65394. }
  65395. /**
  65396. * Loader interface with additional members.
  65397. */
  65398. export interface INode extends BABYLON.GLTF2.INode, IArrayItem {
  65399. /**
  65400. * The parent glTF node.
  65401. */
  65402. parent?: INode;
  65403. /** @hidden */ private _babylonTransformNode?: TransformNode;
  65404. /** @hidden */ private _primitiveBabylonMeshes?: AbstractMesh[];
  65405. /** @hidden */ private _babylonBones?: Bone[];
  65406. /** @hidden */ private _numMorphTargets?: number;
  65407. }
  65408. /** @hidden */
  65409. export interface _ISamplerData {
  65410. noMipMaps: boolean;
  65411. samplingMode: number;
  65412. wrapU: number;
  65413. wrapV: number;
  65414. }
  65415. /**
  65416. * Loader interface with additional members.
  65417. */
  65418. export interface ISampler extends BABYLON.GLTF2.ISampler, IArrayItem {
  65419. /** @hidden */ private _data?: _ISamplerData;
  65420. }
  65421. /**
  65422. * Loader interface with additional members.
  65423. */
  65424. export interface IScene extends BABYLON.GLTF2.IScene, IArrayItem {
  65425. }
  65426. /**
  65427. * Loader interface with additional members.
  65428. */
  65429. export interface ISkin extends BABYLON.GLTF2.ISkin, IArrayItem {
  65430. /** @hidden */ private _data?: {
  65431. babylonSkeleton: Skeleton;
  65432. promise: Promise<void>;
  65433. };
  65434. }
  65435. /**
  65436. * Loader interface with additional members.
  65437. */
  65438. export interface ITexture extends BABYLON.GLTF2.ITexture, IArrayItem {
  65439. }
  65440. /**
  65441. * Loader interface with additional members.
  65442. */
  65443. export interface ITextureInfo extends BABYLON.GLTF2.ITextureInfo {
  65444. }
  65445. /**
  65446. * Loader interface with additional members.
  65447. */
  65448. export interface IGLTF extends BABYLON.GLTF2.IGLTF {
  65449. accessors?: IAccessor[];
  65450. animations?: IAnimation[];
  65451. buffers?: IBuffer[];
  65452. bufferViews?: IBufferView[];
  65453. cameras?: ICamera[];
  65454. images?: IImage[];
  65455. materials?: IMaterial[];
  65456. meshes?: IMesh[];
  65457. nodes?: INode[];
  65458. samplers?: ISampler[];
  65459. scenes?: IScene[];
  65460. skins?: ISkin[];
  65461. textures?: ITexture[];
  65462. }
  65463. }
  65464. declare module BABYLON.GLTF2 {
  65465. /**
  65466. * Interface for a glTF loader extension.
  65467. */
  65468. export interface IGLTFLoaderExtension extends BABYLON.IGLTFLoaderExtension, IDisposable {
  65469. /**
  65470. * Called after the loader state changes to LOADING.
  65471. */
  65472. onLoading?(): void;
  65473. /**
  65474. * Called after the loader state changes to READY.
  65475. */
  65476. onReady?(): void;
  65477. /**
  65478. * Define this method to modify the default behavior when loading scenes.
  65479. * @param context The context when loading the asset
  65480. * @param scene The glTF scene property
  65481. * @returns A promise that resolves when the load is complete or null if not handled
  65482. */
  65483. loadSceneAsync?(context: string, scene: IScene): Nullable<Promise<void>>;
  65484. /**
  65485. * Define this method to modify the default behavior when loading nodes.
  65486. * @param context The context when loading the asset
  65487. * @param node The glTF node property
  65488. * @param assign A function called synchronously after parsing the glTF properties
  65489. * @returns A promise that resolves with the loaded Babylon transform node when the load is complete or null if not handled
  65490. */
  65491. loadNodeAsync?(context: string, node: INode, assign: (babylonMesh: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65492. /**
  65493. * Define this method to modify the default behavior when loading cameras.
  65494. * @param context The context when loading the asset
  65495. * @param camera The glTF camera property
  65496. * @param assign A function called synchronously after parsing the glTF properties
  65497. * @returns A promise that resolves with the loaded Babylon camera when the load is complete or null if not handled
  65498. */
  65499. loadCameraAsync?(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  65500. /**
  65501. * @hidden Define this method to modify the default behavior when loading vertex data for mesh primitives.
  65502. * @param context The context when loading the asset
  65503. * @param primitive The glTF mesh primitive property
  65504. * @returns A promise that resolves with the loaded geometry when the load is complete or null if not handled
  65505. */ private _loadVertexDataAsync?(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65506. /**
  65507. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65508. * @param context The context when loading the asset
  65509. * @param name The mesh name when loading the asset
  65510. * @param node The glTF node when loading the asset
  65511. * @param mesh The glTF mesh when loading the asset
  65512. * @param primitive The glTF mesh primitive property
  65513. * @param assign A function called synchronously after parsing the glTF properties
  65514. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65515. */ private _loadMeshPrimitiveAsync?(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65516. /**
  65517. * @hidden Define this method to modify the default behavior when loading materials. Load material creates the material and then loads material properties.
  65518. * @param context The context when loading the asset
  65519. * @param material The glTF material property
  65520. * @param assign A function called synchronously after parsing the glTF properties
  65521. * @returns A promise that resolves with the loaded Babylon material when the load is complete or null if not handled
  65522. */ private _loadMaterialAsync?(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  65523. /**
  65524. * Define this method to modify the default behavior when creating materials.
  65525. * @param context The context when loading the asset
  65526. * @param material The glTF material property
  65527. * @param babylonDrawMode The draw mode for the Babylon material
  65528. * @returns The Babylon material or null if not handled
  65529. */
  65530. createMaterial?(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  65531. /**
  65532. * Define this method to modify the default behavior when loading material properties.
  65533. * @param context The context when loading the asset
  65534. * @param material The glTF material property
  65535. * @param babylonMaterial The Babylon material
  65536. * @returns A promise that resolves when the load is complete or null if not handled
  65537. */
  65538. loadMaterialPropertiesAsync?(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65539. /**
  65540. * Define this method to modify the default behavior when loading texture infos.
  65541. * @param context The context when loading the asset
  65542. * @param textureInfo The glTF texture info property
  65543. * @param assign A function called synchronously after parsing the glTF properties
  65544. * @returns A promise that resolves with the loaded Babylon texture when the load is complete or null if not handled
  65545. */
  65546. loadTextureInfoAsync?(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65547. /**
  65548. * Define this method to modify the default behavior when loading animations.
  65549. * @param context The context when loading the asset
  65550. * @param animation The glTF animation property
  65551. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete or null if not handled
  65552. */
  65553. loadAnimationAsync?(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  65554. /**
  65555. * @hidden Define this method to modify the default behavior when loading skins.
  65556. * @param context The context when loading the asset
  65557. * @param node The glTF node property
  65558. * @param skin The glTF skin property
  65559. * @returns A promise that resolves when the load is complete or null if not handled
  65560. */ private _loadSkinAsync?(context: string, node: INode, skin: ISkin): Nullable<Promise<void>>;
  65561. /**
  65562. * @hidden Define this method to modify the default behavior when loading uris.
  65563. * @param context The context when loading the asset
  65564. * @param property The glTF property associated with the uri
  65565. * @param uri The uri to load
  65566. * @returns A promise that resolves with the loaded data when the load is complete or null if not handled
  65567. */ private _loadUriAsync?(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  65568. }
  65569. }
  65570. declare module BABYLON.GLTF2 {
  65571. /**
  65572. * Helper class for working with arrays when loading the glTF asset
  65573. */
  65574. export class ArrayItem {
  65575. /**
  65576. * Gets an item from the given array.
  65577. * @param context The context when loading the asset
  65578. * @param array The array to get the item from
  65579. * @param index The index to the array
  65580. * @returns The array item
  65581. */
  65582. static Get<T>(context: string, array: ArrayLike<T> | undefined, index: number | undefined): T;
  65583. /**
  65584. * Assign an `index` field to each item of the given array.
  65585. * @param array The array of items
  65586. */
  65587. static Assign(array?: BABYLON.GLTF2.Loader.IArrayItem[]): void;
  65588. }
  65589. /**
  65590. * The glTF 2.0 loader
  65591. */
  65592. export class GLTFLoader implements IGLTFLoader {
  65593. /** @hidden */ private _completePromises: Promise<any>[];
  65594. private _disposed;
  65595. private _parent;
  65596. private _state;
  65597. private _extensions;
  65598. private _rootUrl;
  65599. private _fileName;
  65600. private _uniqueRootUrl;
  65601. private _gltf;
  65602. private _babylonScene;
  65603. private _rootBabylonMesh;
  65604. private _defaultBabylonMaterialData;
  65605. private _progressCallback?;
  65606. private _requests;
  65607. private static readonly _DefaultSampler;
  65608. private static _ExtensionNames;
  65609. private static _ExtensionFactories;
  65610. /**
  65611. * Registers a loader extension.
  65612. * @param name The name of the loader extension.
  65613. * @param factory The factory function that creates the loader extension.
  65614. */
  65615. static RegisterExtension(name: string, factory: (loader: GLTFLoader) => IGLTFLoaderExtension): void;
  65616. /**
  65617. * Unregisters a loader extension.
  65618. * @param name The name of the loader extenion.
  65619. * @returns A boolean indicating whether the extension has been unregistered
  65620. */
  65621. static UnregisterExtension(name: string): boolean;
  65622. /**
  65623. * Gets the loader state.
  65624. */
  65625. readonly state: Nullable<GLTFLoaderState>;
  65626. /**
  65627. * The glTF object parsed from the JSON.
  65628. */
  65629. readonly gltf: IGLTF;
  65630. /**
  65631. * The Babylon scene when loading the asset.
  65632. */
  65633. readonly babylonScene: Scene;
  65634. /**
  65635. * The root Babylon mesh when loading the asset.
  65636. */
  65637. readonly rootBabylonMesh: Mesh;
  65638. /** @hidden */
  65639. constructor(parent: GLTFFileLoader);
  65640. /** @hidden */
  65641. dispose(): void;
  65642. /** @hidden */
  65643. importMeshAsync(meshesNames: any, scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  65644. meshes: AbstractMesh[];
  65645. particleSystems: IParticleSystem[];
  65646. skeletons: Skeleton[];
  65647. animationGroups: AnimationGroup[];
  65648. }>;
  65649. /** @hidden */
  65650. loadAsync(scene: Scene, data: IGLTFLoaderData, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  65651. private _loadAsync;
  65652. private _loadData;
  65653. private _setupData;
  65654. private _loadExtensions;
  65655. private _checkExtensions;
  65656. private _setState;
  65657. private _createRootNode;
  65658. /**
  65659. * Loads a glTF scene.
  65660. * @param context The context when loading the asset
  65661. * @param scene The glTF scene property
  65662. * @returns A promise that resolves when the load is complete
  65663. */
  65664. loadSceneAsync(context: string, scene: IScene): Promise<void>;
  65665. private _forEachPrimitive;
  65666. private _getMeshes;
  65667. private _getSkeletons;
  65668. private _getAnimationGroups;
  65669. private _startAnimations;
  65670. /**
  65671. * Loads a glTF node.
  65672. * @param context The context when loading the asset
  65673. * @param node The glTF node property
  65674. * @param assign A function called synchronously after parsing the glTF properties
  65675. * @returns A promise that resolves with the loaded Babylon mesh when the load is complete
  65676. */
  65677. loadNodeAsync(context: string, node: INode, assign?: (babylonTransformNode: TransformNode) => void): Promise<TransformNode>;
  65678. private _loadMeshAsync;
  65679. /**
  65680. * @hidden Define this method to modify the default behavior when loading data for mesh primitives.
  65681. * @param context The context when loading the asset
  65682. * @param name The mesh name when loading the asset
  65683. * @param node The glTF node when loading the asset
  65684. * @param mesh The glTF mesh when loading the asset
  65685. * @param primitive The glTF mesh primitive property
  65686. * @param assign A function called synchronously after parsing the glTF properties
  65687. * @returns A promise that resolves with the loaded mesh when the load is complete or null if not handled
  65688. */ private _loadMeshPrimitiveAsync(context: string, name: string, node: INode, mesh: IMesh, primitive: IMeshPrimitive, assign: (babylonMesh: AbstractMesh) => void): Promise<AbstractMesh>;
  65689. private _loadVertexDataAsync;
  65690. private _createMorphTargets;
  65691. private _loadMorphTargetsAsync;
  65692. private _loadMorphTargetVertexDataAsync;
  65693. private static _LoadTransform;
  65694. private _loadSkinAsync;
  65695. private _loadBones;
  65696. private _loadBone;
  65697. private _loadSkinInverseBindMatricesDataAsync;
  65698. private _updateBoneMatrices;
  65699. private _getNodeMatrix;
  65700. /**
  65701. * Loads a glTF camera.
  65702. * @param context The context when loading the asset
  65703. * @param camera The glTF camera property
  65704. * @param assign A function called synchronously after parsing the glTF properties
  65705. * @returns A promise that resolves with the loaded Babylon camera when the load is complete
  65706. */
  65707. loadCameraAsync(context: string, camera: ICamera, assign?: (babylonCamera: Camera) => void): Promise<Camera>;
  65708. private _loadAnimationsAsync;
  65709. /**
  65710. * Loads a glTF animation.
  65711. * @param context The context when loading the asset
  65712. * @param animation The glTF animation property
  65713. * @returns A promise that resolves with the loaded Babylon animation group when the load is complete
  65714. */
  65715. loadAnimationAsync(context: string, animation: IAnimation): Promise<AnimationGroup>;
  65716. /**
  65717. * @hidden Loads a glTF animation channel.
  65718. * @param context The context when loading the asset
  65719. * @param animationContext The context of the animation when loading the asset
  65720. * @param animation The glTF animation property
  65721. * @param channel The glTF animation channel property
  65722. * @param babylonAnimationGroup The babylon animation group property
  65723. * @param animationTargetOverride The babylon animation channel target override property. My be null.
  65724. * @returns A void promise when the channel load is complete
  65725. */ private _loadAnimationChannelAsync(context: string, animationContext: string, animation: IAnimation, channel: IAnimationChannel, babylonAnimationGroup: AnimationGroup, animationTargetOverride?: Nullable<IAnimatable>): Promise<void>;
  65726. private _loadAnimationSamplerAsync;
  65727. private _loadBufferAsync;
  65728. /**
  65729. * Loads a glTF buffer view.
  65730. * @param context The context when loading the asset
  65731. * @param bufferView The glTF buffer view property
  65732. * @returns A promise that resolves with the loaded data when the load is complete
  65733. */
  65734. loadBufferViewAsync(context: string, bufferView: IBufferView): Promise<ArrayBufferView>;
  65735. private _loadAccessorAsync;
  65736. private _loadFloatAccessorAsync;
  65737. private _loadIndicesAccessorAsync;
  65738. private _loadVertexBufferViewAsync;
  65739. private _loadVertexAccessorAsync;
  65740. private _loadMaterialMetallicRoughnessPropertiesAsync;
  65741. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign?: (babylonMaterial: Material) => void): Promise<Material>;
  65742. private _createDefaultMaterial;
  65743. /**
  65744. * Creates a Babylon material from a glTF material.
  65745. * @param context The context when loading the asset
  65746. * @param material The glTF material property
  65747. * @param babylonDrawMode The draw mode for the Babylon material
  65748. * @returns The Babylon material
  65749. */
  65750. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Material;
  65751. /**
  65752. * Loads properties from a glTF material into a Babylon material.
  65753. * @param context The context when loading the asset
  65754. * @param material The glTF material property
  65755. * @param babylonMaterial The Babylon material
  65756. * @returns A promise that resolves when the load is complete
  65757. */
  65758. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65759. /**
  65760. * Loads the normal, occlusion, and emissive properties from a glTF material into a Babylon material.
  65761. * @param context The context when loading the asset
  65762. * @param material The glTF material property
  65763. * @param babylonMaterial The Babylon material
  65764. * @returns A promise that resolves when the load is complete
  65765. */
  65766. loadMaterialBasePropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Promise<void>;
  65767. /**
  65768. * Loads the alpha properties from a glTF material into a Babylon material.
  65769. * Must be called after the setting the albedo texture of the Babylon material when the material has an albedo texture.
  65770. * @param context The context when loading the asset
  65771. * @param material The glTF material property
  65772. * @param babylonMaterial The Babylon material
  65773. */
  65774. loadMaterialAlphaProperties(context: string, material: IMaterial, babylonMaterial: Material): void;
  65775. /**
  65776. * Loads a glTF texture info.
  65777. * @param context The context when loading the asset
  65778. * @param textureInfo The glTF texture info property
  65779. * @param assign A function called synchronously after parsing the glTF properties
  65780. * @returns A promise that resolves with the loaded Babylon texture when the load is complete
  65781. */
  65782. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign?: (babylonTexture: BaseTexture) => void): Promise<BaseTexture>;
  65783. private _loadTextureAsync;
  65784. private _loadSampler;
  65785. /**
  65786. * Loads a glTF image.
  65787. * @param context The context when loading the asset
  65788. * @param image The glTF image property
  65789. * @returns A promise that resolves with the loaded data when the load is complete
  65790. */
  65791. loadImageAsync(context: string, image: IImage): Promise<ArrayBufferView>;
  65792. /**
  65793. * Loads a glTF uri.
  65794. * @param context The context when loading the asset
  65795. * @param property The glTF property associated with the uri
  65796. * @param uri The base64 or relative uri
  65797. * @returns A promise that resolves with the loaded data when the load is complete
  65798. */
  65799. loadUriAsync(context: string, property: IProperty, uri: string): Promise<ArrayBufferView>;
  65800. private _onProgress;
  65801. /**
  65802. * Adds a JSON pointer to the metadata of the Babylon object at `<object>.metadata.gltf.pointers`.
  65803. * @param babylonObject the Babylon object with metadata
  65804. * @param pointer the JSON pointer
  65805. */
  65806. static AddPointerMetadata(babylonObject: {
  65807. metadata: any;
  65808. }, pointer: string): void;
  65809. private static _GetTextureWrapMode;
  65810. private static _GetTextureSamplingMode;
  65811. private static _GetTypedArrayConstructor;
  65812. private static _GetTypedArray;
  65813. private static _GetNumComponents;
  65814. private static _ValidateUri;
  65815. private static _GetDrawMode;
  65816. private _compileMaterialsAsync;
  65817. private _compileShadowGeneratorsAsync;
  65818. private _forEachExtensions;
  65819. private _applyExtensions;
  65820. private _extensionsOnLoading;
  65821. private _extensionsOnReady;
  65822. private _extensionsLoadSceneAsync;
  65823. private _extensionsLoadNodeAsync;
  65824. private _extensionsLoadCameraAsync;
  65825. private _extensionsLoadVertexDataAsync;
  65826. private _extensionsLoadMeshPrimitiveAsync;
  65827. private _extensionsLoadMaterialAsync;
  65828. private _extensionsCreateMaterial;
  65829. private _extensionsLoadMaterialPropertiesAsync;
  65830. private _extensionsLoadTextureInfoAsync;
  65831. private _extensionsLoadAnimationAsync;
  65832. private _extensionsLoadSkinAsync;
  65833. private _extensionsLoadUriAsync;
  65834. /**
  65835. * Helper method called by a loader extension to load an glTF extension.
  65836. * @param context The context when loading the asset
  65837. * @param property The glTF property to load the extension from
  65838. * @param extensionName The name of the extension to load
  65839. * @param actionAsync The action to run
  65840. * @returns The promise returned by actionAsync or null if the extension does not exist
  65841. */
  65842. static LoadExtensionAsync<TExtension = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extensionContext: string, extension: TExtension) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65843. /**
  65844. * Helper method called by a loader extension to load a glTF extra.
  65845. * @param context The context when loading the asset
  65846. * @param property The glTF property to load the extra from
  65847. * @param extensionName The name of the extension to load
  65848. * @param actionAsync The action to run
  65849. * @returns The promise returned by actionAsync or null if the extra does not exist
  65850. */
  65851. static LoadExtraAsync<TExtra = any, TResult = void>(context: string, property: IProperty, extensionName: string, actionAsync: (extraContext: string, extra: TExtra) => Nullable<Promise<TResult>>): Nullable<Promise<TResult>>;
  65852. /**
  65853. * Increments the indentation level and logs a message.
  65854. * @param message The message to log
  65855. */
  65856. logOpen(message: string): void;
  65857. /**
  65858. * Decrements the indentation level.
  65859. */
  65860. logClose(): void;
  65861. /**
  65862. * Logs a message
  65863. * @param message The message to log
  65864. */
  65865. log(message: string): void;
  65866. /**
  65867. * Starts a performance counter.
  65868. * @param counterName The name of the performance counter
  65869. */
  65870. startPerformanceCounter(counterName: string): void;
  65871. /**
  65872. * Ends a performance counter.
  65873. * @param counterName The name of the performance counter
  65874. */
  65875. endPerformanceCounter(counterName: string): void;
  65876. }
  65877. }
  65878. declare module BABYLON.GLTF2.Loader.Extensions {
  65879. /**
  65880. * [Specification](https://github.com/KhronosGroup/glTF/blob/eb3e32332042e04691a5f35103f8c261e50d8f1e/extensions/2.0/Khronos/EXT_lights_image_based/README.md) (Experimental)
  65881. */
  65882. export class EXT_lights_image_based implements IGLTFLoaderExtension {
  65883. /** The name of this extension. */
  65884. readonly name: string;
  65885. /** Defines whether this extension is enabled. */
  65886. enabled: boolean;
  65887. private _loader;
  65888. private _lights?;
  65889. /** @hidden */
  65890. constructor(loader: GLTFLoader);
  65891. /** @hidden */
  65892. dispose(): void;
  65893. /** @hidden */
  65894. onLoading(): void;
  65895. /** @hidden */
  65896. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  65897. private _loadLightAsync;
  65898. }
  65899. }
  65900. declare module BABYLON.GLTF2.Loader.Extensions {
  65901. /**
  65902. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression)
  65903. */
  65904. export class KHR_draco_mesh_compression implements IGLTFLoaderExtension {
  65905. /** The name of this extension. */
  65906. readonly name: string;
  65907. /** The draco compression used to decode vertex data or DracoCompression.Default if not defined */
  65908. dracoCompression?: DracoCompression;
  65909. /** Defines whether this extension is enabled. */
  65910. enabled: boolean;
  65911. private _loader;
  65912. /** @hidden */
  65913. constructor(loader: GLTFLoader);
  65914. /** @hidden */
  65915. dispose(): void;
  65916. /** @hidden */ private _loadVertexDataAsync(context: string, primitive: IMeshPrimitive, babylonMesh: Mesh): Nullable<Promise<Geometry>>;
  65917. }
  65918. }
  65919. declare module BABYLON.GLTF2.Loader.Extensions {
  65920. /**
  65921. * [Specification](https://github.com/KhronosGroup/glTF/blob/1048d162a44dbcb05aefc1874bfd423cf60135a6/extensions/2.0/Khronos/KHR_lights_punctual/README.md) (Experimental)
  65922. */
  65923. export class KHR_lights implements IGLTFLoaderExtension {
  65924. /** The name of this extension. */
  65925. readonly name: string;
  65926. /** Defines whether this extension is enabled. */
  65927. enabled: boolean;
  65928. private _loader;
  65929. private _lights?;
  65930. /** @hidden */
  65931. constructor(loader: GLTFLoader);
  65932. /** @hidden */
  65933. dispose(): void;
  65934. /** @hidden */
  65935. onLoading(): void;
  65936. /** @hidden */
  65937. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  65938. }
  65939. }
  65940. declare module BABYLON.GLTF2.Loader.Extensions {
  65941. /**
  65942. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness)
  65943. */
  65944. export class KHR_materials_pbrSpecularGlossiness implements IGLTFLoaderExtension {
  65945. /** The name of this extension. */
  65946. readonly name: string;
  65947. /** Defines whether this extension is enabled. */
  65948. enabled: boolean;
  65949. private _loader;
  65950. /** @hidden */
  65951. constructor(loader: GLTFLoader);
  65952. /** @hidden */
  65953. dispose(): void;
  65954. /** @hidden */
  65955. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65956. private _loadSpecularGlossinessPropertiesAsync;
  65957. }
  65958. }
  65959. declare module BABYLON.GLTF2.Loader.Extensions {
  65960. /**
  65961. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_unlit)
  65962. */
  65963. export class KHR_materials_unlit implements IGLTFLoaderExtension {
  65964. /** The name of this extension. */
  65965. readonly name: string;
  65966. /** Defines whether this extension is enabled. */
  65967. enabled: boolean;
  65968. private _loader;
  65969. /** @hidden */
  65970. constructor(loader: GLTFLoader);
  65971. /** @hidden */
  65972. dispose(): void;
  65973. /** @hidden */
  65974. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  65975. private _loadUnlitPropertiesAsync;
  65976. }
  65977. }
  65978. declare module BABYLON.GLTF2.Loader.Extensions {
  65979. /**
  65980. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_texture_transform/README.md)
  65981. */
  65982. export class KHR_texture_transform implements IGLTFLoaderExtension {
  65983. /** The name of this extension. */
  65984. readonly name: string;
  65985. /** Defines whether this extension is enabled. */
  65986. enabled: boolean;
  65987. private _loader;
  65988. /** @hidden */
  65989. constructor(loader: GLTFLoader);
  65990. /** @hidden */
  65991. dispose(): void;
  65992. /** @hidden */
  65993. loadTextureInfoAsync(context: string, textureInfo: ITextureInfo, assign: (babylonTexture: BaseTexture) => void): Nullable<Promise<BaseTexture>>;
  65994. }
  65995. }
  65996. declare module BABYLON.GLTF2.Loader.Extensions {
  65997. /**
  65998. * [Specification](https://github.com/najadojo/glTF/tree/MSFT_audio_emitter/extensions/2.0/Vendor/MSFT_audio_emitter)
  65999. */
  66000. export class MSFT_audio_emitter implements IGLTFLoaderExtension {
  66001. /** The name of this extension. */
  66002. readonly name: string;
  66003. /** Defines whether this extension is enabled. */
  66004. enabled: boolean;
  66005. private _loader;
  66006. private _clips;
  66007. private _emitters;
  66008. /** @hidden */
  66009. constructor(loader: GLTFLoader);
  66010. /** @hidden */
  66011. dispose(): void;
  66012. /** @hidden */
  66013. onLoading(): void;
  66014. /** @hidden */
  66015. loadSceneAsync(context: string, scene: IScene): Nullable<Promise<void>>;
  66016. /** @hidden */
  66017. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66018. /** @hidden */
  66019. loadAnimationAsync(context: string, animation: IAnimation): Nullable<Promise<AnimationGroup>>;
  66020. private _loadClipAsync;
  66021. private _loadEmitterAsync;
  66022. private _getEventAction;
  66023. private _loadAnimationEventAsync;
  66024. }
  66025. }
  66026. declare module BABYLON.GLTF2.Loader.Extensions {
  66027. /**
  66028. * [Specification](https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Vendor/MSFT_lod)
  66029. */
  66030. export class MSFT_lod implements IGLTFLoaderExtension {
  66031. /** The name of this extension. */
  66032. readonly name: string;
  66033. /** Defines whether this extension is enabled. */
  66034. enabled: boolean;
  66035. /**
  66036. * Maximum number of LODs to load, starting from the lowest LOD.
  66037. */
  66038. maxLODsToLoad: number;
  66039. /**
  66040. * Observable raised when all node LODs of one level are loaded.
  66041. * The event data is the index of the loaded LOD starting from zero.
  66042. * Dispose the loader to cancel the loading of the next level of LODs.
  66043. */
  66044. onNodeLODsLoadedObservable: Observable<number>;
  66045. /**
  66046. * Observable raised when all material LODs of one level are loaded.
  66047. * The event data is the index of the loaded LOD starting from zero.
  66048. * Dispose the loader to cancel the loading of the next level of LODs.
  66049. */
  66050. onMaterialLODsLoadedObservable: Observable<number>;
  66051. private _loader;
  66052. private _nodeIndexLOD;
  66053. private _nodeSignalLODs;
  66054. private _nodePromiseLODs;
  66055. private _materialIndexLOD;
  66056. private _materialSignalLODs;
  66057. private _materialPromiseLODs;
  66058. /** @hidden */
  66059. constructor(loader: GLTFLoader);
  66060. /** @hidden */
  66061. dispose(): void;
  66062. /** @hidden */
  66063. onReady(): void;
  66064. /** @hidden */
  66065. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66066. /** @hidden */ private _loadMaterialAsync(context: string, material: IMaterial, babylonMesh: Mesh, babylonDrawMode: number, assign: (babylonMaterial: Material) => void): Nullable<Promise<Material>>;
  66067. /** @hidden */ private _loadUriAsync(context: string, property: IProperty, uri: string): Nullable<Promise<ArrayBufferView>>;
  66068. /**
  66069. * Gets an array of LOD properties from lowest to highest.
  66070. */
  66071. private _getLODs;
  66072. private _disposeUnusedMaterials;
  66073. }
  66074. }
  66075. declare module BABYLON.GLTF2.Loader.Extensions {
  66076. /** @hidden */
  66077. export class MSFT_minecraftMesh implements IGLTFLoaderExtension {
  66078. readonly name: string;
  66079. enabled: boolean;
  66080. private _loader;
  66081. constructor(loader: GLTFLoader);
  66082. dispose(): void;
  66083. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66084. }
  66085. }
  66086. declare module BABYLON.GLTF2.Loader.Extensions {
  66087. /** @hidden */
  66088. export class MSFT_sRGBFactors implements IGLTFLoaderExtension {
  66089. readonly name: string;
  66090. enabled: boolean;
  66091. private _loader;
  66092. constructor(loader: GLTFLoader);
  66093. dispose(): void;
  66094. loadMaterialPropertiesAsync(context: string, material: IMaterial, babylonMaterial: Material): Nullable<Promise<void>>;
  66095. }
  66096. }
  66097. declare module BABYLON.GLTF2.Loader.Extensions {
  66098. /**
  66099. * Store glTF extras (if present) in BJS objects' metadata
  66100. */
  66101. export class ExtrasAsMetadata implements IGLTFLoaderExtension {
  66102. /** The name of this extension. */
  66103. readonly name: string;
  66104. /** Defines whether this extension is enabled. */
  66105. enabled: boolean;
  66106. private _loader;
  66107. private _assignExtras;
  66108. /** @hidden */
  66109. constructor(loader: GLTFLoader);
  66110. /** @hidden */
  66111. dispose(): void;
  66112. /** @hidden */
  66113. loadNodeAsync(context: string, node: INode, assign: (babylonTransformNode: TransformNode) => void): Nullable<Promise<TransformNode>>;
  66114. /** @hidden */
  66115. loadCameraAsync(context: string, camera: ICamera, assign: (babylonCamera: Camera) => void): Nullable<Promise<Camera>>;
  66116. /** @hidden */
  66117. createMaterial(context: string, material: IMaterial, babylonDrawMode: number): Nullable<Material>;
  66118. }
  66119. }
  66120. declare module BABYLON {
  66121. /**
  66122. * Class reading and parsing the MTL file bundled with the obj file.
  66123. */
  66124. export class MTLFileLoader {
  66125. /**
  66126. * All material loaded from the mtl will be set here
  66127. */
  66128. materials: StandardMaterial[];
  66129. /**
  66130. * This function will read the mtl file and create each material described inside
  66131. * This function could be improve by adding :
  66132. * -some component missing (Ni, Tf...)
  66133. * -including the specific options available
  66134. *
  66135. * @param scene defines the scene the material will be created in
  66136. * @param data defines the mtl data to parse
  66137. * @param rootUrl defines the rooturl to use in order to load relative dependencies
  66138. */
  66139. parseMTL(scene: Scene, data: string | ArrayBuffer, rootUrl: string): void;
  66140. /**
  66141. * Gets the texture for the material.
  66142. *
  66143. * If the material is imported from input file,
  66144. * We sanitize the url to ensure it takes the textre from aside the material.
  66145. *
  66146. * @param rootUrl The root url to load from
  66147. * @param value The value stored in the mtl
  66148. * @return The Texture
  66149. */
  66150. private static _getTexture;
  66151. }
  66152. /**
  66153. * Options for loading OBJ/MTL files
  66154. */
  66155. type MeshLoadOptions = {
  66156. /**
  66157. * Defines if UVs are optimized by default during load.
  66158. */
  66159. OptimizeWithUV: boolean;
  66160. /**
  66161. * Defines custom scaling of UV coordinates of loaded meshes.
  66162. */
  66163. UVScaling: Vector2;
  66164. /**
  66165. * Invert model on y-axis (does a model scaling inversion)
  66166. */
  66167. InvertY: boolean;
  66168. /**
  66169. * Invert Y-Axis of referenced textures on load
  66170. */
  66171. InvertTextureY: boolean;
  66172. /**
  66173. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66174. */
  66175. ImportVertexColors: boolean;
  66176. /**
  66177. * Compute the normals for the model, even if normals are present in the file.
  66178. */
  66179. ComputeNormals: boolean;
  66180. /**
  66181. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66182. */
  66183. SkipMaterials: boolean;
  66184. /**
  66185. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66186. */
  66187. MaterialLoadingFailsSilently: boolean;
  66188. };
  66189. /**
  66190. * OBJ file type loader.
  66191. * This is a babylon scene loader plugin.
  66192. */
  66193. export class OBJFileLoader implements ISceneLoaderPluginAsync, ISceneLoaderPluginFactory {
  66194. /**
  66195. * Defines if UVs are optimized by default during load.
  66196. */
  66197. static OPTIMIZE_WITH_UV: boolean;
  66198. /**
  66199. * Invert model on y-axis (does a model scaling inversion)
  66200. */
  66201. static INVERT_Y: boolean;
  66202. /**
  66203. * Invert Y-Axis of referenced textures on load
  66204. */
  66205. static INVERT_TEXTURE_Y: boolean;
  66206. /**
  66207. * Include in meshes the vertex colors available in some OBJ files. This is not part of OBJ standard.
  66208. */
  66209. static IMPORT_VERTEX_COLORS: boolean;
  66210. /**
  66211. * Compute the normals for the model, even if normals are present in the file.
  66212. */
  66213. static COMPUTE_NORMALS: boolean;
  66214. /**
  66215. * Defines custom scaling of UV coordinates of loaded meshes.
  66216. */
  66217. static UV_SCALING: Vector2;
  66218. /**
  66219. * Skip loading the materials even if defined in the OBJ file (materials are ignored).
  66220. */
  66221. static SKIP_MATERIALS: boolean;
  66222. /**
  66223. * When a material fails to load OBJ loader will silently fail and onSuccess() callback will be triggered.
  66224. *
  66225. * Defaults to true for backwards compatibility.
  66226. */
  66227. static MATERIAL_LOADING_FAILS_SILENTLY: boolean;
  66228. /**
  66229. * Defines the name of the plugin.
  66230. */
  66231. name: string;
  66232. /**
  66233. * Defines the extension the plugin is able to load.
  66234. */
  66235. extensions: string;
  66236. /** @hidden */
  66237. obj: RegExp;
  66238. /** @hidden */
  66239. group: RegExp;
  66240. /** @hidden */
  66241. mtllib: RegExp;
  66242. /** @hidden */
  66243. usemtl: RegExp;
  66244. /** @hidden */
  66245. smooth: RegExp;
  66246. /** @hidden */
  66247. vertexPattern: RegExp;
  66248. /** @hidden */
  66249. normalPattern: RegExp;
  66250. /** @hidden */
  66251. uvPattern: RegExp;
  66252. /** @hidden */
  66253. facePattern1: RegExp;
  66254. /** @hidden */
  66255. facePattern2: RegExp;
  66256. /** @hidden */
  66257. facePattern3: RegExp;
  66258. /** @hidden */
  66259. facePattern4: RegExp;
  66260. /** @hidden */
  66261. facePattern5: RegExp;
  66262. private _meshLoadOptions;
  66263. /**
  66264. * Creates loader for .OBJ files
  66265. *
  66266. * @param meshLoadOptions options for loading and parsing OBJ/MTL files.
  66267. */
  66268. constructor(meshLoadOptions?: MeshLoadOptions);
  66269. private static readonly currentMeshLoadOptions;
  66270. /**
  66271. * Calls synchronously the MTL file attached to this obj.
  66272. * Load function or importMesh function don't enable to load 2 files in the same time asynchronously.
  66273. * Without this function materials are not displayed in the first frame (but displayed after).
  66274. * In consequence it is impossible to get material information in your HTML file
  66275. *
  66276. * @param url The URL of the MTL file
  66277. * @param rootUrl
  66278. * @param onSuccess Callback function to be called when the MTL file is loaded
  66279. * @private
  66280. */
  66281. private _loadMTL;
  66282. /**
  66283. * Instantiates a OBJ file loader plugin.
  66284. * @returns the created plugin
  66285. */
  66286. createPlugin(): ISceneLoaderPluginAsync | ISceneLoaderPlugin;
  66287. /**
  66288. * If the data string can be loaded directly.
  66289. *
  66290. * @param data string containing the file data
  66291. * @returns if the data can be loaded directly
  66292. */
  66293. canDirectLoad(data: string): boolean;
  66294. /**
  66295. * Imports one or more meshes from the loaded OBJ data and adds them to the scene
  66296. * @param meshesNames a string or array of strings of the mesh names that should be loaded from the file
  66297. * @param scene the scene the meshes should be added to
  66298. * @param data the OBJ data to load
  66299. * @param rootUrl root url to load from
  66300. * @param onProgress event that fires when loading progress has occured
  66301. * @param fileName Defines the name of the file to load
  66302. * @returns a promise containg the loaded meshes, particles, skeletons and animations
  66303. */
  66304. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  66305. meshes: AbstractMesh[];
  66306. particleSystems: IParticleSystem[];
  66307. skeletons: Skeleton[];
  66308. animationGroups: AnimationGroup[];
  66309. }>;
  66310. /**
  66311. * Imports all objects from the loaded OBJ data and adds them to the scene
  66312. * @param scene the scene the objects should be added to
  66313. * @param data the OBJ data to load
  66314. * @param rootUrl root url to load from
  66315. * @param onProgress event that fires when loading progress has occured
  66316. * @param fileName Defines the name of the file to load
  66317. * @returns a promise which completes when objects have been loaded to the scene
  66318. */
  66319. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  66320. /**
  66321. * Load into an asset container.
  66322. * @param scene The scene to load into
  66323. * @param data The data to import
  66324. * @param rootUrl The root url for scene and resources
  66325. * @param onProgress The callback when the load progresses
  66326. * @param fileName Defines the name of the file to load
  66327. * @returns The loaded asset container
  66328. */
  66329. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  66330. /**
  66331. * Read the OBJ file and create an Array of meshes.
  66332. * Each mesh contains all information given by the OBJ and the MTL file.
  66333. * i.e. vertices positions and indices, optional normals values, optional UV values, optional material
  66334. *
  66335. * @param meshesNames
  66336. * @param scene Scene The scene where are displayed the data
  66337. * @param data String The content of the obj file
  66338. * @param rootUrl String The path to the folder
  66339. * @returns Array<AbstractMesh>
  66340. * @private
  66341. */
  66342. private _parseSolid;
  66343. }
  66344. }
  66345. declare module BABYLON {
  66346. /**
  66347. * STL file type loader.
  66348. * This is a babylon scene loader plugin.
  66349. */
  66350. export class STLFileLoader implements ISceneLoaderPlugin {
  66351. /** @hidden */
  66352. solidPattern: RegExp;
  66353. /** @hidden */
  66354. facetsPattern: RegExp;
  66355. /** @hidden */
  66356. normalPattern: RegExp;
  66357. /** @hidden */
  66358. vertexPattern: RegExp;
  66359. /**
  66360. * Defines the name of the plugin.
  66361. */
  66362. name: string;
  66363. /**
  66364. * Defines the extensions the stl loader is able to load.
  66365. * force data to come in as an ArrayBuffer
  66366. * we'll convert to string if it looks like it's an ASCII .stl
  66367. */
  66368. extensions: ISceneLoaderPluginExtensions;
  66369. /**
  66370. * Import meshes into a scene.
  66371. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  66372. * @param scene The scene to import into
  66373. * @param data The data to import
  66374. * @param rootUrl The root url for scene and resources
  66375. * @param meshes The meshes array to import into
  66376. * @param particleSystems The particle systems array to import into
  66377. * @param skeletons The skeletons array to import into
  66378. * @param onError The callback when import fails
  66379. * @returns True if successful or false otherwise
  66380. */
  66381. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: Nullable<AbstractMesh[]>, particleSystems: Nullable<IParticleSystem[]>, skeletons: Nullable<Skeleton[]>): boolean;
  66382. /**
  66383. * Load into a scene.
  66384. * @param scene The scene to load into
  66385. * @param data The data to import
  66386. * @param rootUrl The root url for scene and resources
  66387. * @param onError The callback when import fails
  66388. * @returns true if successful or false otherwise
  66389. */
  66390. load(scene: Scene, data: any, rootUrl: string): boolean;
  66391. /**
  66392. * Load into an asset container.
  66393. * @param scene The scene to load into
  66394. * @param data The data to import
  66395. * @param rootUrl The root url for scene and resources
  66396. * @param onError The callback when import fails
  66397. * @returns The loaded asset container
  66398. */
  66399. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  66400. private _isBinary;
  66401. private _parseBinary;
  66402. private _parseASCII;
  66403. }
  66404. }
  66405. declare module BABYLON {
  66406. /**
  66407. * Class for generating OBJ data from a Babylon scene.
  66408. */
  66409. export class OBJExport {
  66410. /**
  66411. * Exports the geometry of a Mesh array in .OBJ file format (text)
  66412. * @param mesh defines the list of meshes to serialize
  66413. * @param materials defines if materials should be exported
  66414. * @param matlibname defines the name of the associated mtl file
  66415. * @param globalposition defines if the exported positions are globals or local to the exported mesh
  66416. * @returns the OBJ content
  66417. */
  66418. static OBJ(mesh: Mesh[], materials?: boolean, matlibname?: string, globalposition?: boolean): string;
  66419. /**
  66420. * Exports the material(s) of a mesh in .MTL file format (text)
  66421. * @param mesh defines the mesh to extract the material from
  66422. * @returns the mtl content
  66423. */
  66424. static MTL(mesh: Mesh): string;
  66425. }
  66426. }
  66427. declare module BABYLON {
  66428. /** @hidden */
  66429. export var __IGLTFExporterExtension: number;
  66430. /**
  66431. * Interface for extending the exporter
  66432. * @hidden
  66433. */
  66434. export interface IGLTFExporterExtension {
  66435. /**
  66436. * The name of this extension
  66437. */
  66438. readonly name: string;
  66439. /**
  66440. * Defines whether this extension is enabled
  66441. */
  66442. enabled: boolean;
  66443. /**
  66444. * Defines whether this extension is required
  66445. */
  66446. required: boolean;
  66447. }
  66448. }
  66449. declare module BABYLON.GLTF2.Exporter {
  66450. /** @hidden */
  66451. export var __IGLTFExporterExtensionV2: number;
  66452. /**
  66453. * Interface for a glTF exporter extension
  66454. * @hidden
  66455. */
  66456. export interface IGLTFExporterExtensionV2 extends IGLTFExporterExtension, IDisposable {
  66457. /**
  66458. * Define this method to modify the default behavior before exporting a texture
  66459. * @param context The context when loading the asset
  66460. * @param babylonTexture The glTF texture info property
  66461. * @param mimeType The mime-type of the generated image
  66462. * @returns A promise that resolves with the exported glTF texture info when the export is complete, or null if not handled
  66463. */
  66464. preExportTextureAsync?(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  66465. /**
  66466. * Define this method to modify the default behavior when exporting texture info
  66467. * @param context The context when loading the asset
  66468. * @param meshPrimitive glTF mesh primitive
  66469. * @param babylonSubMesh Babylon submesh
  66470. * @param binaryWriter glTF serializer binary writer instance
  66471. * @returns nullable IMeshPrimitive promise
  66472. */
  66473. postExportMeshPrimitiveAsync?(context: string, meshPrimitive: IMeshPrimitive, babylonSubMesh: SubMesh, binaryWriter: _BinaryWriter): Nullable<Promise<IMeshPrimitive>>;
  66474. /**
  66475. * Define this method to modify the default behavior when exporting a node
  66476. * @param context The context when exporting the node
  66477. * @param node glTF node
  66478. * @param babylonNode BabylonJS node
  66479. * @returns nullable INode promise
  66480. */
  66481. postExportNodeAsync?(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  66482. /**
  66483. * Called after the exporter state changes to EXPORTING
  66484. */
  66485. onExporting?(): void;
  66486. }
  66487. }
  66488. declare module BABYLON.GLTF2.Exporter {
  66489. /**
  66490. * Utility methods for working with glTF material conversion properties. This class should only be used internally
  66491. * @hidden
  66492. */
  66493. export class _GLTFMaterialExporter {
  66494. /**
  66495. * Represents the dielectric specular values for R, G and B
  66496. */
  66497. private static readonly _DielectricSpecular;
  66498. /**
  66499. * Allows the maximum specular power to be defined for material calculations
  66500. */
  66501. private static readonly _MaxSpecularPower;
  66502. /**
  66503. * Mapping to store textures
  66504. */
  66505. private _textureMap;
  66506. /**
  66507. * Numeric tolerance value
  66508. */
  66509. private static readonly _Epsilon;
  66510. /**
  66511. * Reference to the glTF Exporter
  66512. */
  66513. private _exporter;
  66514. constructor(exporter: _Exporter);
  66515. /**
  66516. * Specifies if two colors are approximately equal in value
  66517. * @param color1 first color to compare to
  66518. * @param color2 second color to compare to
  66519. * @param epsilon threshold value
  66520. */
  66521. private static FuzzyEquals;
  66522. /**
  66523. * Gets the materials from a Babylon scene and converts them to glTF materials
  66524. * @param scene babylonjs scene
  66525. * @param mimeType texture mime type
  66526. * @param images array of images
  66527. * @param textures array of textures
  66528. * @param materials array of materials
  66529. * @param imageData mapping of texture names to base64 textures
  66530. * @param hasTextureCoords specifies if texture coordinates are present on the material
  66531. */ private _convertMaterialsToGLTFAsync(babylonMaterials: Material[], mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66532. /**
  66533. * Makes a copy of the glTF material without the texture parameters
  66534. * @param originalMaterial original glTF material
  66535. * @returns glTF material without texture parameters
  66536. */ private _stripTexturesFromMaterial(originalMaterial: IMaterial): IMaterial;
  66537. /**
  66538. * Specifies if the material has any texture parameters present
  66539. * @param material glTF Material
  66540. * @returns boolean specifying if texture parameters are present
  66541. */ private _hasTexturesPresent(material: IMaterial): boolean;
  66542. /**
  66543. * Converts a Babylon StandardMaterial to a glTF Metallic Roughness Material
  66544. * @param babylonStandardMaterial
  66545. * @returns glTF Metallic Roughness Material representation
  66546. */ private _convertToGLTFPBRMetallicRoughness(babylonStandardMaterial: StandardMaterial): IMaterialPbrMetallicRoughness;
  66547. /**
  66548. * Computes the metallic factor
  66549. * @param diffuse diffused value
  66550. * @param specular specular value
  66551. * @param oneMinusSpecularStrength one minus the specular strength
  66552. * @returns metallic value
  66553. */ private static _SolveMetallic(diffuse: number, specular: number, oneMinusSpecularStrength: number): number;
  66554. /**
  66555. * Sets the glTF alpha mode to a glTF material from the Babylon Material
  66556. * @param glTFMaterial glTF material
  66557. * @param babylonMaterial Babylon material
  66558. */
  66559. private static _SetAlphaMode;
  66560. /**
  66561. * Converts a Babylon Standard Material to a glTF Material
  66562. * @param babylonStandardMaterial BJS Standard Material
  66563. * @param mimeType mime type to use for the textures
  66564. * @param images array of glTF image interfaces
  66565. * @param textures array of glTF texture interfaces
  66566. * @param materials array of glTF material interfaces
  66567. * @param imageData map of image file name to data
  66568. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66569. */ private _convertStandardMaterialAsync(babylonStandardMaterial: StandardMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66570. /**
  66571. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66572. * @param babylonPBRMetalRoughMaterial BJS PBR Metallic Roughness Material
  66573. * @param mimeType mime type to use for the textures
  66574. * @param images array of glTF image interfaces
  66575. * @param textures array of glTF texture interfaces
  66576. * @param materials array of glTF material interfaces
  66577. * @param imageData map of image file name to data
  66578. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66579. */ private _convertPBRMetallicRoughnessMaterialAsync(babylonPBRMetalRoughMaterial: PBRMetallicRoughnessMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66580. /**
  66581. * Converts an image typed array buffer to a base64 image
  66582. * @param buffer typed array buffer
  66583. * @param width width of the image
  66584. * @param height height of the image
  66585. * @param mimeType mimetype of the image
  66586. * @returns base64 image string
  66587. */
  66588. private _createBase64FromCanvasAsync;
  66589. /**
  66590. * Generates a white texture based on the specified width and height
  66591. * @param width width of the texture in pixels
  66592. * @param height height of the texture in pixels
  66593. * @param scene babylonjs scene
  66594. * @returns white texture
  66595. */
  66596. private _createWhiteTexture;
  66597. /**
  66598. * 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
  66599. * @param texture1 first texture to resize
  66600. * @param texture2 second texture to resize
  66601. * @param scene babylonjs scene
  66602. * @returns resized textures or null
  66603. */
  66604. private _resizeTexturesToSameDimensions;
  66605. /**
  66606. * Converts an array of pixels to a Float32Array
  66607. * Throws an error if the pixel format is not supported
  66608. * @param pixels - array buffer containing pixel values
  66609. * @returns Float32 of pixels
  66610. */
  66611. private _convertPixelArrayToFloat32;
  66612. /**
  66613. * Convert Specular Glossiness Textures to Metallic Roughness
  66614. * See link below for info on the material conversions from PBR Metallic/Roughness and Specular/Glossiness
  66615. * @link https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness/examples/convert-between-workflows-bjs/js/babylon.pbrUtilities.js
  66616. * @param diffuseTexture texture used to store diffuse information
  66617. * @param specularGlossinessTexture texture used to store specular and glossiness information
  66618. * @param factors specular glossiness material factors
  66619. * @param mimeType the mime type to use for the texture
  66620. * @returns pbr metallic roughness interface or null
  66621. */
  66622. private _convertSpecularGlossinessTexturesToMetallicRoughnessAsync;
  66623. /**
  66624. * Converts specular glossiness material properties to metallic roughness
  66625. * @param specularGlossiness interface with specular glossiness material properties
  66626. * @returns interface with metallic roughness material properties
  66627. */
  66628. private _convertSpecularGlossinessToMetallicRoughness;
  66629. /**
  66630. * Calculates the surface reflectance, independent of lighting conditions
  66631. * @param color Color source to calculate brightness from
  66632. * @returns number representing the perceived brightness, or zero if color is undefined
  66633. */
  66634. private _getPerceivedBrightness;
  66635. /**
  66636. * Returns the maximum color component value
  66637. * @param color
  66638. * @returns maximum color component value, or zero if color is null or undefined
  66639. */
  66640. private _getMaxComponent;
  66641. /**
  66642. * Convert a PBRMaterial (Metallic/Roughness) to Metallic Roughness factors
  66643. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66644. * @param mimeType mime type to use for the textures
  66645. * @param images array of glTF image interfaces
  66646. * @param textures array of glTF texture interfaces
  66647. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66648. * @param imageData map of image file name to data
  66649. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66650. * @returns glTF PBR Metallic Roughness factors
  66651. */
  66652. private _convertMetalRoughFactorsToMetallicRoughnessAsync;
  66653. private _getGLTFTextureSampler;
  66654. private _getGLTFTextureWrapMode;
  66655. private _getGLTFTextureWrapModesSampler;
  66656. /**
  66657. * Convert a PBRMaterial (Specular/Glossiness) to Metallic Roughness factors
  66658. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66659. * @param mimeType mime type to use for the textures
  66660. * @param images array of glTF image interfaces
  66661. * @param textures array of glTF texture interfaces
  66662. * @param glTFPbrMetallicRoughness glTF PBR Metallic Roughness interface
  66663. * @param imageData map of image file name to data
  66664. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66665. * @returns glTF PBR Metallic Roughness factors
  66666. */
  66667. private _convertSpecGlossFactorsToMetallicRoughnessAsync;
  66668. /**
  66669. * Converts a Babylon PBR Metallic Roughness Material to a glTF Material
  66670. * @param babylonPBRMaterial BJS PBR Metallic Roughness Material
  66671. * @param mimeType mime type to use for the textures
  66672. * @param images array of glTF image interfaces
  66673. * @param textures array of glTF texture interfaces
  66674. * @param materials array of glTF material interfaces
  66675. * @param imageData map of image file name to data
  66676. * @param hasTextureCoords specifies if texture coordinates are present on the submesh to determine if textures should be applied
  66677. */ private _convertPBRMaterialAsync(babylonPBRMaterial: PBRMaterial, mimeType: ImageMimeType, hasTextureCoords: boolean): Promise<void>;
  66678. private setMetallicRoughnessPbrMaterial;
  66679. private getPixelsFromTexture;
  66680. /**
  66681. * Extracts a texture from a Babylon texture into file data and glTF data
  66682. * @param babylonTexture Babylon texture to extract
  66683. * @param mimeType Mime Type of the babylonTexture
  66684. * @return glTF texture info, or null if the texture format is not supported
  66685. */ private _exportTextureAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>; private _exportTextureInfoAsync(babylonTexture: BaseTexture, mimeType: ImageMimeType): Promise<Nullable<ITextureInfo>>;
  66686. /**
  66687. * Builds a texture from base64 string
  66688. * @param base64Texture base64 texture string
  66689. * @param baseTextureName Name to use for the texture
  66690. * @param mimeType image mime type for the texture
  66691. * @param images array of images
  66692. * @param textures array of textures
  66693. * @param imageData map of image data
  66694. * @returns glTF texture info, or null if the texture format is not supported
  66695. */
  66696. private _getTextureInfoFromBase64;
  66697. }
  66698. }
  66699. declare module BABYLON {
  66700. /**
  66701. * Class for holding and downloading glTF file data
  66702. */
  66703. export class GLTFData {
  66704. /**
  66705. * Object which contains the file name as the key and its data as the value
  66706. */
  66707. glTFFiles: {
  66708. [fileName: string]: string | Blob;
  66709. };
  66710. /**
  66711. * Initializes the glTF file object
  66712. */
  66713. constructor();
  66714. /**
  66715. * Downloads the glTF data as files based on their names and data
  66716. */
  66717. downloadFiles(): void;
  66718. }
  66719. }
  66720. declare module BABYLON {
  66721. /**
  66722. * Holds a collection of exporter options and parameters
  66723. */
  66724. export interface IExportOptions {
  66725. /**
  66726. * Function which indicates whether a babylon node should be exported or not
  66727. * @param node source Babylon node. It is used to check whether it should be exported to glTF or not
  66728. * @returns boolean, which indicates whether the node should be exported (true) or not (false)
  66729. */
  66730. shouldExportNode?(node: Node): boolean;
  66731. /**
  66732. * Function used to extract the part of node's metadata that will be exported into glTF node extras
  66733. * @param metadata source metadata to read from
  66734. * @returns the data to store to glTF node extras
  66735. */
  66736. metadataSelector?(metadata: any): any;
  66737. /**
  66738. * The sample rate to bake animation curves
  66739. */
  66740. animationSampleRate?: number;
  66741. /**
  66742. * Begin serialization without waiting for the scene to be ready
  66743. */
  66744. exportWithoutWaitingForScene?: boolean;
  66745. }
  66746. /**
  66747. * Class for generating glTF data from a Babylon scene.
  66748. */
  66749. export class GLTF2Export {
  66750. /**
  66751. * Exports the geometry of the scene to .gltf file format asynchronously
  66752. * @param scene Babylon scene with scene hierarchy information
  66753. * @param filePrefix File prefix to use when generating the glTF file
  66754. * @param options Exporter options
  66755. * @returns Returns an object with a .gltf file and associates texture names
  66756. * as keys and their data and paths as values
  66757. */
  66758. static GLTFAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66759. private static _PreExportAsync;
  66760. private static _PostExportAsync;
  66761. /**
  66762. * Exports the geometry of the scene to .glb file format asychronously
  66763. * @param scene Babylon scene with scene hierarchy information
  66764. * @param filePrefix File prefix to use when generating glb file
  66765. * @param options Exporter options
  66766. * @returns Returns an object with a .glb filename as key and data as value
  66767. */
  66768. static GLBAsync(scene: Scene, filePrefix: string, options?: IExportOptions): Promise<GLTFData>;
  66769. }
  66770. }
  66771. declare module BABYLON.GLTF2.Exporter {
  66772. /**
  66773. * @hidden
  66774. */
  66775. export class _GLTFUtilities {
  66776. /**
  66777. * Creates a buffer view based on the supplied arguments
  66778. * @param bufferIndex index value of the specified buffer
  66779. * @param byteOffset byte offset value
  66780. * @param byteLength byte length of the bufferView
  66781. * @param byteStride byte distance between conequential elements
  66782. * @param name name of the buffer view
  66783. * @returns bufferView for glTF
  66784. */ private static _CreateBufferView(bufferIndex: number, byteOffset: number, byteLength: number, byteStride?: number, name?: string): IBufferView;
  66785. /**
  66786. * Creates an accessor based on the supplied arguments
  66787. * @param bufferviewIndex The index of the bufferview referenced by this accessor
  66788. * @param name The name of the accessor
  66789. * @param type The type of the accessor
  66790. * @param componentType The datatype of components in the attribute
  66791. * @param count The number of attributes referenced by this accessor
  66792. * @param byteOffset The offset relative to the start of the bufferView in bytes
  66793. * @param min Minimum value of each component in this attribute
  66794. * @param max Maximum value of each component in this attribute
  66795. * @returns accessor for glTF
  66796. */ private static _CreateAccessor(bufferviewIndex: number, name: string, type: AccessorType, componentType: AccessorComponentType, count: number, byteOffset: Nullable<number>, min: Nullable<number[]>, max: Nullable<number[]>): IAccessor;
  66797. /**
  66798. * Calculates the minimum and maximum values of an array of position floats
  66799. * @param positions Positions array of a mesh
  66800. * @param vertexStart Starting vertex offset to calculate min and max values
  66801. * @param vertexCount Number of vertices to check for min and max values
  66802. * @returns min number array and max number array
  66803. */ private static _CalculateMinMaxPositions(positions: FloatArray, vertexStart: number, vertexCount: number, convertToRightHandedSystem: boolean): {
  66804. min: number[];
  66805. max: number[];
  66806. };
  66807. /**
  66808. * Converts a new right-handed Vector3
  66809. * @param vector vector3 array
  66810. * @returns right-handed Vector3
  66811. */ private static _GetRightHandedPositionVector3(vector: Vector3): Vector3;
  66812. /**
  66813. * Converts a Vector3 to right-handed
  66814. * @param vector Vector3 to convert to right-handed
  66815. */ private static _GetRightHandedPositionVector3FromRef(vector: Vector3): void;
  66816. /**
  66817. * Converts a three element number array to right-handed
  66818. * @param vector number array to convert to right-handed
  66819. */ private static _GetRightHandedPositionArray3FromRef(vector: number[]): void;
  66820. /**
  66821. * Converts a new right-handed Vector3
  66822. * @param vector vector3 array
  66823. * @returns right-handed Vector3
  66824. */ private static _GetRightHandedNormalVector3(vector: Vector3): Vector3;
  66825. /**
  66826. * Converts a Vector3 to right-handed
  66827. * @param vector Vector3 to convert to right-handed
  66828. */ private static _GetRightHandedNormalVector3FromRef(vector: Vector3): void;
  66829. /**
  66830. * Converts a three element number array to right-handed
  66831. * @param vector number array to convert to right-handed
  66832. */ private static _GetRightHandedNormalArray3FromRef(vector: number[]): void;
  66833. /**
  66834. * Converts a Vector4 to right-handed
  66835. * @param vector Vector4 to convert to right-handed
  66836. */ private static _GetRightHandedVector4FromRef(vector: Vector4): void;
  66837. /**
  66838. * Converts a Vector4 to right-handed
  66839. * @param vector Vector4 to convert to right-handed
  66840. */ private static _GetRightHandedArray4FromRef(vector: number[]): void;
  66841. /**
  66842. * Converts a Quaternion to right-handed
  66843. * @param quaternion Source quaternion to convert to right-handed
  66844. */ private static _GetRightHandedQuaternionFromRef(quaternion: Quaternion): void;
  66845. /**
  66846. * Converts a Quaternion to right-handed
  66847. * @param quaternion Source quaternion to convert to right-handed
  66848. */ private static _GetRightHandedQuaternionArrayFromRef(quaternion: number[]): void; private static _NormalizeTangentFromRef(tangent: Vector4): void;
  66849. }
  66850. }
  66851. declare module BABYLON.GLTF2.Exporter {
  66852. /**
  66853. * Converts Babylon Scene into glTF 2.0.
  66854. * @hidden
  66855. */
  66856. export class _Exporter {
  66857. /**
  66858. * Stores the glTF to export
  66859. */ private _glTF: IGLTF;
  66860. /**
  66861. * Stores all generated buffer views, which represents views into the main glTF buffer data
  66862. */ private _bufferViews: IBufferView[];
  66863. /**
  66864. * Stores all the generated accessors, which is used for accessing the data within the buffer views in glTF
  66865. */ private _accessors: IAccessor[];
  66866. /**
  66867. * Stores all the generated nodes, which contains transform and/or mesh information per node
  66868. */
  66869. private _nodes;
  66870. /**
  66871. * Stores all the generated glTF scenes, which stores multiple node hierarchies
  66872. */
  66873. private _scenes;
  66874. /**
  66875. * Stores all the generated mesh information, each containing a set of primitives to render in glTF
  66876. */
  66877. private _meshes;
  66878. /**
  66879. * Stores all the generated material information, which represents the appearance of each primitive
  66880. */ private _materials: IMaterial[]; private _materialMap: {
  66881. [materialID: number]: number;
  66882. };
  66883. /**
  66884. * Stores all the generated texture information, which is referenced by glTF materials
  66885. */ private _textures: ITexture[];
  66886. /**
  66887. * Stores all the generated image information, which is referenced by glTF textures
  66888. */ private _images: IImage[];
  66889. /**
  66890. * Stores all the texture samplers
  66891. */ private _samplers: ISampler[];
  66892. /**
  66893. * Stores all the generated animation samplers, which is referenced by glTF animations
  66894. */
  66895. /**
  66896. * Stores the animations for glTF models
  66897. */
  66898. private _animations;
  66899. /**
  66900. * Stores the total amount of bytes stored in the glTF buffer
  66901. */
  66902. private _totalByteLength;
  66903. /**
  66904. * Stores a reference to the Babylon scene containing the source geometry and material information
  66905. */ private _babylonScene: Scene;
  66906. /**
  66907. * Stores a map of the image data, where the key is the file name and the value
  66908. * is the image data
  66909. */ private _imageData: {
  66910. [fileName: string]: {
  66911. data: Uint8Array;
  66912. mimeType: ImageMimeType;
  66913. };
  66914. };
  66915. /**
  66916. * Stores a map of the unique id of a node to its index in the node array
  66917. */
  66918. private _nodeMap;
  66919. /**
  66920. * Specifies if the Babylon scene should be converted to right-handed on export
  66921. */ private _convertToRightHandedSystem: boolean;
  66922. /**
  66923. * Baked animation sample rate
  66924. */
  66925. private _animationSampleRate;
  66926. private _options;
  66927. private _localEngine; private _glTFMaterialExporter: _GLTFMaterialExporter;
  66928. private _extensions;
  66929. private static _ExtensionNames;
  66930. private static _ExtensionFactories;
  66931. 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>>;
  66932. private _forEachExtensions;
  66933. private _extensionsOnExporting;
  66934. /**
  66935. * Load glTF serializer extensions
  66936. */
  66937. private _loadExtensions;
  66938. /**
  66939. * Creates a glTF Exporter instance, which can accept optional exporter options
  66940. * @param babylonScene Babylon scene object
  66941. * @param options Options to modify the behavior of the exporter
  66942. */
  66943. constructor(babylonScene: Scene, options?: IExportOptions);
  66944. /**
  66945. * Registers a glTF exporter extension
  66946. * @param name Name of the extension to export
  66947. * @param factory The factory function that creates the exporter extension
  66948. */
  66949. static RegisterExtension(name: string, factory: (exporter: _Exporter) => IGLTFExporterExtensionV2): void;
  66950. /**
  66951. * Un-registers an exporter extension
  66952. * @param name The name fo the exporter extension
  66953. * @returns A boolean indicating whether the extension has been un-registered
  66954. */
  66955. static UnregisterExtension(name: string): boolean;
  66956. /**
  66957. * Lazy load a local engine with premultiplied alpha set to false
  66958. */ private _getLocalEngine(): Engine;
  66959. private reorderIndicesBasedOnPrimitiveMode;
  66960. /**
  66961. * Reorders the vertex attribute data based on the primitive mode. This is necessary when indices are not available and the winding order is
  66962. * clock-wise during export to glTF
  66963. * @param submesh BabylonJS submesh
  66964. * @param primitiveMode Primitive mode of the mesh
  66965. * @param sideOrientation the winding order of the submesh
  66966. * @param vertexBufferKind The type of vertex attribute
  66967. * @param meshAttributeArray The vertex attribute data
  66968. * @param byteOffset The offset to the binary data
  66969. * @param binaryWriter The binary data for the glTF file
  66970. */
  66971. private reorderVertexAttributeDataBasedOnPrimitiveMode;
  66972. /**
  66973. * Reorders the vertex attributes in the correct triangle mode order . This is necessary when indices are not available and the winding order is
  66974. * clock-wise during export to glTF
  66975. * @param submesh BabylonJS submesh
  66976. * @param primitiveMode Primitive mode of the mesh
  66977. * @param sideOrientation the winding order of the submesh
  66978. * @param vertexBufferKind The type of vertex attribute
  66979. * @param meshAttributeArray The vertex attribute data
  66980. * @param byteOffset The offset to the binary data
  66981. * @param binaryWriter The binary data for the glTF file
  66982. */
  66983. private reorderTriangleFillMode;
  66984. /**
  66985. * Reorders the vertex attributes in the correct triangle strip order. This is necessary when indices are not available and the winding order is
  66986. * clock-wise during export to glTF
  66987. * @param submesh BabylonJS submesh
  66988. * @param primitiveMode Primitive mode of the mesh
  66989. * @param sideOrientation the winding order of the submesh
  66990. * @param vertexBufferKind The type of vertex attribute
  66991. * @param meshAttributeArray The vertex attribute data
  66992. * @param byteOffset The offset to the binary data
  66993. * @param binaryWriter The binary data for the glTF file
  66994. */
  66995. private reorderTriangleStripDrawMode;
  66996. /**
  66997. * Reorders the vertex attributes in the correct triangle fan order. This is necessary when indices are not available and the winding order is
  66998. * clock-wise during export to glTF
  66999. * @param submesh BabylonJS submesh
  67000. * @param primitiveMode Primitive mode of the mesh
  67001. * @param sideOrientation the winding order of the submesh
  67002. * @param vertexBufferKind The type of vertex attribute
  67003. * @param meshAttributeArray The vertex attribute data
  67004. * @param byteOffset The offset to the binary data
  67005. * @param binaryWriter The binary data for the glTF file
  67006. */
  67007. private reorderTriangleFanMode;
  67008. /**
  67009. * Writes the vertex attribute data to binary
  67010. * @param vertices The vertices to write to the binary writer
  67011. * @param byteOffset The offset into the binary writer to overwrite binary data
  67012. * @param vertexAttributeKind The vertex attribute type
  67013. * @param meshAttributeArray The vertex attribute data
  67014. * @param binaryWriter The writer containing the binary data
  67015. */
  67016. private writeVertexAttributeData;
  67017. /**
  67018. * Writes mesh attribute data to a data buffer
  67019. * Returns the bytelength of the data
  67020. * @param vertexBufferKind Indicates what kind of vertex data is being passed in
  67021. * @param meshAttributeArray Array containing the attribute data
  67022. * @param binaryWriter The buffer to write the binary data to
  67023. * @param indices Used to specify the order of the vertex data
  67024. */
  67025. writeAttributeData(vertexBufferKind: string, meshAttributeArray: FloatArray, byteStride: number, binaryWriter: _BinaryWriter): void;
  67026. /**
  67027. * Generates glTF json data
  67028. * @param shouldUseGlb Indicates whether the json should be written for a glb file
  67029. * @param glTFPrefix Text to use when prefixing a glTF file
  67030. * @param prettyPrint Indicates whether the json file should be pretty printed (true) or not (false)
  67031. * @returns json data as string
  67032. */
  67033. private generateJSON;
  67034. /**
  67035. * Generates data for .gltf and .bin files based on the glTF prefix string
  67036. * @param glTFPrefix Text to use when prefixing a glTF file
  67037. * @returns GLTFData with glTF file data
  67038. */ private _generateGLTFAsync(glTFPrefix: string): Promise<GLTFData>;
  67039. /**
  67040. * Creates a binary buffer for glTF
  67041. * @returns array buffer for binary data
  67042. */
  67043. private _generateBinaryAsync;
  67044. /**
  67045. * Pads the number to a multiple of 4
  67046. * @param num number to pad
  67047. * @returns padded number
  67048. */
  67049. private _getPadding;
  67050. /**
  67051. * Generates a glb file from the json and binary data
  67052. * Returns an object with the glb file name as the key and data as the value
  67053. * @param glTFPrefix
  67054. * @returns object with glb filename as key and data as value
  67055. */ private _generateGLBAsync(glTFPrefix: string): Promise<GLTFData>;
  67056. /**
  67057. * Sets the TRS for each node
  67058. * @param node glTF Node for storing the transformation data
  67059. * @param babylonTransformNode Babylon mesh used as the source for the transformation data
  67060. */
  67061. private setNodeTransformation;
  67062. private getVertexBufferFromMesh;
  67063. /**
  67064. * Creates a bufferview based on the vertices type for the Babylon mesh
  67065. * @param kind Indicates the type of vertices data
  67066. * @param babylonTransformNode The Babylon mesh to get the vertices data from
  67067. * @param binaryWriter The buffer to write the bufferview data to
  67068. */
  67069. private createBufferViewKind;
  67070. /**
  67071. * The primitive mode of the Babylon mesh
  67072. * @param babylonMesh The BabylonJS mesh
  67073. */
  67074. private getMeshPrimitiveMode;
  67075. /**
  67076. * Sets the primitive mode of the glTF mesh primitive
  67077. * @param meshPrimitive glTF mesh primitive
  67078. * @param primitiveMode The primitive mode
  67079. */
  67080. private setPrimitiveMode;
  67081. /**
  67082. * Sets the vertex attribute accessor based of the glTF mesh primitive
  67083. * @param meshPrimitive glTF mesh primitive
  67084. * @param attributeKind vertex attribute
  67085. * @returns boolean specifying if uv coordinates are present
  67086. */
  67087. private setAttributeKind;
  67088. /**
  67089. * Sets data for the primitive attributes of each submesh
  67090. * @param mesh glTF Mesh object to store the primitive attribute information
  67091. * @param babylonTransformNode Babylon mesh to get the primitive attribute data from
  67092. * @param binaryWriter Buffer to write the attribute data to
  67093. */
  67094. private setPrimitiveAttributesAsync;
  67095. /**
  67096. * Creates a glTF scene based on the array of meshes
  67097. * Returns the the total byte offset
  67098. * @param babylonScene Babylon scene to get the mesh data from
  67099. * @param binaryWriter Buffer to write binary data to
  67100. */
  67101. private createSceneAsync;
  67102. /**
  67103. * Creates a mapping of Node unique id to node index and handles animations
  67104. * @param babylonScene Babylon Scene
  67105. * @param nodes Babylon transform nodes
  67106. * @param binaryWriter Buffer to write binary data to
  67107. * @returns Node mapping of unique id to index
  67108. */
  67109. private createNodeMapAndAnimationsAsync;
  67110. /**
  67111. * Creates a glTF node from a Babylon mesh
  67112. * @param babylonMesh Source Babylon mesh
  67113. * @param binaryWriter Buffer for storing geometry data
  67114. * @returns glTF node
  67115. */
  67116. private createNodeAsync;
  67117. }
  67118. /**
  67119. * @hidden
  67120. *
  67121. * Stores glTF binary data. If the array buffer byte length is exceeded, it doubles in size dynamically
  67122. */
  67123. export class _BinaryWriter {
  67124. /**
  67125. * Array buffer which stores all binary data
  67126. */
  67127. private _arrayBuffer;
  67128. /**
  67129. * View of the array buffer
  67130. */
  67131. private _dataView;
  67132. /**
  67133. * byte offset of data in array buffer
  67134. */
  67135. private _byteOffset;
  67136. /**
  67137. * Initialize binary writer with an initial byte length
  67138. * @param byteLength Initial byte length of the array buffer
  67139. */
  67140. constructor(byteLength: number);
  67141. /**
  67142. * Resize the array buffer to the specified byte length
  67143. * @param byteLength
  67144. */
  67145. private resizeBuffer;
  67146. /**
  67147. * Get an array buffer with the length of the byte offset
  67148. * @returns ArrayBuffer resized to the byte offset
  67149. */
  67150. getArrayBuffer(): ArrayBuffer;
  67151. /**
  67152. * Get the byte offset of the array buffer
  67153. * @returns byte offset
  67154. */
  67155. getByteOffset(): number;
  67156. /**
  67157. * Stores an UInt8 in the array buffer
  67158. * @param entry
  67159. * @param byteOffset If defined, specifies where to set the value as an offset.
  67160. */
  67161. setUInt8(entry: number, byteOffset?: number): void;
  67162. /**
  67163. * Gets an UInt32 in the array buffer
  67164. * @param entry
  67165. * @param byteOffset If defined, specifies where to set the value as an offset.
  67166. */
  67167. getUInt32(byteOffset: number): number;
  67168. getVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67169. setVector3Float32FromRef(vector3: Vector3, byteOffset: number): void;
  67170. getVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67171. setVector4Float32FromRef(vector4: Vector4, byteOffset: number): void;
  67172. /**
  67173. * Stores a Float32 in the array buffer
  67174. * @param entry
  67175. */
  67176. setFloat32(entry: number, byteOffset?: number): void;
  67177. /**
  67178. * Stores an UInt32 in the array buffer
  67179. * @param entry
  67180. * @param byteOffset If defined, specifies where to set the value as an offset.
  67181. */
  67182. setUInt32(entry: number, byteOffset?: number): void;
  67183. }
  67184. }
  67185. declare module BABYLON.GLTF2.Exporter {
  67186. /**
  67187. * @hidden
  67188. * Interface to store animation data.
  67189. */
  67190. export interface _IAnimationData {
  67191. /**
  67192. * Keyframe data.
  67193. */
  67194. inputs: number[];
  67195. /**
  67196. * Value data.
  67197. */
  67198. outputs: number[][];
  67199. /**
  67200. * Animation interpolation data.
  67201. */
  67202. samplerInterpolation: AnimationSamplerInterpolation;
  67203. /**
  67204. * Minimum keyframe value.
  67205. */
  67206. inputsMin: number;
  67207. /**
  67208. * Maximum keyframe value.
  67209. */
  67210. inputsMax: number;
  67211. }
  67212. /**
  67213. * @hidden
  67214. */
  67215. export interface _IAnimationInfo {
  67216. /**
  67217. * The target channel for the animation
  67218. */
  67219. animationChannelTargetPath: AnimationChannelTargetPath;
  67220. /**
  67221. * The glTF accessor type for the data.
  67222. */
  67223. dataAccessorType: AccessorType.VEC3 | AccessorType.VEC4;
  67224. /**
  67225. * Specifies if quaternions should be used.
  67226. */
  67227. useQuaternion: boolean;
  67228. }
  67229. /**
  67230. * @hidden
  67231. * Utility class for generating glTF animation data from BabylonJS.
  67232. */
  67233. export class _GLTFAnimation {
  67234. /**
  67235. * @ignore
  67236. *
  67237. * Creates glTF channel animation from BabylonJS animation.
  67238. * @param babylonTransformNode - BabylonJS mesh.
  67239. * @param animation - animation.
  67240. * @param animationChannelTargetPath - The target animation channel.
  67241. * @param convertToRightHandedSystem - Specifies if the values should be converted to right-handed.
  67242. * @param useQuaternion - Specifies if quaternions are used.
  67243. * @returns nullable IAnimationData
  67244. */ private static _CreateNodeAnimation(babylonTransformNode: TransformNode, animation: Animation, animationChannelTargetPath: AnimationChannelTargetPath, convertToRightHandedSystem: boolean, useQuaternion: boolean, animationSampleRate: number): Nullable<_IAnimationData>;
  67245. private static _DeduceAnimationInfo;
  67246. /**
  67247. * @ignore
  67248. * Create node animations from the transform node animations
  67249. * @param babylonNode
  67250. * @param runtimeGLTFAnimation
  67251. * @param idleGLTFAnimations
  67252. * @param nodeMap
  67253. * @param nodes
  67254. * @param binaryWriter
  67255. * @param bufferViews
  67256. * @param accessors
  67257. * @param convertToRightHandedSystem
  67258. */ private static _CreateNodeAnimationFromNodeAnimations(babylonNode: Node, runtimeGLTFAnimation: IAnimation, idleGLTFAnimations: IAnimation[], nodeMap: {
  67259. [key: number]: number;
  67260. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67261. /**
  67262. * @ignore
  67263. * Create node animations from the animation groups
  67264. * @param babylonScene
  67265. * @param glTFAnimations
  67266. * @param nodeMap
  67267. * @param nodes
  67268. * @param binaryWriter
  67269. * @param bufferViews
  67270. * @param accessors
  67271. * @param convertToRightHandedSystem
  67272. */ private static _CreateNodeAnimationFromAnimationGroups(babylonScene: Scene, glTFAnimations: IAnimation[], nodeMap: {
  67273. [key: number]: number;
  67274. }, nodes: INode[], binaryWriter: _BinaryWriter, bufferViews: IBufferView[], accessors: IAccessor[], convertToRightHandedSystem: boolean, animationSampleRate: number): void;
  67275. private static AddAnimation;
  67276. /**
  67277. * Create a baked animation
  67278. * @param babylonTransformNode BabylonJS mesh
  67279. * @param animation BabylonJS animation corresponding to the BabylonJS mesh
  67280. * @param animationChannelTargetPath animation target channel
  67281. * @param minFrame minimum animation frame
  67282. * @param maxFrame maximum animation frame
  67283. * @param fps frames per second of the animation
  67284. * @param inputs input key frames of the animation
  67285. * @param outputs output key frame data of the animation
  67286. * @param convertToRightHandedSystem converts the values to right-handed
  67287. * @param useQuaternion specifies if quaternions should be used
  67288. */
  67289. private static _CreateBakedAnimation;
  67290. private static _ConvertFactorToVector3OrQuaternion;
  67291. private static _SetInterpolatedValue;
  67292. /**
  67293. * Creates linear animation from the animation key frames
  67294. * @param babylonTransformNode BabylonJS mesh
  67295. * @param animation BabylonJS animation
  67296. * @param animationChannelTargetPath The target animation channel
  67297. * @param frameDelta The difference between the last and first frame of the animation
  67298. * @param inputs Array to store the key frame times
  67299. * @param outputs Array to store the key frame data
  67300. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67301. * @param useQuaternion Specifies if quaternions are used in the animation
  67302. */
  67303. private static _CreateLinearOrStepAnimation;
  67304. /**
  67305. * Creates cubic spline animation from the animation key frames
  67306. * @param babylonTransformNode BabylonJS mesh
  67307. * @param animation BabylonJS animation
  67308. * @param animationChannelTargetPath The target animation channel
  67309. * @param frameDelta The difference between the last and first frame of the animation
  67310. * @param inputs Array to store the key frame times
  67311. * @param outputs Array to store the key frame data
  67312. * @param convertToRightHandedSystem Specifies if the position data should be converted to right handed
  67313. * @param useQuaternion Specifies if quaternions are used in the animation
  67314. */
  67315. private static _CreateCubicSplineAnimation;
  67316. private static _GetBasePositionRotationOrScale;
  67317. /**
  67318. * Adds a key frame value
  67319. * @param keyFrame
  67320. * @param animation
  67321. * @param outputs
  67322. * @param animationChannelTargetPath
  67323. * @param basePositionRotationOrScale
  67324. * @param convertToRightHandedSystem
  67325. * @param useQuaternion
  67326. */
  67327. private static _AddKeyframeValue;
  67328. /**
  67329. * Determine the interpolation based on the key frames
  67330. * @param keyFrames
  67331. * @param animationChannelTargetPath
  67332. * @param useQuaternion
  67333. */
  67334. private static _DeduceInterpolation;
  67335. /**
  67336. * Adds an input tangent or output tangent to the output data
  67337. * If an input tangent or output tangent is missing, it uses the zero vector or zero quaternion
  67338. * @param tangentType Specifies which type of tangent to handle (inTangent or outTangent)
  67339. * @param outputs The animation data by keyframe
  67340. * @param animationChannelTargetPath The target animation channel
  67341. * @param interpolation The interpolation type
  67342. * @param keyFrame The key frame with the animation data
  67343. * @param frameDelta Time difference between two frames used to scale the tangent by the frame delta
  67344. * @param useQuaternion Specifies if quaternions are used
  67345. * @param convertToRightHandedSystem Specifies if the values should be converted to right-handed
  67346. */
  67347. private static AddSplineTangent;
  67348. /**
  67349. * Get the minimum and maximum key frames' frame values
  67350. * @param keyFrames animation key frames
  67351. * @returns the minimum and maximum key frame value
  67352. */
  67353. private static calculateMinMaxKeyFrames;
  67354. }
  67355. }
  67356. declare module BABYLON.GLTF2.Exporter {
  67357. /** @hidden */
  67358. export var textureTransformPixelShader: {
  67359. name: string;
  67360. shader: string;
  67361. };
  67362. }
  67363. declare module BABYLON.GLTF2.Exporter.Extensions {
  67364. /**
  67365. * @hidden
  67366. */
  67367. export class KHR_texture_transform implements IGLTFExporterExtensionV2 {
  67368. /** Name of this extension */
  67369. readonly name: string;
  67370. /** Defines whether this extension is enabled */
  67371. enabled: boolean;
  67372. /** Defines whether this extension is required */
  67373. required: boolean;
  67374. /** Reference to the glTF exporter */
  67375. private _exporter;
  67376. constructor(exporter: _Exporter);
  67377. dispose(): void;
  67378. preExportTextureAsync(context: string, babylonTexture: Texture, mimeType: ImageMimeType): Nullable<Promise<Texture>>;
  67379. /**
  67380. * Transform the babylon texture by the offset, rotation and scale parameters using a procedural texture
  67381. * @param babylonTexture
  67382. * @param offset
  67383. * @param rotation
  67384. * @param scale
  67385. * @param scene
  67386. */
  67387. private _textureTransformTextureAsync;
  67388. }
  67389. }
  67390. declare module BABYLON.GLTF2.Exporter.Extensions {
  67391. /**
  67392. * [Specification](https://github.com/KhronosGroup/glTF/blob/master/extensions/2.0/Khronos/KHR_lights_punctual/README.md)
  67393. */
  67394. export class KHR_lights_punctual implements IGLTFExporterExtensionV2 {
  67395. /** The name of this extension. */
  67396. readonly name: string;
  67397. /** Defines whether this extension is enabled. */
  67398. enabled: boolean;
  67399. /** Defines whether this extension is required */
  67400. required: boolean;
  67401. /** Reference to the glTF exporter */
  67402. private _exporter;
  67403. private _lights;
  67404. /** @hidden */
  67405. constructor(exporter: _Exporter);
  67406. /** @hidden */
  67407. dispose(): void;
  67408. /** @hidden */
  67409. onExporting(): void;
  67410. /**
  67411. * Define this method to modify the default behavior when exporting a node
  67412. * @param context The context when exporting the node
  67413. * @param node glTF node
  67414. * @param babylonNode BabylonJS node
  67415. * @returns nullable INode promise
  67416. */
  67417. postExportNodeAsync(context: string, node: INode, babylonNode: Node): Nullable<Promise<INode>>;
  67418. }
  67419. }
  67420. declare module BABYLON {
  67421. /**
  67422. * Class for generating STL data from a Babylon scene.
  67423. */
  67424. export class STLExport {
  67425. /**
  67426. * Exports the geometry of a Mesh array in .STL file format (ASCII)
  67427. * @param meshes list defines the mesh to serialize
  67428. * @param download triggers the automatic download of the file.
  67429. * @param fileName changes the downloads fileName.
  67430. * @param binary changes the STL to a binary type.
  67431. * @param isLittleEndian toggle for binary type exporter.
  67432. * @returns the STL as UTF8 string
  67433. */
  67434. static CreateSTL(meshes: Mesh[], download?: boolean, fileName?: string, binary?: boolean, isLittleEndian?: boolean): any;
  67435. }
  67436. }
  67437. /**
  67438. * @ignoreChildren
  67439. * @ignore
  67440. */
  67441. declare module "babylonjs-gltf2interface" {
  67442. export = BABYLON.GLTF2;
  67443. }
  67444. /**
  67445. * Module for glTF 2.0 Interface
  67446. * @ignoreChildren
  67447. * @ignore
  67448. */
  67449. declare module BABYLON.GLTF2 {
  67450. /**
  67451. * The datatype of the components in the attribute
  67452. */
  67453. const enum AccessorComponentType {
  67454. /**
  67455. * Byte
  67456. */
  67457. BYTE = 5120,
  67458. /**
  67459. * Unsigned Byte
  67460. */
  67461. UNSIGNED_BYTE = 5121,
  67462. /**
  67463. * Short
  67464. */
  67465. SHORT = 5122,
  67466. /**
  67467. * Unsigned Short
  67468. */
  67469. UNSIGNED_SHORT = 5123,
  67470. /**
  67471. * Unsigned Int
  67472. */
  67473. UNSIGNED_INT = 5125,
  67474. /**
  67475. * Float
  67476. */
  67477. FLOAT = 5126,
  67478. }
  67479. /**
  67480. * Specifies if the attirbute is a scalar, vector, or matrix
  67481. */
  67482. const enum AccessorType {
  67483. /**
  67484. * Scalar
  67485. */
  67486. SCALAR = "SCALAR",
  67487. /**
  67488. * Vector2
  67489. */
  67490. VEC2 = "VEC2",
  67491. /**
  67492. * Vector3
  67493. */
  67494. VEC3 = "VEC3",
  67495. /**
  67496. * Vector4
  67497. */
  67498. VEC4 = "VEC4",
  67499. /**
  67500. * Matrix2x2
  67501. */
  67502. MAT2 = "MAT2",
  67503. /**
  67504. * Matrix3x3
  67505. */
  67506. MAT3 = "MAT3",
  67507. /**
  67508. * Matrix4x4
  67509. */
  67510. MAT4 = "MAT4",
  67511. }
  67512. /**
  67513. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67514. */
  67515. const enum AnimationChannelTargetPath {
  67516. /**
  67517. * Translation
  67518. */
  67519. TRANSLATION = "translation",
  67520. /**
  67521. * Rotation
  67522. */
  67523. ROTATION = "rotation",
  67524. /**
  67525. * Scale
  67526. */
  67527. SCALE = "scale",
  67528. /**
  67529. * Weights
  67530. */
  67531. WEIGHTS = "weights",
  67532. }
  67533. /**
  67534. * Interpolation algorithm
  67535. */
  67536. const enum AnimationSamplerInterpolation {
  67537. /**
  67538. * The animated values are linearly interpolated between keyframes
  67539. */
  67540. LINEAR = "LINEAR",
  67541. /**
  67542. * The animated values remain constant to the output of the first keyframe, until the next keyframe
  67543. */
  67544. STEP = "STEP",
  67545. /**
  67546. * The animation's interpolation is computed using a cubic spline with specified tangents
  67547. */
  67548. CUBICSPLINE = "CUBICSPLINE",
  67549. }
  67550. /**
  67551. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67552. */
  67553. const enum CameraType {
  67554. /**
  67555. * A perspective camera containing properties to create a perspective projection matrix
  67556. */
  67557. PERSPECTIVE = "perspective",
  67558. /**
  67559. * An orthographic camera containing properties to create an orthographic projection matrix
  67560. */
  67561. ORTHOGRAPHIC = "orthographic",
  67562. }
  67563. /**
  67564. * The mime-type of the image
  67565. */
  67566. const enum ImageMimeType {
  67567. /**
  67568. * JPEG Mime-type
  67569. */
  67570. JPEG = "image/jpeg",
  67571. /**
  67572. * PNG Mime-type
  67573. */
  67574. PNG = "image/png",
  67575. }
  67576. /**
  67577. * The alpha rendering mode of the material
  67578. */
  67579. const enum MaterialAlphaMode {
  67580. /**
  67581. * The alpha value is ignored and the rendered output is fully opaque
  67582. */
  67583. OPAQUE = "OPAQUE",
  67584. /**
  67585. * The rendered output is either fully opaque or fully transparent depending on the alpha value and the specified alpha cutoff value
  67586. */
  67587. MASK = "MASK",
  67588. /**
  67589. * 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)
  67590. */
  67591. BLEND = "BLEND",
  67592. }
  67593. /**
  67594. * The type of the primitives to render
  67595. */
  67596. const enum MeshPrimitiveMode {
  67597. /**
  67598. * Points
  67599. */
  67600. POINTS = 0,
  67601. /**
  67602. * Lines
  67603. */
  67604. LINES = 1,
  67605. /**
  67606. * Line Loop
  67607. */
  67608. LINE_LOOP = 2,
  67609. /**
  67610. * Line Strip
  67611. */
  67612. LINE_STRIP = 3,
  67613. /**
  67614. * Triangles
  67615. */
  67616. TRIANGLES = 4,
  67617. /**
  67618. * Triangle Strip
  67619. */
  67620. TRIANGLE_STRIP = 5,
  67621. /**
  67622. * Triangle Fan
  67623. */
  67624. TRIANGLE_FAN = 6,
  67625. }
  67626. /**
  67627. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  67628. */
  67629. const enum TextureMagFilter {
  67630. /**
  67631. * Nearest
  67632. */
  67633. NEAREST = 9728,
  67634. /**
  67635. * Linear
  67636. */
  67637. LINEAR = 9729,
  67638. }
  67639. /**
  67640. * Minification filter. All valid values correspond to WebGL enums
  67641. */
  67642. const enum TextureMinFilter {
  67643. /**
  67644. * Nearest
  67645. */
  67646. NEAREST = 9728,
  67647. /**
  67648. * Linear
  67649. */
  67650. LINEAR = 9729,
  67651. /**
  67652. * Nearest Mip-Map Nearest
  67653. */
  67654. NEAREST_MIPMAP_NEAREST = 9984,
  67655. /**
  67656. * Linear Mipmap Nearest
  67657. */
  67658. LINEAR_MIPMAP_NEAREST = 9985,
  67659. /**
  67660. * Nearest Mipmap Linear
  67661. */
  67662. NEAREST_MIPMAP_LINEAR = 9986,
  67663. /**
  67664. * Linear Mipmap Linear
  67665. */
  67666. LINEAR_MIPMAP_LINEAR = 9987,
  67667. }
  67668. /**
  67669. * S (U) wrapping mode. All valid values correspond to WebGL enums
  67670. */
  67671. const enum TextureWrapMode {
  67672. /**
  67673. * Clamp to Edge
  67674. */
  67675. CLAMP_TO_EDGE = 33071,
  67676. /**
  67677. * Mirrored Repeat
  67678. */
  67679. MIRRORED_REPEAT = 33648,
  67680. /**
  67681. * Repeat
  67682. */
  67683. REPEAT = 10497,
  67684. }
  67685. /**
  67686. * glTF Property
  67687. */
  67688. interface IProperty {
  67689. /**
  67690. * Dictionary object with extension-specific objects
  67691. */
  67692. extensions?: {
  67693. [key: string]: any;
  67694. };
  67695. /**
  67696. * Application-Specific data
  67697. */
  67698. extras?: any;
  67699. }
  67700. /**
  67701. * glTF Child of Root Property
  67702. */
  67703. interface IChildRootProperty extends IProperty {
  67704. /**
  67705. * The user-defined name of this object
  67706. */
  67707. name?: string;
  67708. }
  67709. /**
  67710. * Indices of those attributes that deviate from their initialization value
  67711. */
  67712. interface IAccessorSparseIndices extends IProperty {
  67713. /**
  67714. * The index of the bufferView with sparse indices. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67715. */
  67716. bufferView: number;
  67717. /**
  67718. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67719. */
  67720. byteOffset?: number;
  67721. /**
  67722. * The indices data type. Valid values correspond to WebGL enums: 5121 (UNSIGNED_BYTE), 5123 (UNSIGNED_SHORT), 5125 (UNSIGNED_INT)
  67723. */
  67724. componentType: AccessorComponentType;
  67725. }
  67726. /**
  67727. * Array of size accessor.sparse.count times number of components storing the displaced accessor attributes pointed by accessor.sparse.indices
  67728. */
  67729. interface IAccessorSparseValues extends IProperty {
  67730. /**
  67731. * The index of the bufferView with sparse values. Referenced bufferView can't have ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER target
  67732. */
  67733. bufferView: number;
  67734. /**
  67735. * The offset relative to the start of the bufferView in bytes. Must be aligned
  67736. */
  67737. byteOffset?: number;
  67738. }
  67739. /**
  67740. * Sparse storage of attributes that deviate from their initialization value
  67741. */
  67742. interface IAccessorSparse extends IProperty {
  67743. /**
  67744. * The number of attributes encoded in this sparse accessor
  67745. */
  67746. count: number;
  67747. /**
  67748. * Index array of size count that points to those accessor attributes that deviate from their initialization value. Indices must strictly increase
  67749. */
  67750. indices: IAccessorSparseIndices;
  67751. /**
  67752. * 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
  67753. */
  67754. values: IAccessorSparseValues;
  67755. }
  67756. /**
  67757. * 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
  67758. */
  67759. interface IAccessor extends IChildRootProperty {
  67760. /**
  67761. * The index of the bufferview
  67762. */
  67763. bufferView?: number;
  67764. /**
  67765. * The offset relative to the start of the bufferView in bytes
  67766. */
  67767. byteOffset?: number;
  67768. /**
  67769. * The datatype of components in the attribute
  67770. */
  67771. componentType: AccessorComponentType;
  67772. /**
  67773. * Specifies whether integer data values should be normalized
  67774. */
  67775. normalized?: boolean;
  67776. /**
  67777. * The number of attributes referenced by this accessor
  67778. */
  67779. count: number;
  67780. /**
  67781. * Specifies if the attribute is a scalar, vector, or matrix
  67782. */
  67783. type: AccessorType;
  67784. /**
  67785. * Maximum value of each component in this attribute
  67786. */
  67787. max?: number[];
  67788. /**
  67789. * Minimum value of each component in this attribute
  67790. */
  67791. min?: number[];
  67792. /**
  67793. * Sparse storage of attributes that deviate from their initialization value
  67794. */
  67795. sparse?: IAccessorSparse;
  67796. }
  67797. /**
  67798. * Targets an animation's sampler at a node's property
  67799. */
  67800. interface IAnimationChannel extends IProperty {
  67801. /**
  67802. * The index of a sampler in this animation used to compute the value for the target
  67803. */
  67804. sampler: number;
  67805. /**
  67806. * The index of the node and TRS property to target
  67807. */
  67808. target: IAnimationChannelTarget;
  67809. }
  67810. /**
  67811. * The index of the node and TRS property that an animation channel targets
  67812. */
  67813. interface IAnimationChannelTarget extends IProperty {
  67814. /**
  67815. * The index of the node to target
  67816. */
  67817. node: number;
  67818. /**
  67819. * The name of the node's TRS property to modify, or the weights of the Morph Targets it instantiates
  67820. */
  67821. path: AnimationChannelTargetPath;
  67822. }
  67823. /**
  67824. * Combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67825. */
  67826. interface IAnimationSampler extends IProperty {
  67827. /**
  67828. * The index of an accessor containing keyframe input values, e.g., time
  67829. */
  67830. input: number;
  67831. /**
  67832. * Interpolation algorithm
  67833. */
  67834. interpolation?: AnimationSamplerInterpolation;
  67835. /**
  67836. * The index of an accessor, containing keyframe output values
  67837. */
  67838. output: number;
  67839. }
  67840. /**
  67841. * A keyframe animation
  67842. */
  67843. interface IAnimation extends IChildRootProperty {
  67844. /**
  67845. * An array of channels, each of which targets an animation's sampler at a node's property
  67846. */
  67847. channels: IAnimationChannel[];
  67848. /**
  67849. * An array of samplers that combines input and output accessors with an interpolation algorithm to define a keyframe graph (but not its target)
  67850. */
  67851. samplers: IAnimationSampler[];
  67852. }
  67853. /**
  67854. * Metadata about the glTF asset
  67855. */
  67856. interface IAsset extends IChildRootProperty {
  67857. /**
  67858. * A copyright message suitable for display to credit the content creator
  67859. */
  67860. copyright?: string;
  67861. /**
  67862. * Tool that generated this glTF model. Useful for debugging
  67863. */
  67864. generator?: string;
  67865. /**
  67866. * The glTF version that this asset targets
  67867. */
  67868. version: string;
  67869. /**
  67870. * The minimum glTF version that this asset targets
  67871. */
  67872. minVersion?: string;
  67873. }
  67874. /**
  67875. * A buffer points to binary geometry, animation, or skins
  67876. */
  67877. interface IBuffer extends IChildRootProperty {
  67878. /**
  67879. * 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
  67880. */
  67881. uri?: string;
  67882. /**
  67883. * The length of the buffer in bytes
  67884. */
  67885. byteLength: number;
  67886. }
  67887. /**
  67888. * A view into a buffer generally representing a subset of the buffer
  67889. */
  67890. interface IBufferView extends IChildRootProperty {
  67891. /**
  67892. * The index of the buffer
  67893. */
  67894. buffer: number;
  67895. /**
  67896. * The offset into the buffer in bytes
  67897. */
  67898. byteOffset?: number;
  67899. /**
  67900. * The lenth of the bufferView in bytes
  67901. */
  67902. byteLength: number;
  67903. /**
  67904. * The stride, in bytes
  67905. */
  67906. byteStride?: number;
  67907. }
  67908. /**
  67909. * An orthographic camera containing properties to create an orthographic projection matrix
  67910. */
  67911. interface ICameraOrthographic extends IProperty {
  67912. /**
  67913. * The floating-point horizontal magnification of the view. Must not be zero
  67914. */
  67915. xmag: number;
  67916. /**
  67917. * The floating-point vertical magnification of the view. Must not be zero
  67918. */
  67919. ymag: number;
  67920. /**
  67921. * The floating-point distance to the far clipping plane. zfar must be greater than znear
  67922. */
  67923. zfar: number;
  67924. /**
  67925. * The floating-point distance to the near clipping plane
  67926. */
  67927. znear: number;
  67928. }
  67929. /**
  67930. * A perspective camera containing properties to create a perspective projection matrix
  67931. */
  67932. interface ICameraPerspective extends IProperty {
  67933. /**
  67934. * The floating-point aspect ratio of the field of view
  67935. */
  67936. aspectRatio?: number;
  67937. /**
  67938. * The floating-point vertical field of view in radians
  67939. */
  67940. yfov: number;
  67941. /**
  67942. * The floating-point distance to the far clipping plane
  67943. */
  67944. zfar?: number;
  67945. /**
  67946. * The floating-point distance to the near clipping plane
  67947. */
  67948. znear: number;
  67949. }
  67950. /**
  67951. * A camera's projection. A node can reference a camera to apply a transform to place the camera in the scene
  67952. */
  67953. interface ICamera extends IChildRootProperty {
  67954. /**
  67955. * An orthographic camera containing properties to create an orthographic projection matrix
  67956. */
  67957. orthographic?: ICameraOrthographic;
  67958. /**
  67959. * A perspective camera containing properties to create a perspective projection matrix
  67960. */
  67961. perspective?: ICameraPerspective;
  67962. /**
  67963. * Specifies if the camera uses a perspective or orthographic projection
  67964. */
  67965. type: CameraType;
  67966. }
  67967. /**
  67968. * Image data used to create a texture. Image can be referenced by URI or bufferView index. mimeType is required in the latter case
  67969. */
  67970. interface IImage extends IChildRootProperty {
  67971. /**
  67972. * 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
  67973. */
  67974. uri?: string;
  67975. /**
  67976. * The image's MIME type
  67977. */
  67978. mimeType?: ImageMimeType;
  67979. /**
  67980. * The index of the bufferView that contains the image. Use this instead of the image's uri property
  67981. */
  67982. bufferView?: number;
  67983. }
  67984. /**
  67985. * Material Normal Texture Info
  67986. */
  67987. interface IMaterialNormalTextureInfo extends ITextureInfo {
  67988. /**
  67989. * The scalar multiplier applied to each normal vector of the normal texture
  67990. */
  67991. scale?: number;
  67992. }
  67993. /**
  67994. * Material Occlusion Texture Info
  67995. */
  67996. interface IMaterialOcclusionTextureInfo extends ITextureInfo {
  67997. /**
  67998. * A scalar multiplier controlling the amount of occlusion applied
  67999. */
  68000. strength?: number;
  68001. }
  68002. /**
  68003. * A set of parameter values that are used to define the metallic-roughness material model from Physically-Based Rendering (PBR) methodology
  68004. */
  68005. interface IMaterialPbrMetallicRoughness {
  68006. /**
  68007. * The material's base color factor
  68008. */
  68009. baseColorFactor?: number[];
  68010. /**
  68011. * The base color texture
  68012. */
  68013. baseColorTexture?: ITextureInfo;
  68014. /**
  68015. * The metalness of the material
  68016. */
  68017. metallicFactor?: number;
  68018. /**
  68019. * The roughness of the material
  68020. */
  68021. roughnessFactor?: number;
  68022. /**
  68023. * The metallic-roughness texture
  68024. */
  68025. metallicRoughnessTexture?: ITextureInfo;
  68026. }
  68027. /**
  68028. * The material appearance of a primitive
  68029. */
  68030. interface IMaterial extends IChildRootProperty {
  68031. /**
  68032. * 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
  68033. */
  68034. pbrMetallicRoughness?: IMaterialPbrMetallicRoughness;
  68035. /**
  68036. * The normal map texture
  68037. */
  68038. normalTexture?: IMaterialNormalTextureInfo;
  68039. /**
  68040. * The occlusion map texture
  68041. */
  68042. occlusionTexture?: IMaterialOcclusionTextureInfo;
  68043. /**
  68044. * The emissive map texture
  68045. */
  68046. emissiveTexture?: ITextureInfo;
  68047. /**
  68048. * 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
  68049. */
  68050. emissiveFactor?: number[];
  68051. /**
  68052. * The alpha rendering mode of the material
  68053. */
  68054. alphaMode?: MaterialAlphaMode;
  68055. /**
  68056. * The alpha cutoff value of the material
  68057. */
  68058. alphaCutoff?: number;
  68059. /**
  68060. * Specifies whether the material is double sided
  68061. */
  68062. doubleSided?: boolean;
  68063. }
  68064. /**
  68065. * Geometry to be rendered with the given material
  68066. */
  68067. interface IMeshPrimitive extends IProperty {
  68068. /**
  68069. * A dictionary object, where each key corresponds to mesh attribute semantic and each value is the index of the accessor containing attribute's data
  68070. */
  68071. attributes: {
  68072. [name: string]: number;
  68073. };
  68074. /**
  68075. * The index of the accessor that contains the indices
  68076. */
  68077. indices?: number;
  68078. /**
  68079. * The index of the material to apply to this primitive when rendering
  68080. */
  68081. material?: number;
  68082. /**
  68083. * The type of primitives to render. All valid values correspond to WebGL enums
  68084. */
  68085. mode?: MeshPrimitiveMode;
  68086. /**
  68087. * 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
  68088. */
  68089. targets?: {
  68090. [name: string]: number;
  68091. }[];
  68092. }
  68093. /**
  68094. * A set of primitives to be rendered. A node can contain one mesh. A node's transform places the mesh in the scene
  68095. */
  68096. interface IMesh extends IChildRootProperty {
  68097. /**
  68098. * An array of primitives, each defining geometry to be rendered with a material
  68099. */
  68100. primitives: IMeshPrimitive[];
  68101. /**
  68102. * Array of weights to be applied to the Morph Targets
  68103. */
  68104. weights?: number[];
  68105. }
  68106. /**
  68107. * A node in the node hierarchy
  68108. */
  68109. interface INode extends IChildRootProperty {
  68110. /**
  68111. * The index of the camera referenced by this node
  68112. */
  68113. camera?: number;
  68114. /**
  68115. * The indices of this node's children
  68116. */
  68117. children?: number[];
  68118. /**
  68119. * The index of the skin referenced by this node
  68120. */
  68121. skin?: number;
  68122. /**
  68123. * A floating-point 4x4 transformation matrix stored in column-major order
  68124. */
  68125. matrix?: number[];
  68126. /**
  68127. * The index of the mesh in this node
  68128. */
  68129. mesh?: number;
  68130. /**
  68131. * The node's unit quaternion rotation in the order (x, y, z, w), where w is the scalar
  68132. */
  68133. rotation?: number[];
  68134. /**
  68135. * The node's non-uniform scale, given as the scaling factors along the x, y, and z axes
  68136. */
  68137. scale?: number[];
  68138. /**
  68139. * The node's translation along the x, y, and z axes
  68140. */
  68141. translation?: number[];
  68142. /**
  68143. * The weights of the instantiated Morph Target. Number of elements must match number of Morph Targets of used mesh
  68144. */
  68145. weights?: number[];
  68146. }
  68147. /**
  68148. * Texture sampler properties for filtering and wrapping modes
  68149. */
  68150. interface ISampler extends IChildRootProperty {
  68151. /**
  68152. * Magnification filter. Valid values correspond to WebGL enums: 9728 (NEAREST) and 9729 (LINEAR)
  68153. */
  68154. magFilter?: TextureMagFilter;
  68155. /**
  68156. * Minification filter. All valid values correspond to WebGL enums
  68157. */
  68158. minFilter?: TextureMinFilter;
  68159. /**
  68160. * S (U) wrapping mode. All valid values correspond to WebGL enums
  68161. */
  68162. wrapS?: TextureWrapMode;
  68163. /**
  68164. * T (V) wrapping mode. All valid values correspond to WebGL enums
  68165. */
  68166. wrapT?: TextureWrapMode;
  68167. }
  68168. /**
  68169. * The root nodes of a scene
  68170. */
  68171. interface IScene extends IChildRootProperty {
  68172. /**
  68173. * The indices of each root node
  68174. */
  68175. nodes: number[];
  68176. }
  68177. /**
  68178. * Joints and matrices defining a skin
  68179. */
  68180. interface ISkin extends IChildRootProperty {
  68181. /**
  68182. * 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
  68183. */
  68184. inverseBindMatrices?: number;
  68185. /**
  68186. * The index of the node used as a skeleton root. When undefined, joints transforms resolve to scene root
  68187. */
  68188. skeleton?: number;
  68189. /**
  68190. * 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)
  68191. */
  68192. joints: number[];
  68193. }
  68194. /**
  68195. * A texture and its sampler
  68196. */
  68197. interface ITexture extends IChildRootProperty {
  68198. /**
  68199. * The index of the sampler used by this texture. When undefined, a sampler with repeat wrapping and auto filtering should be used
  68200. */
  68201. sampler?: number;
  68202. /**
  68203. * The index of the image used by this texture
  68204. */
  68205. source: number;
  68206. }
  68207. /**
  68208. * Reference to a texture
  68209. */
  68210. interface ITextureInfo extends IProperty {
  68211. /**
  68212. * The index of the texture
  68213. */
  68214. index: number;
  68215. /**
  68216. * The set index of texture's TEXCOORD attribute used for texture coordinate mapping
  68217. */
  68218. texCoord?: number;
  68219. }
  68220. /**
  68221. * The root object for a glTF asset
  68222. */
  68223. interface IGLTF extends IProperty {
  68224. /**
  68225. * An array of accessors. An accessor is a typed view into a bufferView
  68226. */
  68227. accessors?: IAccessor[];
  68228. /**
  68229. * An array of keyframe animations
  68230. */
  68231. animations?: IAnimation[];
  68232. /**
  68233. * Metadata about the glTF asset
  68234. */
  68235. asset: IAsset;
  68236. /**
  68237. * An array of buffers. A buffer points to binary geometry, animation, or skins
  68238. */
  68239. buffers?: IBuffer[];
  68240. /**
  68241. * An array of bufferViews. A bufferView is a view into a buffer generally representing a subset of the buffer
  68242. */
  68243. bufferViews?: IBufferView[];
  68244. /**
  68245. * An array of cameras
  68246. */
  68247. cameras?: ICamera[];
  68248. /**
  68249. * Names of glTF extensions used somewhere in this asset
  68250. */
  68251. extensionsUsed?: string[];
  68252. /**
  68253. * Names of glTF extensions required to properly load this asset
  68254. */
  68255. extensionsRequired?: string[];
  68256. /**
  68257. * An array of images. An image defines data used to create a texture
  68258. */
  68259. images?: IImage[];
  68260. /**
  68261. * An array of materials. A material defines the appearance of a primitive
  68262. */
  68263. materials?: IMaterial[];
  68264. /**
  68265. * An array of meshes. A mesh is a set of primitives to be rendered
  68266. */
  68267. meshes?: IMesh[];
  68268. /**
  68269. * An array of nodes
  68270. */
  68271. nodes?: INode[];
  68272. /**
  68273. * An array of samplers. A sampler contains properties for texture filtering and wrapping modes
  68274. */
  68275. samplers?: ISampler[];
  68276. /**
  68277. * The index of the default scene
  68278. */
  68279. scene?: number;
  68280. /**
  68281. * An array of scenes
  68282. */
  68283. scenes?: IScene[];
  68284. /**
  68285. * An array of skins. A skin is defined by joints and matrices
  68286. */
  68287. skins?: ISkin[];
  68288. /**
  68289. * An array of textures
  68290. */
  68291. textures?: ITexture[];
  68292. }
  68293. /**
  68294. * The glTF validation results
  68295. */
  68296. interface IGLTFValidationResults {
  68297. info: {
  68298. generator: string;
  68299. hasAnimations: boolean;
  68300. hasDefaultScene: boolean;
  68301. hasMaterials: boolean;
  68302. hasMorphTargets: boolean;
  68303. hasSkins: boolean;
  68304. hasTextures: boolean;
  68305. maxAttributesUsed: number;
  68306. primitivesCount: number
  68307. };
  68308. issues: {
  68309. messages: Array<string>;
  68310. numErrors: number;
  68311. numHints: number;
  68312. numInfos: number;
  68313. numWarnings: number;
  68314. truncated: boolean
  68315. };
  68316. mimeType: string;
  68317. uri: string;
  68318. validatedAt: string;
  68319. validatorVersion: string;
  68320. }
  68321. /**
  68322. * The glTF validation options
  68323. */
  68324. interface IGLTFValidationOptions {
  68325. uri?: string;
  68326. externalResourceFunction?: (uri: string) => Promise<Uint8Array>;
  68327. validateAccessorData?: boolean;
  68328. maxIssues?: number;
  68329. ignoredIssues?: Array<string>;
  68330. severityOverrides?: Object;
  68331. }
  68332. /**
  68333. * The glTF validator object
  68334. */
  68335. interface IGLTFValidator {
  68336. validateBytes: (data: Uint8Array, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68337. validateString: (json: string, options?: IGLTFValidationOptions) => Promise<IGLTFValidationResults>;
  68338. }
  68339. }
  68340. declare module BABYLON {
  68341. /** @hidden */
  68342. export var cellPixelShader: {
  68343. name: string;
  68344. shader: string;
  68345. };
  68346. }
  68347. declare module BABYLON {
  68348. /** @hidden */
  68349. export var cellVertexShader: {
  68350. name: string;
  68351. shader: string;
  68352. };
  68353. }
  68354. declare module BABYLON {
  68355. export class CellMaterial extends BABYLON.PushMaterial {
  68356. private _diffuseTexture;
  68357. diffuseTexture: BABYLON.BaseTexture;
  68358. diffuseColor: BABYLON.Color3; private _computeHighLevel: boolean;
  68359. computeHighLevel: boolean;
  68360. private _disableLighting;
  68361. disableLighting: boolean;
  68362. private _maxSimultaneousLights;
  68363. maxSimultaneousLights: number;
  68364. private _renderId;
  68365. constructor(name: string, scene: BABYLON.Scene);
  68366. needAlphaBlending(): boolean;
  68367. needAlphaTesting(): boolean;
  68368. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68369. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68370. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68371. getAnimatables(): BABYLON.IAnimatable[];
  68372. getActiveTextures(): BABYLON.BaseTexture[];
  68373. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68374. dispose(forceDisposeEffect?: boolean): void;
  68375. getClassName(): string;
  68376. clone(name: string): CellMaterial;
  68377. serialize(): any;
  68378. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): CellMaterial;
  68379. }
  68380. }
  68381. declare module BABYLON {
  68382. export class CustomShaderStructure {
  68383. FragmentStore: string;
  68384. VertexStore: string;
  68385. constructor();
  68386. }
  68387. export class ShaderSpecialParts {
  68388. constructor();
  68389. Fragment_Begin: string;
  68390. Fragment_Definitions: string;
  68391. Fragment_MainBegin: string;
  68392. Fragment_Custom_Diffuse: string;
  68393. Fragment_Before_Lights: string;
  68394. Fragment_Before_Fog: string;
  68395. Fragment_Custom_Alpha: string;
  68396. Fragment_Before_FragColor: string;
  68397. Vertex_Begin: string;
  68398. Vertex_Definitions: string;
  68399. Vertex_MainBegin: string;
  68400. Vertex_Before_PositionUpdated: string;
  68401. Vertex_Before_NormalUpdated: string;
  68402. Vertex_MainEnd: string;
  68403. }
  68404. export class CustomMaterial extends BABYLON.StandardMaterial {
  68405. static ShaderIndexer: number;
  68406. CustomParts: ShaderSpecialParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  68407. FragmentShader: string;
  68408. VertexShader: string;
  68409. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68410. ReviewUniform(name: string, arr: string[]): string[];
  68411. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.StandardMaterialDefines): string;
  68412. constructor(name: string, scene: BABYLON.Scene);
  68413. AddUniform(name: string, kind: string, param: any): CustomMaterial;
  68414. Fragment_Begin(shaderPart: string): CustomMaterial;
  68415. Fragment_Definitions(shaderPart: string): CustomMaterial;
  68416. Fragment_MainBegin(shaderPart: string): CustomMaterial;
  68417. Fragment_Custom_Diffuse(shaderPart: string): CustomMaterial;
  68418. Fragment_Custom_Alpha(shaderPart: string): CustomMaterial;
  68419. Fragment_Before_Lights(shaderPart: string): CustomMaterial;
  68420. Fragment_Before_Fog(shaderPart: string): CustomMaterial;
  68421. Fragment_Before_FragColor(shaderPart: string): CustomMaterial;
  68422. Vertex_Begin(shaderPart: string): CustomMaterial;
  68423. Vertex_Definitions(shaderPart: string): CustomMaterial;
  68424. Vertex_MainBegin(shaderPart: string): CustomMaterial;
  68425. Vertex_Before_PositionUpdated(shaderPart: string): CustomMaterial;
  68426. Vertex_Before_NormalUpdated(shaderPart: string): CustomMaterial;
  68427. Vertex_MainEnd(shaderPart: string): CustomMaterial;
  68428. }
  68429. }
  68430. declare module BABYLON {
  68431. export class ShaderAlebdoParts {
  68432. constructor();
  68433. Fragment_Begin: string;
  68434. Fragment_Definitions: string;
  68435. Fragment_MainBegin: string;
  68436. Fragment_Custom_Albedo: string;
  68437. Fragment_Before_Lights: string;
  68438. Fragment_Custom_MetallicRoughness: string;
  68439. Fragment_Custom_MicroSurface: string;
  68440. Fragment_Before_Fog: string;
  68441. Fragment_Custom_Alpha: string;
  68442. Fragment_Before_FragColor: string;
  68443. Vertex_Begin: string;
  68444. Vertex_Definitions: string;
  68445. Vertex_MainBegin: string;
  68446. Vertex_Before_PositionUpdated: string;
  68447. Vertex_Before_NormalUpdated: string;
  68448. Vertex_MainEnd: string;
  68449. }
  68450. export class PBRCustomMaterial extends BABYLON.PBRMaterial {
  68451. static ShaderIndexer: number;
  68452. CustomParts: ShaderAlebdoParts; private _isCreatedShader: boolean; private _createdShaderName: string; private _customUniform: string[]; private _newUniforms: string[]; private _newUniformInstances: any[]; private _newSamplerInstances: BABYLON.Texture[];
  68453. FragmentShader: string;
  68454. VertexShader: string;
  68455. AttachAfterBind(mesh: BABYLON.Mesh, effect: BABYLON.Effect): void;
  68456. ReviewUniform(name: string, arr: string[]): string[];
  68457. Builder(shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: BABYLON.PBRMaterialDefines): string;
  68458. constructor(name: string, scene: BABYLON.Scene);
  68459. AddUniform(name: string, kind: string, param: any): PBRCustomMaterial;
  68460. Fragment_Begin(shaderPart: string): PBRCustomMaterial;
  68461. Fragment_Definitions(shaderPart: string): PBRCustomMaterial;
  68462. Fragment_MainBegin(shaderPart: string): PBRCustomMaterial;
  68463. Fragment_Custom_Albedo(shaderPart: string): PBRCustomMaterial;
  68464. Fragment_Custom_Alpha(shaderPart: string): PBRCustomMaterial;
  68465. Fragment_Before_Lights(shaderPart: string): PBRCustomMaterial;
  68466. Fragment_Custom_MetallicRoughness(shaderPart: string): PBRCustomMaterial;
  68467. Fragment_Custom_MicroSurface(shaderPart: string): PBRCustomMaterial;
  68468. Fragment_Before_Fog(shaderPart: string): PBRCustomMaterial;
  68469. Fragment_Before_FragColor(shaderPart: string): PBRCustomMaterial;
  68470. Vertex_Begin(shaderPart: string): PBRCustomMaterial;
  68471. Vertex_Definitions(shaderPart: string): PBRCustomMaterial;
  68472. Vertex_MainBegin(shaderPart: string): PBRCustomMaterial;
  68473. Vertex_Before_PositionUpdated(shaderPart: string): PBRCustomMaterial;
  68474. Vertex_Before_NormalUpdated(shaderPart: string): PBRCustomMaterial;
  68475. Vertex_MainEnd(shaderPart: string): PBRCustomMaterial;
  68476. }
  68477. }
  68478. declare module BABYLON {
  68479. /** @hidden */
  68480. export var firePixelShader: {
  68481. name: string;
  68482. shader: string;
  68483. };
  68484. }
  68485. declare module BABYLON {
  68486. /** @hidden */
  68487. export var fireVertexShader: {
  68488. name: string;
  68489. shader: string;
  68490. };
  68491. }
  68492. declare module BABYLON {
  68493. export class FireMaterial extends BABYLON.PushMaterial {
  68494. private _diffuseTexture;
  68495. diffuseTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68496. private _distortionTexture;
  68497. distortionTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68498. private _opacityTexture;
  68499. opacityTexture: BABYLON.Nullable<BABYLON.BaseTexture>;
  68500. diffuseColor: BABYLON.Color3;
  68501. speed: number;
  68502. private _scaledDiffuse;
  68503. private _renderId;
  68504. private _lastTime;
  68505. constructor(name: string, scene: BABYLON.Scene);
  68506. needAlphaBlending(): boolean;
  68507. needAlphaTesting(): boolean;
  68508. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68509. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68510. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68511. getAnimatables(): BABYLON.IAnimatable[];
  68512. getActiveTextures(): BABYLON.BaseTexture[];
  68513. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68514. getClassName(): string;
  68515. dispose(forceDisposeEffect?: boolean): void;
  68516. clone(name: string): FireMaterial;
  68517. serialize(): any;
  68518. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FireMaterial;
  68519. }
  68520. }
  68521. declare module BABYLON {
  68522. /** @hidden */
  68523. export var furPixelShader: {
  68524. name: string;
  68525. shader: string;
  68526. };
  68527. }
  68528. declare module BABYLON {
  68529. /** @hidden */
  68530. export var furVertexShader: {
  68531. name: string;
  68532. shader: string;
  68533. };
  68534. }
  68535. declare module BABYLON {
  68536. export class FurMaterial extends BABYLON.PushMaterial {
  68537. private _diffuseTexture;
  68538. diffuseTexture: BABYLON.BaseTexture;
  68539. private _heightTexture;
  68540. heightTexture: BABYLON.BaseTexture;
  68541. diffuseColor: BABYLON.Color3;
  68542. furLength: number;
  68543. furAngle: number;
  68544. furColor: BABYLON.Color3;
  68545. furOffset: number;
  68546. furSpacing: number;
  68547. furGravity: BABYLON.Vector3;
  68548. furSpeed: number;
  68549. furDensity: number;
  68550. furOcclusion: number;
  68551. furTexture: BABYLON.DynamicTexture;
  68552. private _disableLighting;
  68553. disableLighting: boolean;
  68554. private _maxSimultaneousLights;
  68555. maxSimultaneousLights: number;
  68556. highLevelFur: boolean; private _meshes: BABYLON.AbstractMesh[];
  68557. private _renderId;
  68558. private _furTime;
  68559. constructor(name: string, scene: BABYLON.Scene);
  68560. furTime: number;
  68561. needAlphaBlending(): boolean;
  68562. needAlphaTesting(): boolean;
  68563. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68564. updateFur(): void;
  68565. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68566. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68567. getAnimatables(): BABYLON.IAnimatable[];
  68568. getActiveTextures(): BABYLON.BaseTexture[];
  68569. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68570. dispose(forceDisposeEffect?: boolean): void;
  68571. clone(name: string): FurMaterial;
  68572. serialize(): any;
  68573. getClassName(): string;
  68574. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): FurMaterial;
  68575. static GenerateTexture(name: string, scene: BABYLON.Scene): BABYLON.DynamicTexture;
  68576. static FurifyMesh(sourceMesh: BABYLON.Mesh, quality: number): BABYLON.Mesh[];
  68577. }
  68578. }
  68579. declare module BABYLON {
  68580. /** @hidden */
  68581. export var gradientPixelShader: {
  68582. name: string;
  68583. shader: string;
  68584. };
  68585. }
  68586. declare module BABYLON {
  68587. /** @hidden */
  68588. export var gradientVertexShader: {
  68589. name: string;
  68590. shader: string;
  68591. };
  68592. }
  68593. declare module BABYLON {
  68594. export class GradientMaterial extends BABYLON.PushMaterial {
  68595. private _maxSimultaneousLights;
  68596. maxSimultaneousLights: number;
  68597. topColor: BABYLON.Color3;
  68598. topColorAlpha: number;
  68599. bottomColor: BABYLON.Color3;
  68600. bottomColorAlpha: number;
  68601. offset: number;
  68602. scale: number;
  68603. smoothness: number;
  68604. private _disableLighting;
  68605. disableLighting: boolean;
  68606. private _renderId;
  68607. constructor(name: string, scene: BABYLON.Scene);
  68608. needAlphaBlending(): boolean;
  68609. needAlphaTesting(): boolean;
  68610. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68611. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68612. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68613. getAnimatables(): BABYLON.IAnimatable[];
  68614. dispose(forceDisposeEffect?: boolean): void;
  68615. clone(name: string): GradientMaterial;
  68616. serialize(): any;
  68617. getClassName(): string;
  68618. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GradientMaterial;
  68619. }
  68620. }
  68621. declare module BABYLON {
  68622. /** @hidden */
  68623. export var gridPixelShader: {
  68624. name: string;
  68625. shader: string;
  68626. };
  68627. }
  68628. declare module BABYLON {
  68629. /** @hidden */
  68630. export var gridVertexShader: {
  68631. name: string;
  68632. shader: string;
  68633. };
  68634. }
  68635. declare module BABYLON {
  68636. /**
  68637. * The grid materials allows you to wrap any shape with a grid.
  68638. * Colors are customizable.
  68639. */
  68640. export class GridMaterial extends BABYLON.PushMaterial {
  68641. /**
  68642. * Main color of the grid (e.g. between lines)
  68643. */
  68644. mainColor: BABYLON.Color3;
  68645. /**
  68646. * Color of the grid lines.
  68647. */
  68648. lineColor: BABYLON.Color3;
  68649. /**
  68650. * The scale of the grid compared to unit.
  68651. */
  68652. gridRatio: number;
  68653. /**
  68654. * Allows setting an offset for the grid lines.
  68655. */
  68656. gridOffset: BABYLON.Vector3;
  68657. /**
  68658. * The frequency of thicker lines.
  68659. */
  68660. majorUnitFrequency: number;
  68661. /**
  68662. * The visibility of minor units in the grid.
  68663. */
  68664. minorUnitVisibility: number;
  68665. /**
  68666. * The grid opacity outside of the lines.
  68667. */
  68668. opacity: number;
  68669. /**
  68670. * Determine RBG output is premultiplied by alpha value.
  68671. */
  68672. preMultiplyAlpha: boolean;
  68673. private _opacityTexture;
  68674. opacityTexture: BABYLON.BaseTexture;
  68675. private _gridControl;
  68676. private _renderId;
  68677. /**
  68678. * constructor
  68679. * @param name The name given to the material in order to identify it afterwards.
  68680. * @param scene The scene the material is used in.
  68681. */
  68682. constructor(name: string, scene: BABYLON.Scene);
  68683. /**
  68684. * Returns wehter or not the grid requires alpha blending.
  68685. */
  68686. needAlphaBlending(): boolean;
  68687. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68688. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68689. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68690. /**
  68691. * Dispose the material and its associated resources.
  68692. * @param forceDisposeEffect will also dispose the used effect when true
  68693. */
  68694. dispose(forceDisposeEffect?: boolean): void;
  68695. clone(name: string): GridMaterial;
  68696. serialize(): any;
  68697. getClassName(): string;
  68698. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): GridMaterial;
  68699. }
  68700. }
  68701. declare module BABYLON {
  68702. /** @hidden */
  68703. export var lavaPixelShader: {
  68704. name: string;
  68705. shader: string;
  68706. };
  68707. }
  68708. declare module BABYLON {
  68709. /** @hidden */
  68710. export var lavaVertexShader: {
  68711. name: string;
  68712. shader: string;
  68713. };
  68714. }
  68715. declare module BABYLON {
  68716. export class LavaMaterial extends BABYLON.PushMaterial {
  68717. private _diffuseTexture;
  68718. diffuseTexture: BABYLON.BaseTexture;
  68719. noiseTexture: BABYLON.BaseTexture;
  68720. fogColor: BABYLON.Color3;
  68721. speed: number;
  68722. movingSpeed: number;
  68723. lowFrequencySpeed: number;
  68724. fogDensity: number;
  68725. private _lastTime;
  68726. diffuseColor: BABYLON.Color3;
  68727. private _disableLighting;
  68728. disableLighting: boolean;
  68729. private _unlit;
  68730. unlit: boolean;
  68731. private _maxSimultaneousLights;
  68732. maxSimultaneousLights: number;
  68733. private _scaledDiffuse;
  68734. private _renderId;
  68735. constructor(name: string, scene: BABYLON.Scene);
  68736. needAlphaBlending(): boolean;
  68737. needAlphaTesting(): boolean;
  68738. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68739. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68740. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68741. getAnimatables(): BABYLON.IAnimatable[];
  68742. getActiveTextures(): BABYLON.BaseTexture[];
  68743. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68744. dispose(forceDisposeEffect?: boolean): void;
  68745. clone(name: string): LavaMaterial;
  68746. serialize(): any;
  68747. getClassName(): string;
  68748. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): LavaMaterial;
  68749. }
  68750. }
  68751. declare module BABYLON {
  68752. /** @hidden */
  68753. export var mixPixelShader: {
  68754. name: string;
  68755. shader: string;
  68756. };
  68757. }
  68758. declare module BABYLON {
  68759. /** @hidden */
  68760. export var mixVertexShader: {
  68761. name: string;
  68762. shader: string;
  68763. };
  68764. }
  68765. declare module BABYLON {
  68766. export class MixMaterial extends BABYLON.PushMaterial {
  68767. /**
  68768. * Mix textures
  68769. */
  68770. private _mixTexture1;
  68771. mixTexture1: BABYLON.BaseTexture;
  68772. private _mixTexture2;
  68773. mixTexture2: BABYLON.BaseTexture;
  68774. /**
  68775. * Diffuse textures
  68776. */
  68777. private _diffuseTexture1;
  68778. diffuseTexture1: BABYLON.Texture;
  68779. private _diffuseTexture2;
  68780. diffuseTexture2: BABYLON.Texture;
  68781. private _diffuseTexture3;
  68782. diffuseTexture3: BABYLON.Texture;
  68783. private _diffuseTexture4;
  68784. diffuseTexture4: BABYLON.Texture;
  68785. private _diffuseTexture5;
  68786. diffuseTexture5: BABYLON.Texture;
  68787. private _diffuseTexture6;
  68788. diffuseTexture6: BABYLON.Texture;
  68789. private _diffuseTexture7;
  68790. diffuseTexture7: BABYLON.Texture;
  68791. private _diffuseTexture8;
  68792. diffuseTexture8: BABYLON.Texture;
  68793. /**
  68794. * Uniforms
  68795. */
  68796. diffuseColor: BABYLON.Color3;
  68797. specularColor: BABYLON.Color3;
  68798. specularPower: number;
  68799. private _disableLighting;
  68800. disableLighting: boolean;
  68801. private _maxSimultaneousLights;
  68802. maxSimultaneousLights: number;
  68803. private _renderId;
  68804. constructor(name: string, scene: BABYLON.Scene);
  68805. needAlphaBlending(): boolean;
  68806. needAlphaTesting(): boolean;
  68807. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68808. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68809. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68810. getAnimatables(): BABYLON.IAnimatable[];
  68811. getActiveTextures(): BABYLON.BaseTexture[];
  68812. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68813. dispose(forceDisposeEffect?: boolean): void;
  68814. clone(name: string): MixMaterial;
  68815. serialize(): any;
  68816. getClassName(): string;
  68817. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): MixMaterial;
  68818. }
  68819. }
  68820. declare module BABYLON {
  68821. /** @hidden */
  68822. export var normalPixelShader: {
  68823. name: string;
  68824. shader: string;
  68825. };
  68826. }
  68827. declare module BABYLON {
  68828. /** @hidden */
  68829. export var normalVertexShader: {
  68830. name: string;
  68831. shader: string;
  68832. };
  68833. }
  68834. declare module BABYLON {
  68835. export class NormalMaterial extends BABYLON.PushMaterial {
  68836. private _diffuseTexture;
  68837. diffuseTexture: BABYLON.BaseTexture;
  68838. diffuseColor: BABYLON.Color3;
  68839. private _disableLighting;
  68840. disableLighting: boolean;
  68841. private _maxSimultaneousLights;
  68842. maxSimultaneousLights: number;
  68843. private _renderId;
  68844. constructor(name: string, scene: BABYLON.Scene);
  68845. needAlphaBlending(): boolean;
  68846. needAlphaBlendingForMesh(mesh: BABYLON.AbstractMesh): boolean;
  68847. needAlphaTesting(): boolean;
  68848. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68849. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68850. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68851. getAnimatables(): BABYLON.IAnimatable[];
  68852. getActiveTextures(): BABYLON.BaseTexture[];
  68853. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68854. dispose(forceDisposeEffect?: boolean): void;
  68855. clone(name: string): NormalMaterial;
  68856. serialize(): any;
  68857. getClassName(): string;
  68858. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): NormalMaterial;
  68859. }
  68860. }
  68861. declare module BABYLON {
  68862. /** @hidden */
  68863. export var shadowOnlyPixelShader: {
  68864. name: string;
  68865. shader: string;
  68866. };
  68867. }
  68868. declare module BABYLON {
  68869. /** @hidden */
  68870. export var shadowOnlyVertexShader: {
  68871. name: string;
  68872. shader: string;
  68873. };
  68874. }
  68875. declare module BABYLON {
  68876. export class ShadowOnlyMaterial extends BABYLON.PushMaterial {
  68877. private _renderId;
  68878. private _activeLight;
  68879. constructor(name: string, scene: BABYLON.Scene);
  68880. shadowColor: BABYLON.Color3;
  68881. needAlphaBlending(): boolean;
  68882. needAlphaTesting(): boolean;
  68883. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68884. activeLight: BABYLON.IShadowLight;
  68885. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68886. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68887. clone(name: string): ShadowOnlyMaterial;
  68888. serialize(): any;
  68889. getClassName(): string;
  68890. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): ShadowOnlyMaterial;
  68891. }
  68892. }
  68893. declare module BABYLON {
  68894. /** @hidden */
  68895. export var simplePixelShader: {
  68896. name: string;
  68897. shader: string;
  68898. };
  68899. }
  68900. declare module BABYLON {
  68901. /** @hidden */
  68902. export var simpleVertexShader: {
  68903. name: string;
  68904. shader: string;
  68905. };
  68906. }
  68907. declare module BABYLON {
  68908. export class SimpleMaterial extends BABYLON.PushMaterial {
  68909. private _diffuseTexture;
  68910. diffuseTexture: BABYLON.BaseTexture;
  68911. diffuseColor: BABYLON.Color3;
  68912. private _disableLighting;
  68913. disableLighting: boolean;
  68914. private _maxSimultaneousLights;
  68915. maxSimultaneousLights: number;
  68916. private _renderId;
  68917. constructor(name: string, scene: BABYLON.Scene);
  68918. needAlphaBlending(): boolean;
  68919. needAlphaTesting(): boolean;
  68920. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  68921. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  68922. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  68923. getAnimatables(): BABYLON.IAnimatable[];
  68924. getActiveTextures(): BABYLON.BaseTexture[];
  68925. hasTexture(texture: BABYLON.BaseTexture): boolean;
  68926. dispose(forceDisposeEffect?: boolean): void;
  68927. clone(name: string): SimpleMaterial;
  68928. serialize(): any;
  68929. getClassName(): string;
  68930. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SimpleMaterial;
  68931. }
  68932. }
  68933. declare module BABYLON {
  68934. /** @hidden */
  68935. export var skyPixelShader: {
  68936. name: string;
  68937. shader: string;
  68938. };
  68939. }
  68940. declare module BABYLON {
  68941. /** @hidden */
  68942. export var skyVertexShader: {
  68943. name: string;
  68944. shader: string;
  68945. };
  68946. }
  68947. declare module BABYLON {
  68948. /**
  68949. * This is the sky material which allows to create dynamic and texture free effects for skyboxes.
  68950. * @see https://doc.babylonjs.com/extensions/sky
  68951. */
  68952. export class SkyMaterial extends BABYLON.PushMaterial {
  68953. /**
  68954. * Defines the overall luminance of sky in interval ]0, 1[.
  68955. */
  68956. luminance: number;
  68957. /**
  68958. * Defines the amount (scattering) of haze as opposed to molecules in atmosphere.
  68959. */
  68960. turbidity: number;
  68961. /**
  68962. * Defines the sky appearance (light intensity).
  68963. */
  68964. rayleigh: number;
  68965. /**
  68966. * Defines the mieCoefficient in interval [0, 0.1] which affects the property .mieDirectionalG.
  68967. */
  68968. mieCoefficient: number;
  68969. /**
  68970. * Defines the amount of haze particles following the Mie scattering theory.
  68971. */
  68972. mieDirectionalG: number;
  68973. /**
  68974. * Defines the distance of the sun according to the active scene camera.
  68975. */
  68976. distance: number;
  68977. /**
  68978. * Defines the sun inclination, in interval [-0.5, 0.5]. When the inclination is not 0, the sun is said
  68979. * "inclined".
  68980. */
  68981. inclination: number;
  68982. /**
  68983. * Defines the solar azimuth in interval [0, 1]. The azimuth is the angle in the horizontal plan between
  68984. * an object direction and a reference direction.
  68985. */
  68986. azimuth: number;
  68987. /**
  68988. * Defines the sun position in the sky on (x,y,z). If the property .useSunPosition is set to false, then
  68989. * the property is overriden by the inclination and the azimuth and can be read at any moment.
  68990. */
  68991. sunPosition: BABYLON.Vector3;
  68992. /**
  68993. * Defines if the sun position should be computed (inclination and azimuth) according to the given
  68994. * .sunPosition property.
  68995. */
  68996. useSunPosition: boolean;
  68997. /**
  68998. * Defines an offset vector used to get a horizon offset.
  68999. * @example skyMaterial.cameraOffset.y = camera.globalPosition.y // Set horizon relative to 0 on the Y axis
  69000. */
  69001. cameraOffset: BABYLON.Vector3;
  69002. private _cameraPosition;
  69003. private _renderId;
  69004. /**
  69005. * Instantiates a new sky material.
  69006. * This material allows to create dynamic and texture free
  69007. * effects for skyboxes by taking care of the atmosphere state.
  69008. * @see https://doc.babylonjs.com/extensions/sky
  69009. * @param name Define the name of the material in the scene
  69010. * @param scene Define the scene the material belong to
  69011. */
  69012. constructor(name: string, scene: BABYLON.Scene);
  69013. /**
  69014. * Specifies if the material will require alpha blending
  69015. * @returns a boolean specifying if alpha blending is needed
  69016. */
  69017. needAlphaBlending(): boolean;
  69018. /**
  69019. * Specifies if this material should be rendered in alpha test mode
  69020. * @returns false as the sky material doesn't need alpha testing.
  69021. */
  69022. needAlphaTesting(): boolean;
  69023. /**
  69024. * Get the texture used for alpha test purpose.
  69025. * @returns null as the sky material has no texture.
  69026. */
  69027. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69028. /**
  69029. * Get if the submesh is ready to be used and all its information available.
  69030. * Child classes can use it to update shaders
  69031. * @param mesh defines the mesh to check
  69032. * @param subMesh defines which submesh to check
  69033. * @param useInstances specifies that instances should be used
  69034. * @returns a boolean indicating that the submesh is ready or not
  69035. */
  69036. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69037. /**
  69038. * Binds the submesh to this material by preparing the effect and shader to draw
  69039. * @param world defines the world transformation matrix
  69040. * @param mesh defines the mesh containing the submesh
  69041. * @param subMesh defines the submesh to bind the material to
  69042. */
  69043. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69044. /**
  69045. * Get the list of animatables in the material.
  69046. * @returns the list of animatables object used in the material
  69047. */
  69048. getAnimatables(): BABYLON.IAnimatable[];
  69049. /**
  69050. * Disposes the material
  69051. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  69052. */
  69053. dispose(forceDisposeEffect?: boolean): void;
  69054. /**
  69055. * Makes a duplicate of the material, and gives it a new name
  69056. * @param name defines the new name for the duplicated material
  69057. * @returns the cloned material
  69058. */
  69059. clone(name: string): SkyMaterial;
  69060. /**
  69061. * Serializes this material in a JSON representation
  69062. * @returns the serialized material object
  69063. */
  69064. serialize(): any;
  69065. /**
  69066. * Gets the current class name of the material e.g. "SkyMaterial"
  69067. * Mainly use in serialization.
  69068. * @returns the class name
  69069. */
  69070. getClassName(): string;
  69071. /**
  69072. * Creates a sky material from parsed material data
  69073. * @param source defines the JSON representation of the material
  69074. * @param scene defines the hosting scene
  69075. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  69076. * @returns a new sky material
  69077. */
  69078. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): SkyMaterial;
  69079. }
  69080. }
  69081. declare module BABYLON {
  69082. /** @hidden */
  69083. export var terrainPixelShader: {
  69084. name: string;
  69085. shader: string;
  69086. };
  69087. }
  69088. declare module BABYLON {
  69089. /** @hidden */
  69090. export var terrainVertexShader: {
  69091. name: string;
  69092. shader: string;
  69093. };
  69094. }
  69095. declare module BABYLON {
  69096. export class TerrainMaterial extends BABYLON.PushMaterial {
  69097. private _mixTexture;
  69098. mixTexture: BABYLON.BaseTexture;
  69099. private _diffuseTexture1;
  69100. diffuseTexture1: BABYLON.Texture;
  69101. private _diffuseTexture2;
  69102. diffuseTexture2: BABYLON.Texture;
  69103. private _diffuseTexture3;
  69104. diffuseTexture3: BABYLON.Texture;
  69105. private _bumpTexture1;
  69106. bumpTexture1: BABYLON.Texture;
  69107. private _bumpTexture2;
  69108. bumpTexture2: BABYLON.Texture;
  69109. private _bumpTexture3;
  69110. bumpTexture3: BABYLON.Texture;
  69111. diffuseColor: BABYLON.Color3;
  69112. specularColor: BABYLON.Color3;
  69113. specularPower: number;
  69114. private _disableLighting;
  69115. disableLighting: boolean;
  69116. private _maxSimultaneousLights;
  69117. maxSimultaneousLights: number;
  69118. private _renderId;
  69119. constructor(name: string, scene: BABYLON.Scene);
  69120. needAlphaBlending(): boolean;
  69121. needAlphaTesting(): boolean;
  69122. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69123. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69124. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69125. getAnimatables(): BABYLON.IAnimatable[];
  69126. getActiveTextures(): BABYLON.BaseTexture[];
  69127. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69128. dispose(forceDisposeEffect?: boolean): void;
  69129. clone(name: string): TerrainMaterial;
  69130. serialize(): any;
  69131. getClassName(): string;
  69132. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TerrainMaterial;
  69133. }
  69134. }
  69135. declare module BABYLON {
  69136. /** @hidden */
  69137. export var triplanarPixelShader: {
  69138. name: string;
  69139. shader: string;
  69140. };
  69141. }
  69142. declare module BABYLON {
  69143. /** @hidden */
  69144. export var triplanarVertexShader: {
  69145. name: string;
  69146. shader: string;
  69147. };
  69148. }
  69149. declare module BABYLON {
  69150. export class TriPlanarMaterial extends BABYLON.PushMaterial {
  69151. mixTexture: BABYLON.BaseTexture;
  69152. private _diffuseTextureX;
  69153. diffuseTextureX: BABYLON.BaseTexture;
  69154. private _diffuseTextureY;
  69155. diffuseTextureY: BABYLON.BaseTexture;
  69156. private _diffuseTextureZ;
  69157. diffuseTextureZ: BABYLON.BaseTexture;
  69158. private _normalTextureX;
  69159. normalTextureX: BABYLON.BaseTexture;
  69160. private _normalTextureY;
  69161. normalTextureY: BABYLON.BaseTexture;
  69162. private _normalTextureZ;
  69163. normalTextureZ: BABYLON.BaseTexture;
  69164. tileSize: number;
  69165. diffuseColor: BABYLON.Color3;
  69166. specularColor: BABYLON.Color3;
  69167. specularPower: number;
  69168. private _disableLighting;
  69169. disableLighting: boolean;
  69170. private _maxSimultaneousLights;
  69171. maxSimultaneousLights: number;
  69172. private _renderId;
  69173. constructor(name: string, scene: BABYLON.Scene);
  69174. needAlphaBlending(): boolean;
  69175. needAlphaTesting(): boolean;
  69176. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69177. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69178. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69179. getAnimatables(): BABYLON.IAnimatable[];
  69180. getActiveTextures(): BABYLON.BaseTexture[];
  69181. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69182. dispose(forceDisposeEffect?: boolean): void;
  69183. clone(name: string): TriPlanarMaterial;
  69184. serialize(): any;
  69185. getClassName(): string;
  69186. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): TriPlanarMaterial;
  69187. }
  69188. }
  69189. declare module BABYLON {
  69190. /** @hidden */
  69191. export var waterPixelShader: {
  69192. name: string;
  69193. shader: string;
  69194. };
  69195. }
  69196. declare module BABYLON {
  69197. /** @hidden */
  69198. export var waterVertexShader: {
  69199. name: string;
  69200. shader: string;
  69201. };
  69202. }
  69203. declare module BABYLON {
  69204. export class WaterMaterial extends BABYLON.PushMaterial {
  69205. renderTargetSize: BABYLON.Vector2;
  69206. private _bumpTexture;
  69207. bumpTexture: BABYLON.BaseTexture;
  69208. diffuseColor: BABYLON.Color3;
  69209. specularColor: BABYLON.Color3;
  69210. specularPower: number;
  69211. private _disableLighting;
  69212. disableLighting: boolean;
  69213. private _maxSimultaneousLights;
  69214. maxSimultaneousLights: number;
  69215. /**
  69216. * @param {number}: Represents the wind force
  69217. */
  69218. windForce: number;
  69219. /**
  69220. * @param {Vector2}: The direction of the wind in the plane (X, Z)
  69221. */
  69222. windDirection: BABYLON.Vector2;
  69223. /**
  69224. * @param {number}: Wave height, represents the height of the waves
  69225. */
  69226. waveHeight: number;
  69227. /**
  69228. * @param {number}: Bump height, represents the bump height related to the bump map
  69229. */
  69230. bumpHeight: number;
  69231. /**
  69232. * @param {boolean}: Add a smaller moving bump to less steady waves.
  69233. */
  69234. private _bumpSuperimpose;
  69235. bumpSuperimpose: boolean;
  69236. /**
  69237. * @param {boolean}: Color refraction and reflection differently with .waterColor2 and .colorBlendFactor2. Non-linear (physically correct) fresnel.
  69238. */
  69239. private _fresnelSeparate;
  69240. fresnelSeparate: boolean;
  69241. /**
  69242. * @param {boolean}: bump Waves modify the reflection.
  69243. */
  69244. private _bumpAffectsReflection;
  69245. bumpAffectsReflection: boolean;
  69246. /**
  69247. * @param {number}: The water color blended with the refraction (near)
  69248. */
  69249. waterColor: BABYLON.Color3;
  69250. /**
  69251. * @param {number}: The blend factor related to the water color
  69252. */
  69253. colorBlendFactor: number;
  69254. /**
  69255. * @param {number}: The water color blended with the reflection (far)
  69256. */
  69257. waterColor2: BABYLON.Color3;
  69258. /**
  69259. * @param {number}: The blend factor related to the water color (reflection, far)
  69260. */
  69261. colorBlendFactor2: number;
  69262. /**
  69263. * @param {number}: Represents the maximum length of a wave
  69264. */
  69265. waveLength: number;
  69266. /**
  69267. * @param {number}: Defines the waves speed
  69268. */
  69269. waveSpeed: number;
  69270. /**
  69271. * Sets or gets wether or not automatic clipping should be enabled or not. Setting to true will save performances and
  69272. * will avoid calculating useless pixels in the pixel shader of the water material.
  69273. */
  69274. disableClipPlane: boolean;
  69275. protected _renderTargets: BABYLON.SmartArray<BABYLON.RenderTargetTexture>;
  69276. private _mesh;
  69277. private _refractionRTT;
  69278. private _reflectionRTT;
  69279. private _reflectionTransform;
  69280. private _lastTime;
  69281. private _lastDeltaTime;
  69282. private _renderId;
  69283. private _useLogarithmicDepth;
  69284. private _waitingRenderList;
  69285. private _imageProcessingConfiguration;
  69286. private _imageProcessingObserver;
  69287. /**
  69288. * Gets a boolean indicating that current material needs to register RTT
  69289. */
  69290. readonly hasRenderTargetTextures: boolean;
  69291. /**
  69292. * Constructor
  69293. */
  69294. constructor(name: string, scene: BABYLON.Scene, renderTargetSize?: BABYLON.Vector2);
  69295. useLogarithmicDepth: boolean;
  69296. readonly refractionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69297. readonly reflectionTexture: BABYLON.Nullable<BABYLON.RenderTargetTexture>;
  69298. addToRenderList(node: any): void;
  69299. enableRenderTargets(enable: boolean): void;
  69300. getRenderList(): BABYLON.Nullable<BABYLON.AbstractMesh[]>;
  69301. readonly renderTargetsEnabled: boolean;
  69302. needAlphaBlending(): boolean;
  69303. needAlphaTesting(): boolean;
  69304. getAlphaTestTexture(): BABYLON.Nullable<BABYLON.BaseTexture>;
  69305. isReadyForSubMesh(mesh: BABYLON.AbstractMesh, subMesh: BABYLON.SubMesh, useInstances?: boolean): boolean;
  69306. bindForSubMesh(world: BABYLON.Matrix, mesh: BABYLON.Mesh, subMesh: BABYLON.SubMesh): void;
  69307. private _createRenderTargets;
  69308. getAnimatables(): BABYLON.IAnimatable[];
  69309. getActiveTextures(): BABYLON.BaseTexture[];
  69310. hasTexture(texture: BABYLON.BaseTexture): boolean;
  69311. dispose(forceDisposeEffect?: boolean): void;
  69312. clone(name: string): WaterMaterial;
  69313. serialize(): any;
  69314. getClassName(): string;
  69315. static Parse(source: any, scene: BABYLON.Scene, rootUrl: string): WaterMaterial;
  69316. static CreateDefaultMesh(name: string, scene: BABYLON.Scene): BABYLON.Mesh;
  69317. }
  69318. }
  69319. declare module BABYLON {
  69320. /** @hidden */
  69321. export var asciiartPixelShader: {
  69322. name: string;
  69323. shader: string;
  69324. };
  69325. }
  69326. declare module BABYLON {
  69327. /**
  69328. * AsciiArtFontTexture is the helper class used to easily create your ascii art font texture.
  69329. *
  69330. * It basically takes care rendering the font front the given font size to a texture.
  69331. * This is used later on in the postprocess.
  69332. */
  69333. export class AsciiArtFontTexture extends BABYLON.BaseTexture {
  69334. private _font;
  69335. private _text;
  69336. private _charSize;
  69337. /**
  69338. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69339. */
  69340. readonly charSize: number;
  69341. /**
  69342. * Create a new instance of the Ascii Art FontTexture class
  69343. * @param name the name of the texture
  69344. * @param font the font to use, use the W3C CSS notation
  69345. * @param text the caracter set to use in the rendering.
  69346. * @param scene the scene that owns the texture
  69347. */
  69348. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69349. /**
  69350. * Gets the max char width of a font.
  69351. * @param font the font to use, use the W3C CSS notation
  69352. * @return the max char width
  69353. */
  69354. private getFontWidth;
  69355. /**
  69356. * Gets the max char height of a font.
  69357. * @param font the font to use, use the W3C CSS notation
  69358. * @return the max char height
  69359. */
  69360. private getFontHeight;
  69361. /**
  69362. * Clones the current AsciiArtTexture.
  69363. * @return the clone of the texture.
  69364. */
  69365. clone(): AsciiArtFontTexture;
  69366. /**
  69367. * Parses a json object representing the texture and returns an instance of it.
  69368. * @param source the source JSON representation
  69369. * @param scene the scene to create the texture for
  69370. * @return the parsed texture
  69371. */
  69372. static Parse(source: any, scene: BABYLON.Scene): AsciiArtFontTexture;
  69373. }
  69374. /**
  69375. * Option available in the Ascii Art Post Process.
  69376. */
  69377. export interface IAsciiArtPostProcessOptions {
  69378. /**
  69379. * The font to use following the w3c font definition.
  69380. */
  69381. font?: string;
  69382. /**
  69383. * The character set to use in the postprocess.
  69384. */
  69385. characterSet?: string;
  69386. /**
  69387. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69388. * This number is defined between 0 and 1;
  69389. */
  69390. mixToTile?: number;
  69391. /**
  69392. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69393. * This number is defined between 0 and 1;
  69394. */
  69395. mixToNormal?: number;
  69396. }
  69397. /**
  69398. * AsciiArtPostProcess helps rendering everithing in Ascii Art.
  69399. *
  69400. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69401. * Example usage: var pp = new AsciiArtPostProcess("myAscii", "20px Monospace", camera);
  69402. */
  69403. export class AsciiArtPostProcess extends BABYLON.PostProcess {
  69404. /**
  69405. * The font texture used to render the char in the post process.
  69406. */
  69407. private _asciiArtFontTexture;
  69408. /**
  69409. * This defines the amount you want to mix the "tile" or caracter space colored in the ascii art.
  69410. * This number is defined between 0 and 1;
  69411. */
  69412. mixToTile: number;
  69413. /**
  69414. * This defines the amount you want to mix the normal rendering pass in the ascii art.
  69415. * This number is defined between 0 and 1;
  69416. */
  69417. mixToNormal: number;
  69418. /**
  69419. * Instantiates a new Ascii Art Post Process.
  69420. * @param name the name to give to the postprocess
  69421. * @camera the camera to apply the post process to.
  69422. * @param options can either be the font name or an option object following the IAsciiArtPostProcessOptions format
  69423. */
  69424. constructor(name: string, camera: BABYLON.Camera, options?: string | IAsciiArtPostProcessOptions);
  69425. }
  69426. }
  69427. declare module BABYLON {
  69428. /** @hidden */
  69429. export var digitalrainPixelShader: {
  69430. name: string;
  69431. shader: string;
  69432. };
  69433. }
  69434. declare module BABYLON {
  69435. /**
  69436. * DigitalRainFontTexture is the helper class used to easily create your digital rain font texture.
  69437. *
  69438. * It basically takes care rendering the font front the given font size to a texture.
  69439. * This is used later on in the postprocess.
  69440. */
  69441. export class DigitalRainFontTexture extends BABYLON.BaseTexture {
  69442. private _font;
  69443. private _text;
  69444. private _charSize;
  69445. /**
  69446. * Gets the size of one char in the texture (each char fits in size * size space in the texture).
  69447. */
  69448. readonly charSize: number;
  69449. /**
  69450. * Create a new instance of the Digital Rain FontTexture class
  69451. * @param name the name of the texture
  69452. * @param font the font to use, use the W3C CSS notation
  69453. * @param text the caracter set to use in the rendering.
  69454. * @param scene the scene that owns the texture
  69455. */
  69456. constructor(name: string, font: string, text: string, scene?: BABYLON.Nullable<BABYLON.Scene>);
  69457. /**
  69458. * Gets the max char width of a font.
  69459. * @param font the font to use, use the W3C CSS notation
  69460. * @return the max char width
  69461. */
  69462. private getFontWidth;
  69463. /**
  69464. * Gets the max char height of a font.
  69465. * @param font the font to use, use the W3C CSS notation
  69466. * @return the max char height
  69467. */
  69468. private getFontHeight;
  69469. /**
  69470. * Clones the current DigitalRainFontTexture.
  69471. * @return the clone of the texture.
  69472. */
  69473. clone(): DigitalRainFontTexture;
  69474. /**
  69475. * Parses a json object representing the texture and returns an instance of it.
  69476. * @param source the source JSON representation
  69477. * @param scene the scene to create the texture for
  69478. * @return the parsed texture
  69479. */
  69480. static Parse(source: any, scene: BABYLON.Scene): DigitalRainFontTexture;
  69481. }
  69482. /**
  69483. * Option available in the Digital Rain Post Process.
  69484. */
  69485. export interface IDigitalRainPostProcessOptions {
  69486. /**
  69487. * The font to use following the w3c font definition.
  69488. */
  69489. font?: string;
  69490. /**
  69491. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69492. * This number is defined between 0 and 1;
  69493. */
  69494. mixToTile?: number;
  69495. /**
  69496. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69497. * This number is defined between 0 and 1;
  69498. */
  69499. mixToNormal?: number;
  69500. }
  69501. /**
  69502. * DigitalRainPostProcess helps rendering everithing in digital rain.
  69503. *
  69504. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69505. * Example usage: var pp = new DigitalRainPostProcess("digitalRain", "20px Monospace", camera);
  69506. */
  69507. export class DigitalRainPostProcess extends BABYLON.PostProcess {
  69508. /**
  69509. * The font texture used to render the char in the post process.
  69510. */
  69511. private _digitalRainFontTexture;
  69512. /**
  69513. * This defines the amount you want to mix the "tile" or caracter space colored in the digital rain.
  69514. * This number is defined between 0 and 1;
  69515. */
  69516. mixToTile: number;
  69517. /**
  69518. * This defines the amount you want to mix the normal rendering pass in the digital rain.
  69519. * This number is defined between 0 and 1;
  69520. */
  69521. mixToNormal: number;
  69522. /**
  69523. * Instantiates a new Digital Rain Post Process.
  69524. * @param name the name to give to the postprocess
  69525. * @camera the camera to apply the post process to.
  69526. * @param options can either be the font name or an option object following the IDigitalRainPostProcessOptions format
  69527. */
  69528. constructor(name: string, camera: BABYLON.Camera, options?: string | IDigitalRainPostProcessOptions);
  69529. }
  69530. }
  69531. declare module BABYLON {
  69532. /** @hidden */
  69533. export var oceanPostProcessPixelShader: {
  69534. name: string;
  69535. shader: string;
  69536. };
  69537. }
  69538. declare module BABYLON {
  69539. /**
  69540. * Option available in the Ocean Post Process.
  69541. */
  69542. export interface IOceanPostProcessOptions {
  69543. /**
  69544. * The size of the reflection RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69545. */
  69546. reflectionSize?: number | {
  69547. width: number;
  69548. height: number;
  69549. } | {
  69550. ratio: number;
  69551. };
  69552. /**
  69553. * The size of the refraction RTT (number if square, or {width: number, height:number} or {ratio:} to define a ratio from the main scene)
  69554. */
  69555. refractionSize?: number | {
  69556. width: number;
  69557. height: number;
  69558. } | {
  69559. ratio: number;
  69560. };
  69561. }
  69562. /**
  69563. * OceanPostProcess helps rendering an infinite ocean surface that can reflect and refract environment.
  69564. *
  69565. * Simmply add it to your scene and let the nerd that lives in you have fun.
  69566. * Example usage:
  69567. * var pp = new OceanPostProcess("myOcean", camera);
  69568. * pp.reflectionEnabled = true;
  69569. * pp.refractionEnabled = true;
  69570. */
  69571. export class OceanPostProcess extends BABYLON.PostProcess {
  69572. /**
  69573. * Gets a boolean indicating if the real-time reflection is enabled on the ocean.
  69574. */
  69575. /**
  69576. * Sets weither or not the real-time reflection is enabled on the ocean.
  69577. * Is set to true, the reflection mirror texture will be used as reflection texture.
  69578. */
  69579. reflectionEnabled: boolean;
  69580. /**
  69581. * Gets a boolean indicating if the real-time refraction is enabled on the ocean.
  69582. */
  69583. /**
  69584. * Sets weither or not the real-time refraction is enabled on the ocean.
  69585. * Is set to true, the refraction render target texture will be used as refraction texture.
  69586. */
  69587. refractionEnabled: boolean;
  69588. /**
  69589. * Gets wether or not the post-processes is supported by the running hardware.
  69590. * This requires draw buffer supports.
  69591. */
  69592. readonly isSupported: boolean;
  69593. /**
  69594. * This is the reflection mirror texture used to display reflections on the ocean.
  69595. * By default, render list is empty.
  69596. */
  69597. reflectionTexture: BABYLON.MirrorTexture;
  69598. /**
  69599. * This is the refraction render target texture used to display refraction on the ocean.
  69600. * By default, render list is empty.
  69601. */
  69602. refractionTexture: BABYLON.RenderTargetTexture;
  69603. private _time;
  69604. private _cameraRotation;
  69605. private _cameraViewMatrix;
  69606. private _reflectionEnabled;
  69607. private _refractionEnabled;
  69608. private _geometryRenderer;
  69609. /**
  69610. * Instantiates a new Ocean Post Process.
  69611. * @param name the name to give to the postprocess.
  69612. * @camera the camera to apply the post process to.
  69613. * @param options optional object following the IOceanPostProcessOptions format used to customize reflection and refraction render targets sizes.
  69614. */
  69615. constructor(name: string, camera: BABYLON.TargetCamera, options?: IOceanPostProcessOptions);
  69616. /**
  69617. * Returns the appropriate defines according to the current configuration.
  69618. */
  69619. private _getDefines;
  69620. /**
  69621. * Computes the current camera rotation as the shader requires a camera rotation.
  69622. */
  69623. private _computeCameraRotation;
  69624. }
  69625. }
  69626. declare module BABYLON {
  69627. /** @hidden */
  69628. export var brickProceduralTexturePixelShader: {
  69629. name: string;
  69630. shader: string;
  69631. };
  69632. }
  69633. declare module BABYLON {
  69634. export class BrickProceduralTexture extends BABYLON.ProceduralTexture {
  69635. private _numberOfBricksHeight;
  69636. private _numberOfBricksWidth;
  69637. private _jointColor;
  69638. private _brickColor;
  69639. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69640. updateShaderUniforms(): void;
  69641. numberOfBricksHeight: number;
  69642. numberOfBricksWidth: number;
  69643. jointColor: BABYLON.Color3;
  69644. brickColor: BABYLON.Color3;
  69645. /**
  69646. * Serializes this brick procedural texture
  69647. * @returns a serialized brick procedural texture object
  69648. */
  69649. serialize(): any;
  69650. /**
  69651. * Creates a Brick Procedural BABYLON.Texture from parsed brick procedural texture data
  69652. * @param parsedTexture defines parsed texture data
  69653. * @param scene defines the current scene
  69654. * @param rootUrl defines the root URL containing brick procedural texture information
  69655. * @returns a parsed Brick Procedural BABYLON.Texture
  69656. */
  69657. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): BrickProceduralTexture;
  69658. }
  69659. }
  69660. declare module BABYLON {
  69661. /** @hidden */
  69662. export var cloudProceduralTexturePixelShader: {
  69663. name: string;
  69664. shader: string;
  69665. };
  69666. }
  69667. declare module BABYLON {
  69668. export class CloudProceduralTexture extends BABYLON.ProceduralTexture {
  69669. private _skyColor;
  69670. private _cloudColor;
  69671. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69672. updateShaderUniforms(): void;
  69673. skyColor: BABYLON.Color4;
  69674. cloudColor: BABYLON.Color4;
  69675. /**
  69676. * Serializes this cloud procedural texture
  69677. * @returns a serialized cloud procedural texture object
  69678. */
  69679. serialize(): any;
  69680. /**
  69681. * Creates a Cloud Procedural BABYLON.Texture from parsed cloud procedural texture data
  69682. * @param parsedTexture defines parsed texture data
  69683. * @param scene defines the current scene
  69684. * @param rootUrl defines the root URL containing cloud procedural texture information
  69685. * @returns a parsed Cloud Procedural BABYLON.Texture
  69686. */
  69687. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): CloudProceduralTexture;
  69688. }
  69689. }
  69690. declare module BABYLON {
  69691. /** @hidden */
  69692. export var fireProceduralTexturePixelShader: {
  69693. name: string;
  69694. shader: string;
  69695. };
  69696. }
  69697. declare module BABYLON {
  69698. export class FireProceduralTexture extends BABYLON.ProceduralTexture {
  69699. private _time;
  69700. private _speed;
  69701. private _autoGenerateTime;
  69702. private _fireColors;
  69703. private _alphaThreshold;
  69704. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69705. updateShaderUniforms(): void;
  69706. render(useCameraPostProcess?: boolean): void;
  69707. static readonly PurpleFireColors: BABYLON.Color3[];
  69708. static readonly GreenFireColors: BABYLON.Color3[];
  69709. static readonly RedFireColors: BABYLON.Color3[];
  69710. static readonly BlueFireColors: BABYLON.Color3[];
  69711. autoGenerateTime: boolean;
  69712. fireColors: BABYLON.Color3[];
  69713. time: number;
  69714. speed: BABYLON.Vector2;
  69715. alphaThreshold: number;
  69716. /**
  69717. * Serializes this fire procedural texture
  69718. * @returns a serialized fire procedural texture object
  69719. */
  69720. serialize(): any;
  69721. /**
  69722. * Creates a Fire Procedural BABYLON.Texture from parsed fire procedural texture data
  69723. * @param parsedTexture defines parsed texture data
  69724. * @param scene defines the current scene
  69725. * @param rootUrl defines the root URL containing fire procedural texture information
  69726. * @returns a parsed Fire Procedural BABYLON.Texture
  69727. */
  69728. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): FireProceduralTexture;
  69729. }
  69730. }
  69731. declare module BABYLON {
  69732. /** @hidden */
  69733. export var grassProceduralTexturePixelShader: {
  69734. name: string;
  69735. shader: string;
  69736. };
  69737. }
  69738. declare module BABYLON {
  69739. export class GrassProceduralTexture extends BABYLON.ProceduralTexture {
  69740. private _grassColors;
  69741. private _groundColor;
  69742. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69743. updateShaderUniforms(): void;
  69744. grassColors: BABYLON.Color3[];
  69745. groundColor: BABYLON.Color3;
  69746. /**
  69747. * Serializes this grass procedural texture
  69748. * @returns a serialized grass procedural texture object
  69749. */
  69750. serialize(): any;
  69751. /**
  69752. * Creates a Grass Procedural BABYLON.Texture from parsed grass procedural texture data
  69753. * @param parsedTexture defines parsed texture data
  69754. * @param scene defines the current scene
  69755. * @param rootUrl defines the root URL containing grass procedural texture information
  69756. * @returns a parsed Grass Procedural BABYLON.Texture
  69757. */
  69758. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): GrassProceduralTexture;
  69759. }
  69760. }
  69761. declare module BABYLON {
  69762. /** @hidden */
  69763. export var marbleProceduralTexturePixelShader: {
  69764. name: string;
  69765. shader: string;
  69766. };
  69767. }
  69768. declare module BABYLON {
  69769. export class MarbleProceduralTexture extends BABYLON.ProceduralTexture {
  69770. private _numberOfTilesHeight;
  69771. private _numberOfTilesWidth;
  69772. private _amplitude;
  69773. private _jointColor;
  69774. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69775. updateShaderUniforms(): void;
  69776. numberOfTilesHeight: number;
  69777. amplitude: number;
  69778. numberOfTilesWidth: number;
  69779. jointColor: BABYLON.Color3;
  69780. /**
  69781. * Serializes this marble procedural texture
  69782. * @returns a serialized marble procedural texture object
  69783. */
  69784. serialize(): any;
  69785. /**
  69786. * Creates a Marble Procedural BABYLON.Texture from parsed marble procedural texture data
  69787. * @param parsedTexture defines parsed texture data
  69788. * @param scene defines the current scene
  69789. * @param rootUrl defines the root URL containing marble procedural texture information
  69790. * @returns a parsed Marble Procedural BABYLON.Texture
  69791. */
  69792. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): MarbleProceduralTexture;
  69793. }
  69794. }
  69795. declare module BABYLON {
  69796. /** @hidden */
  69797. export var normalMapProceduralTexturePixelShader: {
  69798. name: string;
  69799. shader: string;
  69800. };
  69801. }
  69802. declare module BABYLON {
  69803. export class NormalMapProceduralTexture extends BABYLON.ProceduralTexture {
  69804. private _baseTexture;
  69805. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69806. updateShaderUniforms(): void;
  69807. render(useCameraPostProcess?: boolean): void;
  69808. resize(size: any, generateMipMaps: any): void;
  69809. baseTexture: BABYLON.Texture;
  69810. /**
  69811. * Serializes this normal map procedural texture
  69812. * @returns a serialized normal map procedural texture object
  69813. */
  69814. serialize(): any;
  69815. /**
  69816. * Creates a Normal Map Procedural BABYLON.Texture from parsed normal map procedural texture data
  69817. * @param parsedTexture defines parsed texture data
  69818. * @param scene defines the current scene
  69819. * @param rootUrl defines the root URL containing normal map procedural texture information
  69820. * @returns a parsed Normal Map Procedural BABYLON.Texture
  69821. */
  69822. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): NormalMapProceduralTexture;
  69823. }
  69824. }
  69825. declare module BABYLON {
  69826. /** @hidden */
  69827. export var perlinNoiseProceduralTexturePixelShader: {
  69828. name: string;
  69829. shader: string;
  69830. };
  69831. }
  69832. declare module BABYLON {
  69833. export class PerlinNoiseProceduralTexture extends BABYLON.ProceduralTexture {
  69834. time: number;
  69835. timeScale: number;
  69836. translationSpeed: number;
  69837. private _currentTranslation;
  69838. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69839. updateShaderUniforms(): void;
  69840. render(useCameraPostProcess?: boolean): void;
  69841. resize(size: any, generateMipMaps: any): void;
  69842. /**
  69843. * Serializes this perlin noise procedural texture
  69844. * @returns a serialized perlin noise procedural texture object
  69845. */
  69846. serialize(): any;
  69847. /**
  69848. * Creates a Perlin Noise Procedural BABYLON.Texture from parsed perlin noise procedural texture data
  69849. * @param parsedTexture defines parsed texture data
  69850. * @param scene defines the current scene
  69851. * @param rootUrl defines the root URL containing perlin noise procedural texture information
  69852. * @returns a parsed Perlin Noise Procedural BABYLON.Texture
  69853. */
  69854. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): PerlinNoiseProceduralTexture;
  69855. }
  69856. }
  69857. declare module BABYLON {
  69858. /** @hidden */
  69859. export var roadProceduralTexturePixelShader: {
  69860. name: string;
  69861. shader: string;
  69862. };
  69863. }
  69864. declare module BABYLON {
  69865. export class RoadProceduralTexture extends BABYLON.ProceduralTexture {
  69866. private _roadColor;
  69867. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69868. updateShaderUniforms(): void;
  69869. roadColor: BABYLON.Color3;
  69870. /**
  69871. * Serializes this road procedural texture
  69872. * @returns a serialized road procedural texture object
  69873. */
  69874. serialize(): any;
  69875. /**
  69876. * Creates a Road Procedural BABYLON.Texture from parsed road procedural texture data
  69877. * @param parsedTexture defines parsed texture data
  69878. * @param scene defines the current scene
  69879. * @param rootUrl defines the root URL containing road procedural texture information
  69880. * @returns a parsed Road Procedural BABYLON.Texture
  69881. */
  69882. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): RoadProceduralTexture;
  69883. }
  69884. }
  69885. declare module BABYLON {
  69886. /** @hidden */
  69887. export var starfieldProceduralTexturePixelShader: {
  69888. name: string;
  69889. shader: string;
  69890. };
  69891. }
  69892. declare module BABYLON {
  69893. export class StarfieldProceduralTexture extends BABYLON.ProceduralTexture {
  69894. private _time;
  69895. private _alpha;
  69896. private _beta;
  69897. private _zoom;
  69898. private _formuparam;
  69899. private _stepsize;
  69900. private _tile;
  69901. private _brightness;
  69902. private _darkmatter;
  69903. private _distfading;
  69904. private _saturation;
  69905. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69906. updateShaderUniforms(): void;
  69907. time: number;
  69908. alpha: number;
  69909. beta: number;
  69910. formuparam: number;
  69911. stepsize: number;
  69912. zoom: number;
  69913. tile: number;
  69914. brightness: number;
  69915. darkmatter: number;
  69916. distfading: number;
  69917. saturation: number;
  69918. /**
  69919. * Serializes this starfield procedural texture
  69920. * @returns a serialized starfield procedural texture object
  69921. */
  69922. serialize(): any;
  69923. /**
  69924. * Creates a Starfield Procedural BABYLON.Texture from parsed startfield procedural texture data
  69925. * @param parsedTexture defines parsed texture data
  69926. * @param scene defines the current scene
  69927. * @param rootUrl defines the root URL containing startfield procedural texture information
  69928. * @returns a parsed Starfield Procedural BABYLON.Texture
  69929. */
  69930. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): StarfieldProceduralTexture;
  69931. }
  69932. }
  69933. declare module BABYLON {
  69934. /** @hidden */
  69935. export var woodProceduralTexturePixelShader: {
  69936. name: string;
  69937. shader: string;
  69938. };
  69939. }
  69940. declare module BABYLON {
  69941. export class WoodProceduralTexture extends BABYLON.ProceduralTexture {
  69942. private _ampScale;
  69943. private _woodColor;
  69944. constructor(name: string, size: number, scene: BABYLON.Scene, fallbackTexture?: BABYLON.Texture, generateMipMaps?: boolean);
  69945. updateShaderUniforms(): void;
  69946. ampScale: number;
  69947. woodColor: BABYLON.Color3;
  69948. /**
  69949. * Serializes this wood procedural texture
  69950. * @returns a serialized wood procedural texture object
  69951. */
  69952. serialize(): any;
  69953. /**
  69954. * Creates a Wood Procedural BABYLON.Texture from parsed wood procedural texture data
  69955. * @param parsedTexture defines parsed texture data
  69956. * @param scene defines the current scene
  69957. * @param rootUrl defines the root URL containing wood procedural texture information
  69958. * @returns a parsed Wood Procedural BABYLON.Texture
  69959. */
  69960. static Parse(parsedTexture: any, scene: BABYLON.Scene, rootUrl: string): WoodProceduralTexture;
  69961. }
  69962. }