babylon.d.ts 1020 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157
  1. declare module 'babylonjs' {
  2. export = BABYLON;
  3. }
  4. declare module BABYLON {
  5. class AssetContainer {
  6. scene: Scene;
  7. cameras: Camera[];
  8. lights: Light[];
  9. meshes: AbstractMesh[];
  10. skeletons: Skeleton[];
  11. particleSystems: ParticleSystem[];
  12. animations: Animation[];
  13. multiMaterials: MultiMaterial[];
  14. materials: Material[];
  15. morphTargetManagers: MorphTargetManager[];
  16. geometries: Geometry[];
  17. transformNodes: TransformNode[];
  18. lensFlareSystems: LensFlareSystem[];
  19. shadowGenerators: ShadowGenerator[];
  20. actionManagers: ActionManager[];
  21. sounds: Sound[];
  22. constructor(scene: Scene);
  23. addAllToScene(): void;
  24. removeAllFromScene(): void;
  25. }
  26. }
  27. interface Window {
  28. mozIndexedDB: IDBFactory;
  29. webkitIndexedDB: IDBFactory;
  30. msIndexedDB: IDBFactory;
  31. webkitURL: typeof URL;
  32. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  33. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  34. WebGLRenderingContext: WebGLRenderingContext;
  35. MSGesture: MSGesture;
  36. CANNON: any;
  37. AudioContext: AudioContext;
  38. webkitAudioContext: AudioContext;
  39. PointerEvent: any;
  40. Math: Math;
  41. Uint8Array: Uint8ArrayConstructor;
  42. Float32Array: Float32ArrayConstructor;
  43. mozURL: typeof URL;
  44. msURL: typeof URL;
  45. VRFrameData: any;
  46. }
  47. interface WebGLRenderingContext {
  48. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  49. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  50. vertexAttribDivisor(index: number, divisor: number): void;
  51. createVertexArray(): any;
  52. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  53. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  54. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  55. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  56. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  57. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  58. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59. createQuery(): WebGLQuery;
  60. deleteQuery(query: WebGLQuery): void;
  61. beginQuery(target: number, query: WebGLQuery): void;
  62. endQuery(target: number): void;
  63. getQueryParameter(query: WebGLQuery, pname: number): any;
  64. getQuery(target: number, pname: number): any;
  65. MAX_SAMPLES: number;
  66. RGBA8: number;
  67. READ_FRAMEBUFFER: number;
  68. DRAW_FRAMEBUFFER: number;
  69. UNIFORM_BUFFER: number;
  70. HALF_FLOAT_OES: number;
  71. RGBA16F: number;
  72. RGBA32F: number;
  73. DEPTH24_STENCIL8: number;
  74. drawBuffers(buffers: number[]): void;
  75. readBuffer(src: number): void;
  76. readonly COLOR_ATTACHMENT0: number;
  77. readonly COLOR_ATTACHMENT1: number;
  78. readonly COLOR_ATTACHMENT2: number;
  79. readonly COLOR_ATTACHMENT3: number;
  80. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  81. ANY_SAMPLES_PASSED: number;
  82. QUERY_RESULT_AVAILABLE: number;
  83. QUERY_RESULT: number;
  84. }
  85. interface Document {
  86. mozCancelFullScreen(): void;
  87. msCancelFullScreen(): void;
  88. mozFullScreen: boolean;
  89. msIsFullScreen: boolean;
  90. fullscreen: boolean;
  91. mozPointerLockElement: HTMLElement;
  92. msPointerLockElement: HTMLElement;
  93. webkitPointerLockElement: HTMLElement;
  94. }
  95. interface HTMLCanvasElement {
  96. msRequestPointerLock?(): void;
  97. mozRequestPointerLock?(): void;
  98. webkitRequestPointerLock?(): void;
  99. }
  100. interface CanvasRenderingContext2D {
  101. msImageSmoothingEnabled: boolean;
  102. }
  103. interface WebGLBuffer {
  104. references: number;
  105. capacity: number;
  106. is32Bits: boolean;
  107. }
  108. interface WebGLProgram {
  109. transformFeedback?: WebGLTransformFeedback | null;
  110. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  111. }
  112. interface MouseEvent {
  113. mozMovementX: number;
  114. mozMovementY: number;
  115. webkitMovementX: number;
  116. webkitMovementY: number;
  117. msMovementX: number;
  118. msMovementY: number;
  119. }
  120. interface Navigator {
  121. getVRDisplays: () => any;
  122. mozGetVRDevices: (any: any) => any;
  123. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  124. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  125. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  126. webkitGetGamepads(): Gamepad[];
  127. msGetGamepads(): Gamepad[];
  128. webkitGamepads(): Gamepad[];
  129. }
  130. interface HTMLVideoElement {
  131. mozSrcObject: any;
  132. }
  133. interface Screen {
  134. orientation: string;
  135. mozOrientation: string;
  136. }
  137. interface Math {
  138. fround(x: number): number;
  139. imul(a: number, b: number): number;
  140. }
  141. interface GamepadPose {
  142. hasOrientation: boolean;
  143. hasPosition: boolean;
  144. position?: Float32Array;
  145. linearVelocity?: Float32Array;
  146. linearAcceleration?: Float32Array;
  147. orientation?: Float32Array;
  148. angularVelocity?: Float32Array;
  149. angularAcceleration?: Float32Array;
  150. }
  151. interface EXT_disjoint_timer_query {
  152. QUERY_COUNTER_BITS_EXT: number;
  153. TIME_ELAPSED_EXT: number;
  154. TIMESTAMP_EXT: number;
  155. GPU_DISJOINT_EXT: number;
  156. QUERY_RESULT_EXT: number;
  157. QUERY_RESULT_AVAILABLE_EXT: number;
  158. queryCounterEXT(query: WebGLQuery, target: number): void;
  159. createQueryEXT(): WebGLQuery;
  160. beginQueryEXT(target: number, query: WebGLQuery): void;
  161. endQueryEXT(target: number): void;
  162. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  163. deleteQueryEXT(query: WebGLQuery): void;
  164. }
  165. interface WebGLUniformLocation {
  166. _currentState: any;
  167. }
  168. declare module BABYLON {
  169. /**
  170. * Node is the basic class for all scene objects (Mesh, Light Camera).
  171. */
  172. class Node {
  173. name: string;
  174. id: string;
  175. uniqueId: number;
  176. state: string;
  177. metadata: any;
  178. doNotSerialize: boolean;
  179. animations: Animation[];
  180. private _ranges;
  181. onReady: (node: Node) => void;
  182. private _isEnabled;
  183. private _isReady;
  184. _currentRenderId: number;
  185. private _parentRenderId;
  186. _waitingParentId: Nullable<string>;
  187. private _scene;
  188. _cache: any;
  189. private _parentNode;
  190. private _children;
  191. parent: Nullable<Node>;
  192. getClassName(): string;
  193. /**
  194. * An event triggered when the mesh is disposed.
  195. * @type {BABYLON.Observable}
  196. */
  197. onDisposeObservable: Observable<Node>;
  198. private _onDisposeObserver;
  199. onDispose: () => void;
  200. /**
  201. * @constructor
  202. * @param {string} name - the name and id to be given to this node
  203. * @param {BABYLON.Scene} the scene this node will be added to
  204. */
  205. constructor(name: string, scene?: Nullable<Scene>);
  206. getScene(): Scene;
  207. getEngine(): Engine;
  208. private _behaviors;
  209. addBehavior(behavior: Behavior<Node>): Node;
  210. removeBehavior(behavior: Behavior<Node>): Node;
  211. readonly behaviors: Behavior<Node>[];
  212. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  213. getWorldMatrix(): Matrix;
  214. _initCache(): void;
  215. updateCache(force?: boolean): void;
  216. _updateCache(ignoreParentClass?: boolean): void;
  217. _isSynchronized(): boolean;
  218. _markSyncedWithParent(): void;
  219. isSynchronizedWithParent(): boolean;
  220. isSynchronized(updateCache?: boolean): boolean;
  221. hasNewParent(update?: boolean): boolean;
  222. /**
  223. * Is this node ready to be used/rendered
  224. * @return {boolean} is it ready
  225. */
  226. isReady(): boolean;
  227. /**
  228. * Is this node enabled.
  229. * 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.
  230. * @param {boolean} [checkAncestors=true] - 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.
  231. * @return {boolean} whether this node (and its parent) is enabled.
  232. * @see setEnabled
  233. */
  234. isEnabled(checkAncestors?: boolean): boolean;
  235. /**
  236. * Set the enabled state of this node.
  237. * @param {boolean} value - the new enabled state
  238. * @see isEnabled
  239. */
  240. setEnabled(value: boolean): void;
  241. /**
  242. * Is this node a descendant of the given node.
  243. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
  244. * @param {BABYLON.Node} ancestor - The parent node to inspect
  245. * @see parent
  246. */
  247. isDescendantOf(ancestor: Node): boolean;
  248. /**
  249. * Evaluate the list of children and determine if they should be considered as descendants considering the given criterias
  250. * @param {BABYLON.Node[]} results the result array containing the nodes matching the given criterias
  251. * @param {boolean} directDescendantsOnly 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.
  252. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  253. */
  254. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  255. /**
  256. * Will return all nodes that have this node as ascendant.
  257. * @param {boolean} directDescendantsOnly 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.
  258. * @param predicate: an optional predicate that will be called on every evaluated children, the predicate must return true for a given child to be part of the result, otherwise it will be ignored.
  259. * @return {BABYLON.Node[]} all children nodes of all types.
  260. */
  261. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  262. /**
  263. * Get all child-meshes of this node.
  264. */
  265. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  266. /**
  267. * Get all child-transformNodes of this node.
  268. */
  269. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  270. /**
  271. * Get all direct children of this node.
  272. */
  273. getChildren(predicate?: (node: Node) => boolean): Node[];
  274. _setReady(state: boolean): void;
  275. getAnimationByName(name: string): Nullable<Animation>;
  276. createAnimationRange(name: string, from: number, to: number): void;
  277. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  278. getAnimationRange(name: string): Nullable<AnimationRange>;
  279. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): void;
  280. serializeAnimationRanges(): any;
  281. computeWorldMatrix(force?: boolean): Matrix;
  282. dispose(): void;
  283. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  284. }
  285. }
  286. declare module BABYLON {
  287. interface IDisposable {
  288. dispose(): void;
  289. }
  290. interface IActiveMeshCandidateProvider {
  291. getMeshes(scene: Scene): AbstractMesh[];
  292. readonly checksIsEnabled: boolean;
  293. }
  294. /**
  295. * This class is used by the onRenderingGroupObservable
  296. */
  297. class RenderingGroupInfo {
  298. /**
  299. * The Scene that being rendered
  300. */
  301. scene: Scene;
  302. /**
  303. * The camera currently used for the rendering pass
  304. */
  305. camera: Nullable<Camera>;
  306. /**
  307. * The ID of the renderingGroup being processed
  308. */
  309. renderingGroupId: number;
  310. /**
  311. * The rendering stage, can be either STAGE_PRECLEAR, STAGE_PREOPAQUE, STAGE_PRETRANSPARENT, STAGE_POSTTRANSPARENT
  312. */
  313. renderStage: number;
  314. /**
  315. * Stage corresponding to the very first hook in the renderingGroup phase: before the render buffer may be cleared
  316. * This stage will be fired no matter what
  317. */
  318. static STAGE_PRECLEAR: number;
  319. /**
  320. * Called before opaque object are rendered.
  321. * This stage will be fired only if there's 3D Opaque content to render
  322. */
  323. static STAGE_PREOPAQUE: number;
  324. /**
  325. * Called after the opaque objects are rendered and before the transparent ones
  326. * This stage will be fired only if there's 3D transparent content to render
  327. */
  328. static STAGE_PRETRANSPARENT: number;
  329. /**
  330. * Called after the transparent object are rendered, last hook of the renderingGroup phase
  331. * This stage will be fired no matter what
  332. */
  333. static STAGE_POSTTRANSPARENT: number;
  334. }
  335. /**
  336. * Represents a scene to be rendered by the engine.
  337. * @see http://doc.babylonjs.com/page.php?p=21911
  338. */
  339. class Scene implements IAnimatable {
  340. private static _FOGMODE_NONE;
  341. private static _FOGMODE_EXP;
  342. private static _FOGMODE_EXP2;
  343. private static _FOGMODE_LINEAR;
  344. private static _uniqueIdCounter;
  345. static MinDeltaTime: number;
  346. static MaxDeltaTime: number;
  347. /** The fog is deactivated */
  348. static readonly FOGMODE_NONE: number;
  349. /** The fog density is following an exponential function */
  350. static readonly FOGMODE_EXP: number;
  351. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  352. static readonly FOGMODE_EXP2: number;
  353. /** The fog density is following a linear function. */
  354. static readonly FOGMODE_LINEAR: number;
  355. autoClear: boolean;
  356. autoClearDepthAndStencil: boolean;
  357. clearColor: Color4;
  358. ambientColor: Color3;
  359. _environmentBRDFTexture: BaseTexture;
  360. protected _environmentTexture: BaseTexture;
  361. /**
  362. * Texture used in all pbr material as the reflection texture.
  363. * As in the majority of the scene they are the same (exception for multi room and so on),
  364. * this is easier to reference from here than from all the materials.
  365. */
  366. /**
  367. * Texture used in all pbr material as the reflection texture.
  368. * As in the majority of the scene they are the same (exception for multi room and so on),
  369. * this is easier to set here than in all the materials.
  370. */
  371. environmentTexture: BaseTexture;
  372. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  373. /**
  374. * Default image processing configuration used either in the rendering
  375. * Forward main pass or through the imageProcessingPostProcess if present.
  376. * As in the majority of the scene they are the same (exception for multi camera),
  377. * this is easier to reference from here than from all the materials and post process.
  378. *
  379. * No setter as we it is a shared configuration, you can set the values instead.
  380. */
  381. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  382. forceWireframe: boolean;
  383. private _forcePointsCloud;
  384. forcePointsCloud: boolean;
  385. forceShowBoundingBoxes: boolean;
  386. clipPlane: Nullable<Plane>;
  387. animationsEnabled: boolean;
  388. useConstantAnimationDeltaTime: boolean;
  389. constantlyUpdateMeshUnderPointer: boolean;
  390. hoverCursor: string;
  391. defaultCursor: string;
  392. /**
  393. * This is used to call preventDefault() on pointer down
  394. * in order to block unwanted artifacts like system double clicks
  395. */
  396. preventDefaultOnPointerDown: boolean;
  397. metadata: any;
  398. loadingPluginName: string;
  399. private _spritePredicate;
  400. /**
  401. * An event triggered when the scene is disposed.
  402. * @type {BABYLON.Observable}
  403. */
  404. onDisposeObservable: Observable<Scene>;
  405. private _onDisposeObserver;
  406. /** A function to be executed when this scene is disposed. */
  407. onDispose: () => void;
  408. /**
  409. * An event triggered before rendering the scene (right after animations and physics)
  410. * @type {BABYLON.Observable}
  411. */
  412. onBeforeRenderObservable: Observable<Scene>;
  413. private _onBeforeRenderObserver;
  414. /** A function to be executed before rendering this scene */
  415. beforeRender: Nullable<() => void>;
  416. /**
  417. * An event triggered after rendering the scene
  418. * @type {BABYLON.Observable}
  419. */
  420. onAfterRenderObservable: Observable<Scene>;
  421. private _onAfterRenderObserver;
  422. /** A function to be executed after rendering this scene */
  423. afterRender: Nullable<() => void>;
  424. /**
  425. * An event triggered before animating the scene
  426. * @type {BABYLON.Observable}
  427. */
  428. onBeforeAnimationsObservable: Observable<Scene>;
  429. /**
  430. * An event triggered after animations processing
  431. * @type {BABYLON.Observable}
  432. */
  433. onAfterAnimationsObservable: Observable<Scene>;
  434. /**
  435. * An event triggered before draw calls are ready to be sent
  436. * @type {BABYLON.Observable}
  437. */
  438. onBeforeDrawPhaseObservable: Observable<Scene>;
  439. /**
  440. * An event triggered after draw calls have been sent
  441. * @type {BABYLON.Observable}
  442. */
  443. onAfterDrawPhaseObservable: Observable<Scene>;
  444. /**
  445. * An event triggered when physic simulation is about to be run
  446. * @type {BABYLON.Observable}
  447. */
  448. onBeforePhysicsObservable: Observable<Scene>;
  449. /**
  450. * An event triggered when physic simulation has been done
  451. * @type {BABYLON.Observable}
  452. */
  453. onAfterPhysicsObservable: Observable<Scene>;
  454. /**
  455. * An event triggered when the scene is ready
  456. * @type {BABYLON.Observable}
  457. */
  458. onReadyObservable: Observable<Scene>;
  459. /**
  460. * An event triggered before rendering a camera
  461. * @type {BABYLON.Observable}
  462. */
  463. onBeforeCameraRenderObservable: Observable<Camera>;
  464. private _onBeforeCameraRenderObserver;
  465. beforeCameraRender: () => void;
  466. /**
  467. * An event triggered after rendering a camera
  468. * @type {BABYLON.Observable}
  469. */
  470. onAfterCameraRenderObservable: Observable<Camera>;
  471. private _onAfterCameraRenderObserver;
  472. afterCameraRender: () => void;
  473. /**
  474. * An event triggered when active meshes evaluation is about to start
  475. * @type {BABYLON.Observable}
  476. */
  477. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  478. /**
  479. * An event triggered when active meshes evaluation is done
  480. * @type {BABYLON.Observable}
  481. */
  482. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  483. /**
  484. * An event triggered when particles rendering is about to start
  485. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  486. * @type {BABYLON.Observable}
  487. */
  488. onBeforeParticlesRenderingObservable: Observable<Scene>;
  489. /**
  490. * An event triggered when particles rendering is done
  491. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  492. * @type {BABYLON.Observable}
  493. */
  494. onAfterParticlesRenderingObservable: Observable<Scene>;
  495. /**
  496. * An event triggered when sprites rendering is about to start
  497. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  498. * @type {BABYLON.Observable}
  499. */
  500. onBeforeSpritesRenderingObservable: Observable<Scene>;
  501. /**
  502. * An event triggered when sprites rendering is done
  503. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  504. * @type {BABYLON.Observable}
  505. */
  506. onAfterSpritesRenderingObservable: Observable<Scene>;
  507. /**
  508. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  509. * @type {BABYLON.Observable}
  510. */
  511. onDataLoadedObservable: Observable<Scene>;
  512. /**
  513. * An event triggered when a camera is created
  514. * @type {BABYLON.Observable}
  515. */
  516. onNewCameraAddedObservable: Observable<Camera>;
  517. /**
  518. * An event triggered when a camera is removed
  519. * @type {BABYLON.Observable}
  520. */
  521. onCameraRemovedObservable: Observable<Camera>;
  522. /**
  523. * An event triggered when a light is created
  524. * @type {BABYLON.Observable}
  525. */
  526. onNewLightAddedObservable: Observable<Light>;
  527. /**
  528. * An event triggered when a light is removed
  529. * @type {BABYLON.Observable}
  530. */
  531. onLightRemovedObservable: Observable<Light>;
  532. /**
  533. * An event triggered when a geometry is created
  534. * @type {BABYLON.Observable}
  535. */
  536. onNewGeometryAddedObservable: Observable<Geometry>;
  537. /**
  538. * An event triggered when a geometry is removed
  539. * @type {BABYLON.Observable}
  540. */
  541. onGeometryRemovedObservable: Observable<Geometry>;
  542. /**
  543. * An event triggered when a transform node is created
  544. * @type {BABYLON.Observable}
  545. */
  546. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  547. /**
  548. * An event triggered when a transform node is removed
  549. * @type {BABYLON.Observable}
  550. */
  551. onTransformNodeRemovedObservable: Observable<TransformNode>;
  552. /**
  553. * An event triggered when a mesh is created
  554. * @type {BABYLON.Observable}
  555. */
  556. onNewMeshAddedObservable: Observable<AbstractMesh>;
  557. /**
  558. * An event triggered when a mesh is removed
  559. * @type {BABYLON.Observable}
  560. */
  561. onMeshRemovedObservable: Observable<AbstractMesh>;
  562. /**
  563. * An event triggered when render targets are about to be rendered
  564. * Can happen multiple times per frame.
  565. * @type {BABYLON.Observable}
  566. */
  567. OnBeforeRenderTargetsRenderObservable: Observable<Scene>;
  568. /**
  569. * An event triggered when render targets were rendered.
  570. * Can happen multiple times per frame.
  571. * @type {BABYLON.Observable}
  572. */
  573. OnAfterRenderTargetsRenderObservable: Observable<Scene>;
  574. /**
  575. * An event triggered before calculating deterministic simulation step
  576. * @type {BABYLON.Observable}
  577. */
  578. onBeforeStepObservable: Observable<Scene>;
  579. /**
  580. * An event triggered after calculating deterministic simulation step
  581. * @type {BABYLON.Observable}
  582. */
  583. onAfterStepObservable: Observable<Scene>;
  584. /**
  585. * This Observable will be triggered for each stage of each renderingGroup of each rendered camera.
  586. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  587. * 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)
  588. */
  589. onRenderingGroupObservable: Observable<RenderingGroupInfo>;
  590. animations: Animation[];
  591. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  592. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  593. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  594. private _onPointerMove;
  595. private _onPointerDown;
  596. private _onPointerUp;
  597. /** Deprecated. Use onPointerObservable instead */
  598. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  599. /** Deprecated. Use onPointerObservable instead */
  600. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  601. /** Deprecated. Use onPointerObservable instead */
  602. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>) => void;
  603. /** Deprecated. Use onPointerObservable instead */
  604. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  605. private _gamepadManager;
  606. readonly gamepadManager: GamepadManager;
  607. /**
  608. * 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).
  609. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  610. */
  611. onPrePointerObservable: Observable<PointerInfoPre>;
  612. /**
  613. * Observable event triggered each time an input event is received from the rendering canvas
  614. */
  615. onPointerObservable: Observable<PointerInfo>;
  616. readonly unTranslatedPointer: Vector2;
  617. /** The distance in pixel that you have to move to prevent some events */
  618. static DragMovementThreshold: number;
  619. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  620. static LongPressDelay: number;
  621. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  622. static DoubleClickDelay: number;
  623. /** If you need to check double click without raising a single click at first click, enable this flag */
  624. static ExclusiveDoubleClickMode: boolean;
  625. private _initClickEvent;
  626. private _initActionManager;
  627. private _delayedSimpleClick;
  628. private _delayedSimpleClickTimeout;
  629. private _previousDelayedSimpleClickTimeout;
  630. private _meshPickProceed;
  631. private _previousButtonPressed;
  632. private _currentPickResult;
  633. private _previousPickResult;
  634. private _totalPointersPressed;
  635. private _doubleClickOccured;
  636. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  637. cameraToUseForPointers: Nullable<Camera>;
  638. private _pointerX;
  639. private _pointerY;
  640. private _unTranslatedPointerX;
  641. private _unTranslatedPointerY;
  642. private _startingPointerPosition;
  643. private _previousStartingPointerPosition;
  644. private _startingPointerTime;
  645. private _previousStartingPointerTime;
  646. private _timeAccumulator;
  647. private _currentStepId;
  648. private _currentInternalStep;
  649. _mirroredCameraPosition: Nullable<Vector3>;
  650. /**
  651. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  652. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  653. */
  654. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  655. /**
  656. * Observable event triggered each time an keyboard event is received from the hosting window
  657. */
  658. onKeyboardObservable: Observable<KeyboardInfo>;
  659. private _onKeyDown;
  660. private _onKeyUp;
  661. private _onCanvasFocusObserver;
  662. private _onCanvasBlurObserver;
  663. /**
  664. * use right-handed coordinate system on this scene.
  665. * @type {boolean}
  666. */
  667. private _useRightHandedSystem;
  668. useRightHandedSystem: boolean;
  669. setStepId(newStepId: number): void;
  670. getStepId(): number;
  671. getInternalStep(): number;
  672. private _fogEnabled;
  673. /**
  674. * is fog enabled on this scene.
  675. */
  676. fogEnabled: boolean;
  677. private _fogMode;
  678. fogMode: number;
  679. fogColor: Color3;
  680. fogDensity: number;
  681. fogStart: number;
  682. fogEnd: number;
  683. /**
  684. * is shadow enabled on this scene.
  685. * @type {boolean}
  686. */
  687. private _shadowsEnabled;
  688. shadowsEnabled: boolean;
  689. /**
  690. * is light enabled on this scene.
  691. * @type {boolean}
  692. */
  693. private _lightsEnabled;
  694. lightsEnabled: boolean;
  695. /**
  696. * All of the lights added to this scene.
  697. * @see BABYLON.Light
  698. * @type {BABYLON.Light[]}
  699. */
  700. lights: Light[];
  701. /** All of the cameras added to this scene. */
  702. cameras: Camera[];
  703. /** All of the active cameras added to this scene. */
  704. activeCameras: Camera[];
  705. /** The current active camera */
  706. activeCamera: Nullable<Camera>;
  707. /**
  708. * All of the tranform nodes added to this scene.
  709. * @see BABYLON.TransformNode
  710. * @type {BABYLON.TransformNode[]}
  711. */
  712. transformNodes: TransformNode[];
  713. /**
  714. * All of the (abstract) meshes added to this scene.
  715. * @see BABYLON.AbstractMesh
  716. * @type {BABYLON.AbstractMesh[]}
  717. */
  718. meshes: AbstractMesh[];
  719. /**
  720. * All of the animation groups added to this scene.
  721. * @see BABYLON.AnimationGroup
  722. * @type {BABYLON.AnimationGroup[]}
  723. */
  724. animationGroups: AnimationGroup[];
  725. private _geometries;
  726. materials: Material[];
  727. multiMaterials: MultiMaterial[];
  728. private _defaultMaterial;
  729. /** The default material used on meshes when no material is affected */
  730. /** The default material used on meshes when no material is affected */
  731. defaultMaterial: Material;
  732. private _texturesEnabled;
  733. texturesEnabled: boolean;
  734. textures: BaseTexture[];
  735. particlesEnabled: boolean;
  736. particleSystems: IParticleSystem[];
  737. spritesEnabled: boolean;
  738. spriteManagers: SpriteManager[];
  739. layers: Layer[];
  740. highlightLayers: HighlightLayer[];
  741. private _skeletonsEnabled;
  742. skeletonsEnabled: boolean;
  743. skeletons: Skeleton[];
  744. morphTargetManagers: MorphTargetManager[];
  745. lensFlaresEnabled: boolean;
  746. lensFlareSystems: LensFlareSystem[];
  747. collisionsEnabled: boolean;
  748. private _workerCollisions;
  749. collisionCoordinator: ICollisionCoordinator;
  750. /** Defines the gravity applied to this scene */
  751. gravity: Vector3;
  752. postProcesses: PostProcess[];
  753. postProcessesEnabled: boolean;
  754. postProcessManager: PostProcessManager;
  755. private _postProcessRenderPipelineManager;
  756. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  757. renderTargetsEnabled: boolean;
  758. dumpNextRenderTargets: boolean;
  759. customRenderTargets: RenderTargetTexture[];
  760. useDelayedTextureLoading: boolean;
  761. importedMeshesFiles: String[];
  762. probesEnabled: boolean;
  763. reflectionProbes: ReflectionProbe[];
  764. database: Database;
  765. /**
  766. * This scene's action manager
  767. * @type {BABYLON.ActionManager}
  768. */
  769. actionManager: ActionManager;
  770. _actionManagers: ActionManager[];
  771. private _meshesForIntersections;
  772. proceduralTexturesEnabled: boolean;
  773. _proceduralTextures: ProceduralTexture[];
  774. private _mainSoundTrack;
  775. soundTracks: SoundTrack[];
  776. private _audioEnabled;
  777. private _headphone;
  778. readonly mainSoundTrack: SoundTrack;
  779. VRHelper: VRExperienceHelper;
  780. simplificationQueue: SimplificationQueue;
  781. private _engine;
  782. private _totalVertices;
  783. _activeIndices: PerfCounter;
  784. _activeParticles: PerfCounter;
  785. _activeBones: PerfCounter;
  786. private _animationRatio;
  787. private _animationTimeLast;
  788. private _animationTime;
  789. animationTimeScale: number;
  790. _cachedMaterial: Nullable<Material>;
  791. _cachedEffect: Nullable<Effect>;
  792. _cachedVisibility: Nullable<number>;
  793. private _renderId;
  794. private _executeWhenReadyTimeoutId;
  795. private _intermediateRendering;
  796. private _viewUpdateFlag;
  797. private _projectionUpdateFlag;
  798. private _alternateViewUpdateFlag;
  799. private _alternateProjectionUpdateFlag;
  800. _toBeDisposed: SmartArray<Nullable<IDisposable>>;
  801. private _activeRequests;
  802. private _pendingData;
  803. private _isDisposed;
  804. dispatchAllSubMeshesOfActiveMeshes: boolean;
  805. private _activeMeshes;
  806. private _processedMaterials;
  807. private _renderTargets;
  808. _activeParticleSystems: SmartArray<IParticleSystem>;
  809. private _activeSkeletons;
  810. private _softwareSkinnedMeshes;
  811. private _renderingManager;
  812. private _physicsEngine;
  813. _activeAnimatables: Animatable[];
  814. private _transformMatrix;
  815. private _sceneUbo;
  816. private _alternateSceneUbo;
  817. private _pickWithRayInverseMatrix;
  818. private _boundingBoxRenderer;
  819. private _outlineRenderer;
  820. private _viewMatrix;
  821. private _projectionMatrix;
  822. private _alternateViewMatrix;
  823. private _alternateProjectionMatrix;
  824. private _alternateTransformMatrix;
  825. private _useAlternateCameraConfiguration;
  826. private _alternateRendering;
  827. _forcedViewPosition: Nullable<Vector3>;
  828. readonly _isAlternateRenderingEnabled: boolean;
  829. private _frustumPlanes;
  830. readonly frustumPlanes: Plane[];
  831. requireLightSorting: boolean;
  832. private _selectionOctree;
  833. private _pointerOverMesh;
  834. private _pointerOverSprite;
  835. private _debugLayer;
  836. private _depthRenderer;
  837. private _geometryBufferRenderer;
  838. private _pickedDownMesh;
  839. private _pickedUpMesh;
  840. private _pickedDownSprite;
  841. private _externalData;
  842. private _uid;
  843. /**
  844. * @constructor
  845. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  846. */
  847. constructor(engine: Engine);
  848. readonly debugLayer: DebugLayer;
  849. workerCollisions: boolean;
  850. readonly selectionOctree: Octree<AbstractMesh>;
  851. /**
  852. * The mesh that is currently under the pointer.
  853. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  854. */
  855. readonly meshUnderPointer: Nullable<AbstractMesh>;
  856. /**
  857. * Current on-screen X position of the pointer
  858. * @return {number} X position of the pointer
  859. */
  860. readonly pointerX: number;
  861. /**
  862. * Current on-screen Y position of the pointer
  863. * @return {number} Y position of the pointer
  864. */
  865. readonly pointerY: number;
  866. getCachedMaterial(): Nullable<Material>;
  867. getCachedEffect(): Nullable<Effect>;
  868. getCachedVisibility(): Nullable<number>;
  869. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  870. getBoundingBoxRenderer(): BoundingBoxRenderer;
  871. getOutlineRenderer(): OutlineRenderer;
  872. getEngine(): Engine;
  873. getTotalVertices(): number;
  874. readonly totalVerticesPerfCounter: PerfCounter;
  875. getActiveIndices(): number;
  876. readonly totalActiveIndicesPerfCounter: PerfCounter;
  877. getActiveParticles(): number;
  878. readonly activeParticlesPerfCounter: PerfCounter;
  879. getActiveBones(): number;
  880. readonly activeBonesPerfCounter: PerfCounter;
  881. getInterFramePerfCounter(): number;
  882. readonly interFramePerfCounter: Nullable<PerfCounter>;
  883. getLastFrameDuration(): number;
  884. readonly lastFramePerfCounter: Nullable<PerfCounter>;
  885. getEvaluateActiveMeshesDuration(): number;
  886. readonly evaluateActiveMeshesDurationPerfCounter: Nullable<PerfCounter>;
  887. getActiveMeshes(): SmartArray<AbstractMesh>;
  888. getRenderTargetsDuration(): number;
  889. getRenderDuration(): number;
  890. readonly renderDurationPerfCounter: Nullable<PerfCounter>;
  891. getParticlesDuration(): number;
  892. readonly particlesDurationPerfCounter: Nullable<PerfCounter>;
  893. getSpritesDuration(): number;
  894. readonly spriteDuractionPerfCounter: Nullable<PerfCounter>;
  895. getAnimationRatio(): number;
  896. getRenderId(): number;
  897. incrementRenderId(): void;
  898. private _updatePointerPosition(evt);
  899. private _createUbo();
  900. private _createAlternateUbo();
  901. /**
  902. * Use this method to simulate a pointer move on a mesh
  903. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  904. */
  905. simulatePointerMove(pickResult: PickingInfo): Scene;
  906. private _processPointerMove(pickResult, evt);
  907. /**
  908. * Use this method to simulate a pointer down on a mesh
  909. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  910. */
  911. simulatePointerDown(pickResult: PickingInfo): Scene;
  912. private _processPointerDown(pickResult, evt);
  913. /**
  914. * Use this method to simulate a pointer up on a mesh
  915. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  916. */
  917. simulatePointerUp(pickResult: PickingInfo): Scene;
  918. private _processPointerUp(pickResult, evt, clickInfo);
  919. /**
  920. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  921. * @param attachUp defines if you want to attach events to pointerup
  922. * @param attachDown defines if you want to attach events to pointerdown
  923. * @param attachMove defines if you want to attach events to pointermove
  924. */
  925. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  926. detachControl(): void;
  927. /**
  928. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  929. * Delay loaded resources are not taking in account
  930. * @return true if all required resources are ready
  931. */
  932. isReady(): boolean;
  933. resetCachedMaterial(): void;
  934. registerBeforeRender(func: () => void): void;
  935. unregisterBeforeRender(func: () => void): void;
  936. registerAfterRender(func: () => void): void;
  937. unregisterAfterRender(func: () => void): void;
  938. private _executeOnceBeforeRender(func);
  939. /**
  940. * The provided function will run before render once and will be disposed afterwards.
  941. * A timeout delay can be provided so that the function will be executed in N ms.
  942. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  943. * @param func The function to be executed.
  944. * @param timeout optional delay in ms
  945. */
  946. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  947. _addPendingData(data: any): void;
  948. _removePendingData(data: any): void;
  949. getWaitingItemsCount(): number;
  950. readonly isLoading: boolean;
  951. /**
  952. * Registers a function to be executed when the scene is ready.
  953. * @param {Function} func - the function to be executed.
  954. */
  955. executeWhenReady(func: () => void): void;
  956. _checkIsReady(): void;
  957. /**
  958. * Will start the animation sequence of a given target
  959. * @param target - the target
  960. * @param {number} from - from which frame should animation start
  961. * @param {number} to - till which frame should animation run.
  962. * @param {boolean} [loop] - should the animation loop
  963. * @param {number} [speedRatio] - the speed in which to run the animation
  964. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  965. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  966. * Returns {BABYLON.Animatable} the animatable object created for this animation
  967. * See BABYLON.Animatable
  968. */
  969. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  970. /**
  971. * Begin a new animation on a given node
  972. * @param {BABYLON.Node} node defines the root node where the animation will take place
  973. * @param {BABYLON.Animation[]} defines the list of animations to start
  974. * @param {number} from defines the initial value
  975. * @param {number} to defines the final value
  976. * @param {boolean} loop defines if you want animation to loop (off by default)
  977. * @param {number} speedRatio defines the speed ratio to apply to all animations
  978. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  979. * @returns the list of created animatables
  980. */
  981. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  982. /**
  983. * Begin a new animation on a given node and its hierarchy
  984. * @param {BABYLON.Node} node defines the root node where the animation will take place
  985. * @param {boolean} 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.
  986. * @param {BABYLON.Animation[]} defines the list of animations to start
  987. * @param {number} from defines the initial value
  988. * @param {number} to defines the final value
  989. * @param {boolean} loop defines if you want animation to loop (off by default)
  990. * @param {number} speedRatio defines the speed ratio to apply to all animations
  991. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  992. * @returns the list of animatables created for all nodes
  993. */
  994. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable[];
  995. getAnimatableByTarget(target: any): Nullable<Animatable>;
  996. readonly animatables: Animatable[];
  997. /**
  998. * Will stop the animation of the given target
  999. * @param target - the target
  1000. * @param animationName - the name of the animation to stop (all animations will be stopped is empty)
  1001. * @see beginAnimation
  1002. */
  1003. stopAnimation(target: any, animationName?: string): void;
  1004. /**
  1005. * Stops and removes all animations that have been applied to the scene
  1006. */
  1007. stopAllAnimations(): void;
  1008. private _animate();
  1009. _switchToAlternateCameraConfiguration(active: boolean): void;
  1010. getViewMatrix(): Matrix;
  1011. getProjectionMatrix(): Matrix;
  1012. getTransformMatrix(): Matrix;
  1013. setTransformMatrix(view: Matrix, projection: Matrix): void;
  1014. _setAlternateTransformMatrix(view: Matrix, projection: Matrix): void;
  1015. getSceneUniformBuffer(): UniformBuffer;
  1016. getUniqueId(): number;
  1017. addMesh(newMesh: AbstractMesh): void;
  1018. removeMesh(toRemove: AbstractMesh): number;
  1019. addTransformNode(newTransformNode: TransformNode): void;
  1020. removeTransformNode(toRemove: TransformNode): number;
  1021. removeSkeleton(toRemove: Skeleton): number;
  1022. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  1023. removeLight(toRemove: Light): number;
  1024. removeCamera(toRemove: Camera): number;
  1025. removeParticleSystem(toRemove: ParticleSystem): number;
  1026. removeAnimation(toRemove: Animation): number;
  1027. removeMultiMaterial(toRemove: MultiMaterial): number;
  1028. removeMaterial(toRemove: Material): number;
  1029. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  1030. removeActionManager(toRemove: ActionManager): number;
  1031. addLight(newLight: Light): void;
  1032. sortLightsByPriority(): void;
  1033. addCamera(newCamera: Camera): void;
  1034. addSkeleton(newSkeleton: Skeleton): void;
  1035. addParticleSystem(newParticleSystem: ParticleSystem): void;
  1036. addAnimation(newAnimation: Animation): void;
  1037. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  1038. addMaterial(newMaterial: Material): void;
  1039. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  1040. addGeometry(newGeometrie: Geometry): void;
  1041. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  1042. addActionManager(newActionManager: ActionManager): void;
  1043. /**
  1044. * Switch active camera
  1045. * @param {Camera} newCamera - new active camera
  1046. * @param {boolean} attachControl - call attachControl for the new active camera (default: true)
  1047. */
  1048. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  1049. /**
  1050. * sets the active camera of the scene using its ID
  1051. * @param {string} id - the camera's ID
  1052. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1053. * @see activeCamera
  1054. */
  1055. setActiveCameraByID(id: string): Nullable<Camera>;
  1056. /**
  1057. * sets the active camera of the scene using its name
  1058. * @param {string} name - the camera's name
  1059. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  1060. * @see activeCamera
  1061. */
  1062. setActiveCameraByName(name: string): Nullable<Camera>;
  1063. /**
  1064. * get an animation group using its name
  1065. * @param {string} the material's name
  1066. * @return {BABYLON.AnimationGroup|null} the animation group or null if none found.
  1067. */
  1068. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  1069. /**
  1070. * get a material using its id
  1071. * @param {string} the material's ID
  1072. * @return {BABYLON.Material|null} the material or null if none found.
  1073. */
  1074. getMaterialByID(id: string): Nullable<Material>;
  1075. /**
  1076. * get a material using its name
  1077. * @param {string} the material's name
  1078. * @return {BABYLON.Material|null} the material or null if none found.
  1079. */
  1080. getMaterialByName(name: string): Nullable<Material>;
  1081. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  1082. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  1083. getCameraByID(id: string): Nullable<Camera>;
  1084. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  1085. /**
  1086. * get a camera using its name
  1087. * @param {string} the camera's name
  1088. * @return {BABYLON.Camera|null} the camera or null if none found.
  1089. */
  1090. getCameraByName(name: string): Nullable<Camera>;
  1091. /**
  1092. * get a bone using its id
  1093. * @param {string} the bone's id
  1094. * @return {BABYLON.Bone|null} the bone or null if not found
  1095. */
  1096. getBoneByID(id: string): Nullable<Bone>;
  1097. /**
  1098. * get a bone using its id
  1099. * @param {string} the bone's name
  1100. * @return {BABYLON.Bone|null} the bone or null if not found
  1101. */
  1102. getBoneByName(name: string): Nullable<Bone>;
  1103. /**
  1104. * get a light node using its name
  1105. * @param {string} the light's name
  1106. * @return {BABYLON.Light|null} the light or null if none found.
  1107. */
  1108. getLightByName(name: string): Nullable<Light>;
  1109. /**
  1110. * get a light node using its ID
  1111. * @param {string} the light's id
  1112. * @return {BABYLON.Light|null} the light or null if none found.
  1113. */
  1114. getLightByID(id: string): Nullable<Light>;
  1115. /**
  1116. * get a light node using its scene-generated unique ID
  1117. * @param {number} the light's unique id
  1118. * @return {BABYLON.Light|null} the light or null if none found.
  1119. */
  1120. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  1121. /**
  1122. * get a particle system by id
  1123. * @param id {number} the particle system id
  1124. * @return {BABYLON.IParticleSystem|null} the corresponding system or null if none found.
  1125. */
  1126. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  1127. /**
  1128. * get a geometry using its ID
  1129. * @param {string} the geometry's id
  1130. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  1131. */
  1132. getGeometryByID(id: string): Nullable<Geometry>;
  1133. /**
  1134. * add a new geometry to this scene.
  1135. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  1136. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  1137. * @return {boolean} was the geometry added or not
  1138. */
  1139. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  1140. /**
  1141. * Removes an existing geometry
  1142. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  1143. * @return {boolean} was the geometry removed or not
  1144. */
  1145. removeGeometry(geometry: Geometry): boolean;
  1146. getGeometries(): Geometry[];
  1147. /**
  1148. * Get the first added mesh found of a given ID
  1149. * @param {string} id - the id to search for
  1150. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1151. */
  1152. getMeshByID(id: string): Nullable<AbstractMesh>;
  1153. getMeshesByID(id: string): Array<AbstractMesh>;
  1154. /**
  1155. * Get the first added transform node found of a given ID
  1156. * @param {string} id - the id to search for
  1157. * @return {BABYLON.TransformNode|null} the transform node found or null if not found at all.
  1158. */
  1159. getTransformNodeByID(id: string): Nullable<TransformNode>;
  1160. getTransformNodesByID(id: string): Array<TransformNode>;
  1161. /**
  1162. * Get a mesh with its auto-generated unique id
  1163. * @param {number} uniqueId - the unique id to search for
  1164. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1165. */
  1166. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  1167. /**
  1168. * Get a the last added mesh found of a given ID
  1169. * @param {string} id - the id to search for
  1170. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  1171. */
  1172. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  1173. /**
  1174. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  1175. * @param {string} id - the id to search for
  1176. * @return {BABYLON.Node|null} the node found or null if not found at all.
  1177. */
  1178. getLastEntryByID(id: string): Nullable<Node>;
  1179. getNodeByID(id: string): Nullable<Node>;
  1180. getNodeByName(name: string): Nullable<Node>;
  1181. getMeshByName(name: string): Nullable<AbstractMesh>;
  1182. getTransformNodeByName(name: string): Nullable<TransformNode>;
  1183. getSoundByName(name: string): Nullable<Sound>;
  1184. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  1185. getSkeletonById(id: string): Nullable<Skeleton>;
  1186. getSkeletonByName(name: string): Nullable<Skeleton>;
  1187. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  1188. isActiveMesh(mesh: AbstractMesh): boolean;
  1189. /**
  1190. * Return a the first highlight layer of the scene with a given name.
  1191. * @param name The name of the highlight layer to look for.
  1192. * @return The highlight layer if found otherwise null.
  1193. */
  1194. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  1195. /**
  1196. * Return a unique id as a string which can serve as an identifier for the scene
  1197. */
  1198. readonly uid: string;
  1199. /**
  1200. * Add an externaly attached data from its key.
  1201. * This method call will fail and return false, if such key already exists.
  1202. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  1203. * @param key the unique key that identifies the data
  1204. * @param data the data object to associate to the key for this Engine instance
  1205. * @return true if no such key were already present and the data was added successfully, false otherwise
  1206. */
  1207. addExternalData<T>(key: string, data: T): boolean;
  1208. /**
  1209. * Get an externaly attached data from its key
  1210. * @param key the unique key that identifies the data
  1211. * @return the associated data, if present (can be null), or undefined if not present
  1212. */
  1213. getExternalData<T>(key: string): Nullable<T>;
  1214. /**
  1215. * Get an externaly attached data from its key, create it using a factory if it's not already present
  1216. * @param key the unique key that identifies the data
  1217. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  1218. * @return the associated data, can be null if the factory returned null.
  1219. */
  1220. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  1221. /**
  1222. * Remove an externaly attached data from the Engine instance
  1223. * @param key the unique key that identifies the data
  1224. * @return true if the data was successfully removed, false if it doesn't exist
  1225. */
  1226. removeExternalData(key: string): boolean;
  1227. private _evaluateSubMesh(subMesh, mesh);
  1228. _isInIntermediateRendering(): boolean;
  1229. private _activeMeshCandidateProvider;
  1230. setActiveMeshCandidateProvider(provider: IActiveMeshCandidateProvider): void;
  1231. getActiveMeshCandidateProvider(): IActiveMeshCandidateProvider;
  1232. private _activeMeshesFrozen;
  1233. /**
  1234. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  1235. */
  1236. freezeActiveMeshes(): Scene;
  1237. /**
  1238. * Use this function to restart evaluating active meshes on every frame
  1239. */
  1240. unfreezeActiveMeshes(): this;
  1241. private _evaluateActiveMeshes();
  1242. private _activeMesh(sourceMesh, mesh);
  1243. updateTransformMatrix(force?: boolean): void;
  1244. updateAlternateTransformMatrix(alternateCamera: Camera): void;
  1245. private _renderForCamera(camera);
  1246. private _processSubCameras(camera);
  1247. private _checkIntersections();
  1248. render(): void;
  1249. private _updateAudioParameters();
  1250. audioEnabled: boolean;
  1251. private _disableAudio();
  1252. private _enableAudio();
  1253. headphone: boolean;
  1254. private _switchAudioModeForHeadphones();
  1255. private _switchAudioModeForNormalSpeakers();
  1256. enableDepthRenderer(): DepthRenderer;
  1257. disableDepthRenderer(): void;
  1258. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  1259. disableGeometryBufferRenderer(): void;
  1260. freezeMaterials(): void;
  1261. unfreezeMaterials(): void;
  1262. dispose(): void;
  1263. readonly isDisposed: boolean;
  1264. disposeSounds(): void;
  1265. getWorldExtends(): {
  1266. min: Vector3;
  1267. max: Vector3;
  1268. };
  1269. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  1270. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  1271. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  1272. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  1273. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  1274. private _internalPick(rayFunction, predicate?, fastCheck?);
  1275. private _internalMultiPick(rayFunction, predicate?);
  1276. private _internalPickSprites(ray, predicate?, fastCheck?, camera?);
  1277. private _tempPickingRay;
  1278. /** Launch a ray to try to pick a mesh in the scene
  1279. * @param x position on screen
  1280. * @param y position on screen
  1281. * @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
  1282. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1283. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1284. */
  1285. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  1286. /** Launch a ray to try to pick a sprite in the scene
  1287. * @param x position on screen
  1288. * @param y position on screen
  1289. * @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
  1290. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1291. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1292. */
  1293. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  1294. private _cachedRayForTransform;
  1295. /** Use the given ray to pick a mesh in the scene
  1296. * @param ray The ray to use to pick meshes
  1297. * @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
  1298. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  1299. */
  1300. pickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  1301. /**
  1302. * Launch a ray to try to pick a mesh in the scene
  1303. * @param x X position on screen
  1304. * @param y Y position on screen
  1305. * @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
  1306. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  1307. */
  1308. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  1309. /**
  1310. * Launch a ray to try to pick a mesh in the scene
  1311. * @param ray Ray to use
  1312. * @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
  1313. */
  1314. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean): Nullable<PickingInfo[]>;
  1315. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  1316. getPointerOverMesh(): Nullable<AbstractMesh>;
  1317. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  1318. getPointerOverSprite(): Nullable<Sprite>;
  1319. getPhysicsEngine(): Nullable<PhysicsEngine>;
  1320. /**
  1321. * Enables physics to the current scene
  1322. * @param {BABYLON.Vector3} [gravity] - the scene's gravity for the physics engine
  1323. * @param {BABYLON.IPhysicsEnginePlugin} [plugin] - The physics engine to be used. defaults to OimoJS.
  1324. * @return {boolean} was the physics engine initialized
  1325. */
  1326. enablePhysics(gravity?: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  1327. disablePhysicsEngine(): void;
  1328. isPhysicsEnabled(): boolean;
  1329. deleteCompoundImpostor(compound: any): void;
  1330. _rebuildGeometries(): void;
  1331. _rebuildTextures(): void;
  1332. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  1333. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number): Nullable<Mesh>;
  1334. createDefaultEnvironment(options: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  1335. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  1336. private _getByTags(list, tagsQuery, forEach?);
  1337. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  1338. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  1339. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  1340. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  1341. /**
  1342. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  1343. * This allowed control for front to back rendering or reversly depending of the special needs.
  1344. *
  1345. * @param renderingGroupId The rendering group id corresponding to its index
  1346. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  1347. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  1348. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  1349. */
  1350. 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;
  1351. /**
  1352. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  1353. *
  1354. * @param renderingGroupId The rendering group id corresponding to its index
  1355. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  1356. * @param depth Automatically clears depth between groups if true and autoClear is true.
  1357. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  1358. */
  1359. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  1360. /**
  1361. * Will flag all materials as dirty to trigger new shader compilation
  1362. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  1363. */
  1364. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  1365. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, useDatabase?: boolean, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  1366. }
  1367. }
  1368. declare module BABYLON {
  1369. type Nullable<T> = T | null;
  1370. type float = number;
  1371. type double = number;
  1372. type int = number;
  1373. type FloatArray = number[] | Float32Array;
  1374. type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  1375. }
  1376. declare module BABYLON {
  1377. class Action {
  1378. triggerOptions: any;
  1379. trigger: number;
  1380. _actionManager: ActionManager;
  1381. private _nextActiveAction;
  1382. private _child;
  1383. private _condition?;
  1384. private _triggerParameter;
  1385. onBeforeExecuteObservable: Observable<Action>;
  1386. constructor(triggerOptions: any, condition?: Condition);
  1387. _prepare(): void;
  1388. getTriggerParameter(): any;
  1389. _executeCurrent(evt?: ActionEvent): void;
  1390. execute(evt?: ActionEvent): void;
  1391. skipToNextActiveAction(): void;
  1392. then(action: Action): Action;
  1393. _getProperty(propertyPath: string): string;
  1394. _getEffectiveTarget(target: any, propertyPath: string): any;
  1395. serialize(parent: any): any;
  1396. protected _serialize(serializedAction: any, parent?: any): any;
  1397. static _SerializeValueAsString: (value: any) => string;
  1398. static _GetTargetProperty: (target: Scene | Node) => {
  1399. name: string;
  1400. targetType: string;
  1401. value: string;
  1402. };
  1403. }
  1404. }
  1405. declare module BABYLON {
  1406. /**
  1407. * ActionEvent is the event beint sent when an action is triggered.
  1408. */
  1409. class ActionEvent {
  1410. source: any;
  1411. pointerX: number;
  1412. pointerY: number;
  1413. meshUnderPointer: Nullable<AbstractMesh>;
  1414. sourceEvent: any;
  1415. additionalData: any;
  1416. /**
  1417. * @param source The mesh or sprite that triggered the action.
  1418. * @param pointerX The X mouse cursor position at the time of the event
  1419. * @param pointerY The Y mouse cursor position at the time of the event
  1420. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  1421. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  1422. */
  1423. constructor(source: any, pointerX: number, pointerY: number, meshUnderPointer: Nullable<AbstractMesh>, sourceEvent?: any, additionalData?: any);
  1424. /**
  1425. * Helper function to auto-create an ActionEvent from a source mesh.
  1426. * @param source The source mesh that triggered the event
  1427. * @param evt {Event} The original (browser) event
  1428. */
  1429. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  1430. /**
  1431. * Helper function to auto-create an ActionEvent from a source mesh.
  1432. * @param source The source sprite that triggered the event
  1433. * @param scene Scene associated with the sprite
  1434. * @param evt {Event} The original (browser) event
  1435. */
  1436. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  1437. /**
  1438. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  1439. * @param scene the scene where the event occurred
  1440. * @param evt {Event} The original (browser) event
  1441. */
  1442. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  1443. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  1444. }
  1445. /**
  1446. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  1447. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  1448. */
  1449. class ActionManager {
  1450. private static _NothingTrigger;
  1451. private static _OnPickTrigger;
  1452. private static _OnLeftPickTrigger;
  1453. private static _OnRightPickTrigger;
  1454. private static _OnCenterPickTrigger;
  1455. private static _OnPickDownTrigger;
  1456. private static _OnDoublePickTrigger;
  1457. private static _OnPickUpTrigger;
  1458. private static _OnLongPressTrigger;
  1459. private static _OnPointerOverTrigger;
  1460. private static _OnPointerOutTrigger;
  1461. private static _OnEveryFrameTrigger;
  1462. private static _OnIntersectionEnterTrigger;
  1463. private static _OnIntersectionExitTrigger;
  1464. private static _OnKeyDownTrigger;
  1465. private static _OnKeyUpTrigger;
  1466. private static _OnPickOutTrigger;
  1467. static readonly NothingTrigger: number;
  1468. static readonly OnPickTrigger: number;
  1469. static readonly OnLeftPickTrigger: number;
  1470. static readonly OnRightPickTrigger: number;
  1471. static readonly OnCenterPickTrigger: number;
  1472. static readonly OnPickDownTrigger: number;
  1473. static readonly OnDoublePickTrigger: number;
  1474. static readonly OnPickUpTrigger: number;
  1475. static readonly OnPickOutTrigger: number;
  1476. static readonly OnLongPressTrigger: number;
  1477. static readonly OnPointerOverTrigger: number;
  1478. static readonly OnPointerOutTrigger: number;
  1479. static readonly OnEveryFrameTrigger: number;
  1480. static readonly OnIntersectionEnterTrigger: number;
  1481. static readonly OnIntersectionExitTrigger: number;
  1482. static readonly OnKeyDownTrigger: number;
  1483. static readonly OnKeyUpTrigger: number;
  1484. static Triggers: {
  1485. [key: string]: number;
  1486. };
  1487. actions: Action[];
  1488. hoverCursor: string;
  1489. private _scene;
  1490. constructor(scene: Scene);
  1491. dispose(): void;
  1492. getScene(): Scene;
  1493. /**
  1494. * Does this action manager handles actions of any of the given triggers
  1495. * @param {number[]} triggers - the triggers to be tested
  1496. * @return {boolean} whether one (or more) of the triggers is handeled
  1497. */
  1498. hasSpecificTriggers(triggers: number[]): boolean;
  1499. /**
  1500. * Does this action manager handles actions of a given trigger
  1501. * @param {number} trigger - the trigger to be tested
  1502. * @return {boolean} whether the trigger is handeled
  1503. */
  1504. hasSpecificTrigger(trigger: number): boolean;
  1505. /**
  1506. * Does this action manager has pointer triggers
  1507. * @return {boolean} whether or not it has pointer triggers
  1508. */
  1509. readonly hasPointerTriggers: boolean;
  1510. /**
  1511. * Does this action manager has pick triggers
  1512. * @return {boolean} whether or not it has pick triggers
  1513. */
  1514. readonly hasPickTriggers: boolean;
  1515. /**
  1516. * Does exist one action manager with at least one trigger
  1517. * @return {boolean} whether or not it exists one action manager with one trigger
  1518. **/
  1519. static readonly HasTriggers: boolean;
  1520. /**
  1521. * Does exist one action manager with at least one pick trigger
  1522. * @return {boolean} whether or not it exists one action manager with one pick trigger
  1523. **/
  1524. static readonly HasPickTriggers: boolean;
  1525. /**
  1526. * Does exist one action manager that handles actions of a given trigger
  1527. * @param {number} trigger - the trigger to be tested
  1528. * @return {boolean} whether the trigger is handeled by at least one action manager
  1529. **/
  1530. static HasSpecificTrigger(trigger: number): boolean;
  1531. /**
  1532. * Registers an action to this action manager
  1533. * @param {BABYLON.Action} action - the action to be registered
  1534. * @return {BABYLON.Action} the action amended (prepared) after registration
  1535. */
  1536. registerAction(action: Action): Nullable<Action>;
  1537. /**
  1538. * Process a specific trigger
  1539. * @param {number} trigger - the trigger to process
  1540. * @param evt {BABYLON.ActionEvent} the event details to be processed
  1541. */
  1542. processTrigger(trigger: number, evt?: ActionEvent): void;
  1543. _getEffectiveTarget(target: any, propertyPath: string): any;
  1544. _getProperty(propertyPath: string): string;
  1545. serialize(name: string): any;
  1546. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  1547. static GetTriggerName(trigger: number): string;
  1548. }
  1549. }
  1550. declare module BABYLON {
  1551. class Condition {
  1552. _actionManager: ActionManager;
  1553. _evaluationId: number;
  1554. _currentResult: boolean;
  1555. constructor(actionManager: ActionManager);
  1556. isValid(): boolean;
  1557. _getProperty(propertyPath: string): string;
  1558. _getEffectiveTarget(target: any, propertyPath: string): any;
  1559. serialize(): any;
  1560. protected _serialize(serializedCondition: any): any;
  1561. }
  1562. class ValueCondition extends Condition {
  1563. propertyPath: string;
  1564. value: any;
  1565. operator: number;
  1566. private static _IsEqual;
  1567. private static _IsDifferent;
  1568. private static _IsGreater;
  1569. private static _IsLesser;
  1570. static readonly IsEqual: number;
  1571. static readonly IsDifferent: number;
  1572. static readonly IsGreater: number;
  1573. static readonly IsLesser: number;
  1574. _actionManager: ActionManager;
  1575. private _target;
  1576. private _effectiveTarget;
  1577. private _property;
  1578. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1579. isValid(): boolean;
  1580. serialize(): any;
  1581. static GetOperatorName(operator: number): string;
  1582. }
  1583. class PredicateCondition extends Condition {
  1584. predicate: () => boolean;
  1585. _actionManager: ActionManager;
  1586. constructor(actionManager: ActionManager, predicate: () => boolean);
  1587. isValid(): boolean;
  1588. }
  1589. class StateCondition extends Condition {
  1590. value: string;
  1591. _actionManager: ActionManager;
  1592. private _target;
  1593. constructor(actionManager: ActionManager, target: any, value: string);
  1594. isValid(): boolean;
  1595. serialize(): any;
  1596. }
  1597. }
  1598. declare module BABYLON {
  1599. class SwitchBooleanAction extends Action {
  1600. propertyPath: string;
  1601. private _target;
  1602. private _effectiveTarget;
  1603. private _property;
  1604. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1605. _prepare(): void;
  1606. execute(): void;
  1607. serialize(parent: any): any;
  1608. }
  1609. class SetStateAction extends Action {
  1610. value: string;
  1611. private _target;
  1612. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1613. execute(): void;
  1614. serialize(parent: any): any;
  1615. }
  1616. class SetValueAction extends Action {
  1617. propertyPath: string;
  1618. value: any;
  1619. private _target;
  1620. private _effectiveTarget;
  1621. private _property;
  1622. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1623. _prepare(): void;
  1624. execute(): void;
  1625. serialize(parent: any): any;
  1626. }
  1627. class IncrementValueAction extends Action {
  1628. propertyPath: string;
  1629. value: any;
  1630. private _target;
  1631. private _effectiveTarget;
  1632. private _property;
  1633. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1634. _prepare(): void;
  1635. execute(): void;
  1636. serialize(parent: any): any;
  1637. }
  1638. class PlayAnimationAction extends Action {
  1639. from: number;
  1640. to: number;
  1641. loop: boolean | undefined;
  1642. private _target;
  1643. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean | undefined, condition?: Condition);
  1644. _prepare(): void;
  1645. execute(): void;
  1646. serialize(parent: any): any;
  1647. }
  1648. class StopAnimationAction extends Action {
  1649. private _target;
  1650. constructor(triggerOptions: any, target: any, condition?: Condition);
  1651. _prepare(): void;
  1652. execute(): void;
  1653. serialize(parent: any): any;
  1654. }
  1655. class DoNothingAction extends Action {
  1656. constructor(triggerOptions?: any, condition?: Condition);
  1657. execute(): void;
  1658. serialize(parent: any): any;
  1659. }
  1660. class CombineAction extends Action {
  1661. children: Action[];
  1662. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1663. _prepare(): void;
  1664. execute(evt: ActionEvent): void;
  1665. serialize(parent: any): any;
  1666. }
  1667. class ExecuteCodeAction extends Action {
  1668. func: (evt: ActionEvent) => void;
  1669. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1670. execute(evt: ActionEvent): void;
  1671. }
  1672. class SetParentAction extends Action {
  1673. private _parent;
  1674. private _target;
  1675. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1676. _prepare(): void;
  1677. execute(): void;
  1678. serialize(parent: any): any;
  1679. }
  1680. class PlaySoundAction extends Action {
  1681. private _sound;
  1682. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1683. _prepare(): void;
  1684. execute(): void;
  1685. serialize(parent: any): any;
  1686. }
  1687. class StopSoundAction extends Action {
  1688. private _sound;
  1689. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1690. _prepare(): void;
  1691. execute(): void;
  1692. serialize(parent: any): any;
  1693. }
  1694. }
  1695. declare module BABYLON {
  1696. class InterpolateValueAction extends Action {
  1697. propertyPath: string;
  1698. value: any;
  1699. duration: number;
  1700. stopOtherAnimations: boolean | undefined;
  1701. onInterpolationDone: (() => void) | undefined;
  1702. private _target;
  1703. private _effectiveTarget;
  1704. private _property;
  1705. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  1706. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean | undefined, onInterpolationDone?: (() => void) | undefined);
  1707. _prepare(): void;
  1708. execute(): void;
  1709. serialize(parent: any): any;
  1710. }
  1711. }
  1712. declare module BABYLON {
  1713. class Animatable {
  1714. target: any;
  1715. fromFrame: number;
  1716. toFrame: number;
  1717. loopAnimation: boolean;
  1718. onAnimationEnd: (() => void) | null | undefined;
  1719. private _localDelayOffset;
  1720. private _pausedDelay;
  1721. private _runtimeAnimations;
  1722. private _paused;
  1723. private _scene;
  1724. private _speedRatio;
  1725. animationStarted: boolean;
  1726. speedRatio: number;
  1727. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: (() => void) | null | undefined, animations?: any);
  1728. getAnimations(): RuntimeAnimation[];
  1729. appendAnimations(target: any, animations: Animation[]): void;
  1730. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  1731. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  1732. reset(): void;
  1733. enableBlending(blendingSpeed: number): void;
  1734. disableBlending(): void;
  1735. goToFrame(frame: number): void;
  1736. pause(): void;
  1737. restart(): void;
  1738. stop(animationName?: string): void;
  1739. _animate(delay: number): boolean;
  1740. }
  1741. }
  1742. declare module BABYLON {
  1743. class AnimationRange {
  1744. name: string;
  1745. from: number;
  1746. to: number;
  1747. constructor(name: string, from: number, to: number);
  1748. clone(): AnimationRange;
  1749. }
  1750. /**
  1751. * Composed of a frame, and an action function
  1752. */
  1753. class AnimationEvent {
  1754. frame: number;
  1755. action: () => void;
  1756. onlyOnce: boolean | undefined;
  1757. isDone: boolean;
  1758. constructor(frame: number, action: () => void, onlyOnce?: boolean | undefined);
  1759. }
  1760. class PathCursor {
  1761. private path;
  1762. private _onchange;
  1763. value: number;
  1764. animations: Animation[];
  1765. constructor(path: Path2);
  1766. getPoint(): Vector3;
  1767. moveAhead(step?: number): PathCursor;
  1768. moveBack(step?: number): PathCursor;
  1769. move(step: number): PathCursor;
  1770. private ensureLimits();
  1771. private raiseOnChange();
  1772. onchange(f: (cursor: PathCursor) => void): PathCursor;
  1773. }
  1774. interface IAnimationKey {
  1775. frame: number;
  1776. value: any;
  1777. inTangent?: any;
  1778. outTangent?: any;
  1779. interpolation?: AnimationKeyInterpolation;
  1780. }
  1781. enum AnimationKeyInterpolation {
  1782. /**
  1783. * Do not interpolate between keys and use the start key value only. Tangents are ignored.
  1784. */
  1785. STEP = 1,
  1786. }
  1787. class Animation {
  1788. name: string;
  1789. targetProperty: string;
  1790. framePerSecond: number;
  1791. dataType: number;
  1792. loopMode: number | undefined;
  1793. enableBlending: boolean | undefined;
  1794. static AllowMatricesInterpolation: boolean;
  1795. private _keys;
  1796. private _easingFunction;
  1797. _runtimeAnimations: RuntimeAnimation[];
  1798. private _events;
  1799. targetPropertyPath: string[];
  1800. blendingSpeed: number;
  1801. private _ranges;
  1802. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  1803. /**
  1804. * Sets up an animation.
  1805. * @param property the property to animate
  1806. * @param animationType the animation type to apply
  1807. * @param easingFunction the easing function used in the animation
  1808. * @returns The created animation
  1809. */
  1810. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  1811. /**
  1812. * Create and start an animation on a node
  1813. * @param {string} name defines the name of the global animation that will be run on all nodes
  1814. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1815. * @param {string} targetProperty defines property to animate
  1816. * @param {number} framePerSecond defines the number of frame per second yo use
  1817. * @param {number} totalFrame defines the number of frames in total
  1818. * @param {any} from defines the initial value
  1819. * @param {any} to defines the final value
  1820. * @param {number} loopMode defines which loop mode you want to use (off by default)
  1821. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  1822. * @param onAnimationEnd defines the callback to call when animation end
  1823. * @returns the animatable created for this animation
  1824. */
  1825. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  1826. /**
  1827. * Create and start an animation on a node and its descendants
  1828. * @param {string} name defines the name of the global animation that will be run on all nodes
  1829. * @param {BABYLON.Node} node defines the root node where the animation will take place
  1830. * @param {boolean} 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.
  1831. * @param {string} targetProperty defines property to animate
  1832. * @param {number} framePerSecond defines the number of frame per second yo use
  1833. * @param {number} totalFrame defines the number of frames in total
  1834. * @param {any} from defines the initial value
  1835. * @param {any} to defines the final value
  1836. * @param {number} loopMode defines which loop mode you want to use (off by default)
  1837. * @param {BABYLON.EasingFunction} easingFunction defines the easing function to use (linear by default)
  1838. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  1839. * @returns the list of animatables created for all nodes
  1840. * @example https://www.babylonjs-playground.com/#MH0VLI
  1841. */
  1842. 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[]>;
  1843. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  1844. /**
  1845. * Transition property of the Camera to the target Value.
  1846. * @param property The property to transition
  1847. * @param targetValue The target Value of the property
  1848. * @param host The object where the property to animate belongs
  1849. * @param scene Scene used to run the animation
  1850. * @param frameRate Framerate (in frame/s) to use
  1851. * @param transition The transition type we want to use
  1852. * @param duration The duration of the animation, in milliseconds
  1853. * @param onAnimationEnd Call back trigger at the end of the animation.
  1854. */
  1855. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  1856. /**
  1857. * Return the array of runtime animations currently using this animation
  1858. */
  1859. readonly runtimeAnimations: RuntimeAnimation[];
  1860. readonly hasRunningRuntimeAnimations: boolean;
  1861. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number | undefined, enableBlending?: boolean | undefined);
  1862. /**
  1863. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  1864. */
  1865. toString(fullDetails?: boolean): string;
  1866. /**
  1867. * Add an event to this animation.
  1868. */
  1869. addEvent(event: AnimationEvent): void;
  1870. /**
  1871. * Remove all events found at the given frame
  1872. * @param frame
  1873. */
  1874. removeEvents(frame: number): void;
  1875. getEvents(): AnimationEvent[];
  1876. createRange(name: string, from: number, to: number): void;
  1877. deleteRange(name: string, deleteFrames?: boolean): void;
  1878. getRange(name: string): Nullable<AnimationRange>;
  1879. getKeys(): Array<IAnimationKey>;
  1880. getHighestFrame(): number;
  1881. getEasingFunction(): IEasingFunction;
  1882. setEasingFunction(easingFunction: EasingFunction): void;
  1883. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  1884. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  1885. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  1886. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  1887. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  1888. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  1889. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  1890. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  1891. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  1892. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  1893. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  1894. clone(): Animation;
  1895. setKeys(values: Array<IAnimationKey>): void;
  1896. serialize(): any;
  1897. private static _ANIMATIONTYPE_FLOAT;
  1898. private static _ANIMATIONTYPE_VECTOR3;
  1899. private static _ANIMATIONTYPE_QUATERNION;
  1900. private static _ANIMATIONTYPE_MATRIX;
  1901. private static _ANIMATIONTYPE_COLOR3;
  1902. private static _ANIMATIONTYPE_VECTOR2;
  1903. private static _ANIMATIONTYPE_SIZE;
  1904. private static _ANIMATIONLOOPMODE_RELATIVE;
  1905. private static _ANIMATIONLOOPMODE_CYCLE;
  1906. private static _ANIMATIONLOOPMODE_CONSTANT;
  1907. static readonly ANIMATIONTYPE_FLOAT: number;
  1908. static readonly ANIMATIONTYPE_VECTOR3: number;
  1909. static readonly ANIMATIONTYPE_VECTOR2: number;
  1910. static readonly ANIMATIONTYPE_SIZE: number;
  1911. static readonly ANIMATIONTYPE_QUATERNION: number;
  1912. static readonly ANIMATIONTYPE_MATRIX: number;
  1913. static readonly ANIMATIONTYPE_COLOR3: number;
  1914. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  1915. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  1916. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  1917. static Parse(parsedAnimation: any): Animation;
  1918. static AppendSerializedAnimations(source: IAnimatable, destination: any): any;
  1919. }
  1920. }
  1921. declare module BABYLON {
  1922. /**
  1923. * This class defines the direct association between an animation and a target
  1924. */
  1925. class TargetedAnimation {
  1926. animation: Animation;
  1927. target: any;
  1928. }
  1929. /**
  1930. * Use this class to create coordinated animations on multiple targets
  1931. */
  1932. class AnimationGroup implements IDisposable {
  1933. name: string;
  1934. private _scene;
  1935. private _targetedAnimations;
  1936. private _animatables;
  1937. private _from;
  1938. private _to;
  1939. private _isStarted;
  1940. private _speedRatio;
  1941. onAnimationEndObservable: Observable<TargetedAnimation>;
  1942. /**
  1943. * Define if the animations are started
  1944. */
  1945. readonly isStarted: boolean;
  1946. /**
  1947. * Gets or sets the speed ratio to use for all animations
  1948. */
  1949. /**
  1950. * Gets or sets the speed ratio to use for all animations
  1951. */
  1952. speedRatio: number;
  1953. /**
  1954. * Gets the targeted animations for this animation group
  1955. */
  1956. readonly targetedAnimations: Array<TargetedAnimation>;
  1957. constructor(name: string, scene?: Nullable<Scene>);
  1958. /**
  1959. * Add an animation (with its target) in the group
  1960. * @param animation defines the animation we want to add
  1961. * @param target defines the target of the animation
  1962. * @returns the {BABYLON.TargetedAnimation} object
  1963. */
  1964. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  1965. /**
  1966. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  1967. * It can add constant keys at begin or end
  1968. * @param beginFrame defines the new begin frame for all animations. It can't be bigger than the smallest begin frame of all animations
  1969. * @param endFrame defines the new end frame for all animations. It can't be smaller than the largest end frame of all animations
  1970. */
  1971. normalize(beginFrame?: number, endFrame?: number): AnimationGroup;
  1972. /**
  1973. * Start all animations on given targets
  1974. * @param loop defines if animations must loop
  1975. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  1976. */
  1977. start(loop?: boolean, speedRatio?: number): AnimationGroup;
  1978. /**
  1979. * Pause all animations
  1980. */
  1981. pause(): AnimationGroup;
  1982. /**
  1983. * Play all animations to initial state
  1984. * This function will start() the animations if they were not started or will restart() them if they were paused
  1985. * @param loop defines if animations must loop
  1986. */
  1987. play(loop?: boolean): AnimationGroup;
  1988. /**
  1989. * Reset all animations to initial state
  1990. */
  1991. reset(): AnimationGroup;
  1992. /**
  1993. * Restart animations from key 0
  1994. */
  1995. restart(): AnimationGroup;
  1996. /**
  1997. * Stop all animations
  1998. */
  1999. stop(): AnimationGroup;
  2000. /**
  2001. * Dispose all associated resources
  2002. */
  2003. dispose(): void;
  2004. }
  2005. }
  2006. declare module BABYLON {
  2007. interface IEasingFunction {
  2008. ease(gradient: number): number;
  2009. }
  2010. class EasingFunction implements IEasingFunction {
  2011. private static _EASINGMODE_EASEIN;
  2012. private static _EASINGMODE_EASEOUT;
  2013. private static _EASINGMODE_EASEINOUT;
  2014. static readonly EASINGMODE_EASEIN: number;
  2015. static readonly EASINGMODE_EASEOUT: number;
  2016. static readonly EASINGMODE_EASEINOUT: number;
  2017. private _easingMode;
  2018. setEasingMode(easingMode: number): void;
  2019. getEasingMode(): number;
  2020. easeInCore(gradient: number): number;
  2021. ease(gradient: number): number;
  2022. }
  2023. class CircleEase extends EasingFunction implements IEasingFunction {
  2024. easeInCore(gradient: number): number;
  2025. }
  2026. class BackEase extends EasingFunction implements IEasingFunction {
  2027. amplitude: number;
  2028. constructor(amplitude?: number);
  2029. easeInCore(gradient: number): number;
  2030. }
  2031. class BounceEase extends EasingFunction implements IEasingFunction {
  2032. bounces: number;
  2033. bounciness: number;
  2034. constructor(bounces?: number, bounciness?: number);
  2035. easeInCore(gradient: number): number;
  2036. }
  2037. class CubicEase extends EasingFunction implements IEasingFunction {
  2038. easeInCore(gradient: number): number;
  2039. }
  2040. class ElasticEase extends EasingFunction implements IEasingFunction {
  2041. oscillations: number;
  2042. springiness: number;
  2043. constructor(oscillations?: number, springiness?: number);
  2044. easeInCore(gradient: number): number;
  2045. }
  2046. class ExponentialEase extends EasingFunction implements IEasingFunction {
  2047. exponent: number;
  2048. constructor(exponent?: number);
  2049. easeInCore(gradient: number): number;
  2050. }
  2051. class PowerEase extends EasingFunction implements IEasingFunction {
  2052. power: number;
  2053. constructor(power?: number);
  2054. easeInCore(gradient: number): number;
  2055. }
  2056. class QuadraticEase extends EasingFunction implements IEasingFunction {
  2057. easeInCore(gradient: number): number;
  2058. }
  2059. class QuarticEase extends EasingFunction implements IEasingFunction {
  2060. easeInCore(gradient: number): number;
  2061. }
  2062. class QuinticEase extends EasingFunction implements IEasingFunction {
  2063. easeInCore(gradient: number): number;
  2064. }
  2065. class SineEase extends EasingFunction implements IEasingFunction {
  2066. easeInCore(gradient: number): number;
  2067. }
  2068. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  2069. x1: number;
  2070. y1: number;
  2071. x2: number;
  2072. y2: number;
  2073. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  2074. easeInCore(gradient: number): number;
  2075. }
  2076. }
  2077. declare module BABYLON {
  2078. class RuntimeAnimation {
  2079. currentFrame: number;
  2080. private _animation;
  2081. private _target;
  2082. private _originalBlendValue;
  2083. private _offsetsCache;
  2084. private _highLimitsCache;
  2085. private _stopped;
  2086. private _blendingFactor;
  2087. constructor(target: any, animation: Animation);
  2088. readonly animation: Animation;
  2089. reset(): void;
  2090. isStopped(): boolean;
  2091. dispose(): void;
  2092. private _getKeyValue(value);
  2093. private _interpolate(currentFrame, repeatCount, loopMode?, offsetValue?, highLimitValue?);
  2094. setValue(currentValue: any, blend?: boolean): void;
  2095. goToFrame(frame: number): void;
  2096. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  2097. private _ratioOffset;
  2098. private _previousDelay;
  2099. private _previousRatio;
  2100. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, blend?: boolean): boolean;
  2101. }
  2102. }
  2103. declare module BABYLON {
  2104. class Analyser {
  2105. SMOOTHING: number;
  2106. FFT_SIZE: number;
  2107. BARGRAPHAMPLITUDE: number;
  2108. DEBUGCANVASPOS: {
  2109. x: number;
  2110. y: number;
  2111. };
  2112. DEBUGCANVASSIZE: {
  2113. width: number;
  2114. height: number;
  2115. };
  2116. private _byteFreqs;
  2117. private _byteTime;
  2118. private _floatFreqs;
  2119. private _webAudioAnalyser;
  2120. private _debugCanvas;
  2121. private _debugCanvasContext;
  2122. private _scene;
  2123. private _registerFunc;
  2124. private _audioEngine;
  2125. constructor(scene: Scene);
  2126. getFrequencyBinCount(): number;
  2127. getByteFrequencyData(): Uint8Array;
  2128. getByteTimeDomainData(): Uint8Array;
  2129. getFloatFrequencyData(): Uint8Array;
  2130. drawDebugCanvas(): void;
  2131. stopDebugCanvas(): void;
  2132. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  2133. dispose(): void;
  2134. }
  2135. }
  2136. declare module BABYLON {
  2137. class AudioEngine {
  2138. private _audioContext;
  2139. private _audioContextInitialized;
  2140. canUseWebAudio: boolean;
  2141. masterGain: GainNode;
  2142. private _connectedAnalyser;
  2143. WarnedWebAudioUnsupported: boolean;
  2144. unlocked: boolean;
  2145. onAudioUnlocked: () => any;
  2146. isMP3supported: boolean;
  2147. isOGGsupported: boolean;
  2148. readonly audioContext: Nullable<AudioContext>;
  2149. constructor();
  2150. private _unlockiOSaudio();
  2151. private _initializeAudioContext();
  2152. dispose(): void;
  2153. getGlobalVolume(): number;
  2154. setGlobalVolume(newVolume: number): void;
  2155. connectToAnalyser(analyser: Analyser): void;
  2156. }
  2157. }
  2158. declare module BABYLON {
  2159. class Sound {
  2160. name: string;
  2161. autoplay: boolean;
  2162. loop: boolean;
  2163. useCustomAttenuation: boolean;
  2164. soundTrackId: number;
  2165. spatialSound: boolean;
  2166. refDistance: number;
  2167. rolloffFactor: number;
  2168. maxDistance: number;
  2169. distanceModel: string;
  2170. private _panningModel;
  2171. onended: () => any;
  2172. private _playbackRate;
  2173. private _streaming;
  2174. private _startTime;
  2175. private _startOffset;
  2176. private _position;
  2177. private _localDirection;
  2178. private _volume;
  2179. private _isReadyToPlay;
  2180. isPlaying: boolean;
  2181. isPaused: boolean;
  2182. private _isDirectional;
  2183. private _readyToPlayCallback;
  2184. private _audioBuffer;
  2185. private _soundSource;
  2186. private _streamingSource;
  2187. private _soundPanner;
  2188. private _soundGain;
  2189. private _inputAudioNode;
  2190. private _ouputAudioNode;
  2191. private _coneInnerAngle;
  2192. private _coneOuterAngle;
  2193. private _coneOuterGain;
  2194. private _scene;
  2195. private _connectedMesh;
  2196. private _customAttenuationFunction;
  2197. private _registerFunc;
  2198. private _isOutputConnected;
  2199. private _htmlAudioElement;
  2200. private _urlType;
  2201. /**
  2202. * Create a sound and attach it to a scene
  2203. * @param name Name of your sound
  2204. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  2205. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  2206. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  2207. */
  2208. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  2209. dispose(): void;
  2210. isReady(): boolean;
  2211. private _soundLoaded(audioData);
  2212. setAudioBuffer(audioBuffer: AudioBuffer): void;
  2213. updateOptions(options: any): void;
  2214. private _createSpatialParameters();
  2215. private _updateSpatialParameters();
  2216. switchPanningModelToHRTF(): void;
  2217. switchPanningModelToEqualPower(): void;
  2218. private _switchPanningModel();
  2219. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  2220. /**
  2221. * Transform this sound into a directional source
  2222. * @param coneInnerAngle Size of the inner cone in degree
  2223. * @param coneOuterAngle Size of the outer cone in degree
  2224. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  2225. */
  2226. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  2227. setPosition(newPosition: Vector3): void;
  2228. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  2229. private _updateDirection();
  2230. updateDistanceFromListener(): void;
  2231. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  2232. /**
  2233. * Play the sound
  2234. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  2235. * @param offset (optional) Start the sound setting it at a specific time
  2236. */
  2237. play(time?: number, offset?: number): void;
  2238. private _onended();
  2239. /**
  2240. * Stop the sound
  2241. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  2242. */
  2243. stop(time?: number): void;
  2244. pause(): void;
  2245. setVolume(newVolume: number, time?: number): void;
  2246. setPlaybackRate(newPlaybackRate: number): void;
  2247. getVolume(): number;
  2248. attachToMesh(meshToConnectTo: AbstractMesh): void;
  2249. detachFromMesh(): void;
  2250. private _onRegisterAfterWorldMatrixUpdate(node);
  2251. clone(): Nullable<Sound>;
  2252. getAudioBuffer(): AudioBuffer | null;
  2253. serialize(): any;
  2254. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  2255. }
  2256. }
  2257. declare module BABYLON {
  2258. class SoundTrack {
  2259. private _outputAudioNode;
  2260. private _scene;
  2261. id: number;
  2262. soundCollection: Array<Sound>;
  2263. private _isMainTrack;
  2264. private _connectedAnalyser;
  2265. private _options;
  2266. private _isInitialized;
  2267. constructor(scene: Scene, options?: any);
  2268. private _initializeSoundTrackAudioGraph();
  2269. dispose(): void;
  2270. AddSound(sound: Sound): void;
  2271. RemoveSound(sound: Sound): void;
  2272. setVolume(newVolume: number): void;
  2273. switchPanningModelToHRTF(): void;
  2274. switchPanningModelToEqualPower(): void;
  2275. connectToAnalyser(analyser: Analyser): void;
  2276. }
  2277. }
  2278. declare module BABYLON {
  2279. interface Behavior<T extends Node> {
  2280. name: string;
  2281. init(): void;
  2282. attach(node: T): void;
  2283. detach(): void;
  2284. }
  2285. }
  2286. declare module BABYLON {
  2287. class Bone extends Node {
  2288. name: string;
  2289. private static _tmpVecs;
  2290. private static _tmpQuat;
  2291. private static _tmpMats;
  2292. children: Bone[];
  2293. animations: Animation[];
  2294. length: number;
  2295. _index: Nullable<number>;
  2296. private _skeleton;
  2297. private _localMatrix;
  2298. private _restPose;
  2299. private _baseMatrix;
  2300. private _worldTransform;
  2301. private _absoluteTransform;
  2302. private _invertedAbsoluteTransform;
  2303. private _parent;
  2304. private _scaleMatrix;
  2305. private _scaleVector;
  2306. private _negateScaleChildren;
  2307. private _scalingDeterminant;
  2308. _matrix: Matrix;
  2309. constructor(name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  2310. getSkeleton(): Skeleton;
  2311. getParent(): Nullable<Bone>;
  2312. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  2313. getLocalMatrix(): Matrix;
  2314. getBaseMatrix(): Matrix;
  2315. getRestPose(): Matrix;
  2316. returnToRest(): void;
  2317. getWorldMatrix(): Matrix;
  2318. getInvertedAbsoluteTransform(): Matrix;
  2319. getAbsoluteTransform(): Matrix;
  2320. position: Vector3;
  2321. rotation: Vector3;
  2322. rotationQuaternion: Quaternion;
  2323. scaling: Vector3;
  2324. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean): void;
  2325. _updateDifferenceMatrix(rootMatrix?: Matrix): void;
  2326. markAsDirty(): void;
  2327. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired?: boolean, skelDimensionsRatio?: Nullable<Vector3>): boolean;
  2328. /**
  2329. * Translate the bone in local or world space.
  2330. * @param vec The amount to translate the bone.
  2331. * @param space The space that the translation is in.
  2332. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2333. */
  2334. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2335. /**
  2336. * Set the postion of the bone in local or world space.
  2337. * @param position The position to set the bone.
  2338. * @param space The space that the position is in.
  2339. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2340. */
  2341. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2342. /**
  2343. * Set the absolute postion of the bone (world space).
  2344. * @param position The position to set the bone.
  2345. * @param mesh The mesh that this bone is attached to.
  2346. */
  2347. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  2348. /**
  2349. * Set the scale of the bone on the x, y and z axes.
  2350. * @param x The scale of the bone on the x axis.
  2351. * @param x The scale of the bone on the y axis.
  2352. * @param z The scale of the bone on the z axis.
  2353. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2354. */
  2355. setScale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2356. /**
  2357. * Scale the bone on the x, y and z axes.
  2358. * @param x The amount to scale the bone on the x axis.
  2359. * @param x The amount to scale the bone on the y axis.
  2360. * @param z The amount to scale the bone on the z axis.
  2361. * @param scaleChildren Set this to true if children of the bone should be scaled.
  2362. */
  2363. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  2364. /**
  2365. * Set the yaw, pitch, and roll of the bone in local or world space.
  2366. * @param yaw The rotation of the bone on the y axis.
  2367. * @param pitch The rotation of the bone on the x axis.
  2368. * @param roll The rotation of the bone on the z axis.
  2369. * @param space The space that the axes of rotation are in.
  2370. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2371. */
  2372. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  2373. /**
  2374. * Rotate the bone on an axis in local or world space.
  2375. * @param axis The axis to rotate the bone on.
  2376. * @param amount The amount to rotate the bone.
  2377. * @param space The space that the axis is in.
  2378. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2379. */
  2380. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  2381. /**
  2382. * Set the rotation of the bone to a particular axis angle in local or world space.
  2383. * @param axis The axis to rotate the bone on.
  2384. * @param angle The angle that the bone should be rotated to.
  2385. * @param space The space that the axis is in.
  2386. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2387. */
  2388. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  2389. /**
  2390. * Set the euler rotation of the bone in local of world space.
  2391. * @param rotation The euler rotation that the bone should be set to.
  2392. * @param space The space that the rotation is in.
  2393. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2394. */
  2395. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  2396. /**
  2397. * Set the quaternion rotation of the bone in local of world space.
  2398. * @param quat The quaternion rotation that the bone should be set to.
  2399. * @param space The space that the rotation is in.
  2400. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2401. */
  2402. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  2403. /**
  2404. * Set the rotation matrix of the bone in local of world space.
  2405. * @param rotMat The rotation matrix that the bone should be set to.
  2406. * @param space The space that the rotation is in.
  2407. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2408. */
  2409. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  2410. private _rotateWithMatrix(rmat, space?, mesh?);
  2411. private _getNegativeRotationToRef(rotMatInv, space?, mesh?);
  2412. /**
  2413. * Get the scale of the bone
  2414. * @returns the scale of the bone
  2415. */
  2416. getScale(): Vector3;
  2417. /**
  2418. * Copy the scale of the bone to a vector3.
  2419. * @param result The vector3 to copy the scale to
  2420. */
  2421. getScaleToRef(result: Vector3): void;
  2422. /**
  2423. * Get the position of the bone in local or world space.
  2424. * @param space The space that the returned position is in.
  2425. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2426. * @returns The position of the bone
  2427. */
  2428. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2429. /**
  2430. * Copy the position of the bone to a vector3 in local or world space.
  2431. * @param space The space that the returned position is in.
  2432. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2433. * @param result The vector3 to copy the position to.
  2434. */
  2435. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  2436. /**
  2437. * Get the absolute position of the bone (world space).
  2438. * @param mesh The mesh that this bone is attached to.
  2439. * @returns The absolute position of the bone
  2440. */
  2441. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  2442. /**
  2443. * Copy the absolute position of the bone (world space) to the result param.
  2444. * @param mesh The mesh that this bone is attached to.
  2445. * @param result The vector3 to copy the absolute position to.
  2446. */
  2447. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  2448. /**
  2449. * Compute the absolute transforms of this bone and its children.
  2450. */
  2451. computeAbsoluteTransforms(): void;
  2452. private _syncScaleVector();
  2453. /**
  2454. * Get the world direction from an axis that is in the local space of the bone.
  2455. * @param localAxis The local direction that is used to compute the world direction.
  2456. * @param mesh The mesh that this bone is attached to.
  2457. * @returns The world direction
  2458. */
  2459. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2460. /**
  2461. * Copy the world direction to a vector3 from an axis that is in the local space of the bone.
  2462. * @param localAxis The local direction that is used to compute the world direction.
  2463. * @param mesh The mesh that this bone is attached to.
  2464. * @param result The vector3 that the world direction will be copied to.
  2465. */
  2466. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2467. /**
  2468. * Get the euler rotation of the bone in local or world space.
  2469. * @param space The space that the rotation should be in.
  2470. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2471. * @returns The euler rotation
  2472. */
  2473. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  2474. /**
  2475. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space.
  2476. * @param space The space that the rotation should be in.
  2477. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2478. * @param result The vector3 that the rotation should be copied to.
  2479. */
  2480. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2481. /**
  2482. * Get the quaternion rotation of the bone in either local or world space.
  2483. * @param space The space that the rotation should be in.
  2484. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2485. * @returns The quaternion rotation
  2486. */
  2487. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  2488. /**
  2489. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space.
  2490. * @param space The space that the rotation should be in.
  2491. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2492. * @param result The quaternion that the rotation should be copied to.
  2493. */
  2494. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  2495. /**
  2496. * Get the rotation matrix of the bone in local or world space.
  2497. * @param space The space that the rotation should be in.
  2498. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2499. * @returns The rotation matrix
  2500. */
  2501. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  2502. /**
  2503. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space.
  2504. * @param space The space that the rotation should be in.
  2505. * @param mesh The mesh that this bone is attached to. This is only used in world space.
  2506. * @param result The quaternion that the rotation should be copied to.
  2507. */
  2508. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  2509. /**
  2510. * Get the world position of a point that is in the local space of the bone.
  2511. * @param position The local position
  2512. * @param mesh The mesh that this bone is attached to.
  2513. * @returns The world position
  2514. */
  2515. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2516. /**
  2517. * Get the world position of a point that is in the local space of the bone and copy it to the result param.
  2518. * @param position The local position
  2519. * @param mesh The mesh that this bone is attached to.
  2520. * @param result The vector3 that the world position should be copied to.
  2521. */
  2522. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2523. /**
  2524. * Get the local position of a point that is in world space.
  2525. * @param position The world position
  2526. * @param mesh The mesh that this bone is attached to.
  2527. * @returns The local position
  2528. */
  2529. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  2530. /**
  2531. * Get the local position of a point that is in world space and copy it to the result param.
  2532. * @param position The world position
  2533. * @param mesh The mesh that this bone is attached to.
  2534. * @param result The vector3 that the local position should be copied to.
  2535. */
  2536. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  2537. }
  2538. }
  2539. declare module BABYLON {
  2540. class BoneIKController {
  2541. private static _tmpVecs;
  2542. private static _tmpQuat;
  2543. private static _tmpMats;
  2544. targetMesh: AbstractMesh;
  2545. poleTargetMesh: AbstractMesh;
  2546. poleTargetBone: Nullable<Bone>;
  2547. targetPosition: Vector3;
  2548. poleTargetPosition: Vector3;
  2549. poleTargetLocalOffset: Vector3;
  2550. poleAngle: number;
  2551. mesh: AbstractMesh;
  2552. slerpAmount: number;
  2553. private _bone1Quat;
  2554. private _bone1Mat;
  2555. private _bone2Ang;
  2556. private _bone1;
  2557. private _bone2;
  2558. private _bone1Length;
  2559. private _bone2Length;
  2560. private _maxAngle;
  2561. private _maxReach;
  2562. private _rightHandedSystem;
  2563. private _bendAxis;
  2564. private _slerping;
  2565. private _adjustRoll;
  2566. maxAngle: number;
  2567. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  2568. targetMesh?: AbstractMesh;
  2569. poleTargetMesh?: AbstractMesh;
  2570. poleTargetBone?: Bone;
  2571. poleTargetLocalOffset?: Vector3;
  2572. poleAngle?: number;
  2573. bendAxis?: Vector3;
  2574. maxAngle?: number;
  2575. slerpAmount?: number;
  2576. });
  2577. private _setMaxAngle(ang);
  2578. update(): void;
  2579. }
  2580. }
  2581. declare module BABYLON {
  2582. class BoneLookController {
  2583. private static _tmpVecs;
  2584. private static _tmpQuat;
  2585. private static _tmpMats;
  2586. /**
  2587. * The target Vector3 that the bone will look at.
  2588. */
  2589. target: Vector3;
  2590. /**
  2591. * The mesh that the bone is attached to.
  2592. */
  2593. mesh: AbstractMesh;
  2594. /**
  2595. * The bone that will be looking to the target.
  2596. */
  2597. bone: Bone;
  2598. /**
  2599. * The up axis of the coordinate system that is used when the bone is rotated.
  2600. */
  2601. upAxis: Vector3;
  2602. /**
  2603. * The space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2604. */
  2605. upAxisSpace: Space;
  2606. /**
  2607. * Used to make an adjustment to the yaw of the bone.
  2608. */
  2609. adjustYaw: number;
  2610. /**
  2611. * Used to make an adjustment to the pitch of the bone.
  2612. */
  2613. adjustPitch: number;
  2614. /**
  2615. * Used to make an adjustment to the roll of the bone.
  2616. */
  2617. adjustRoll: number;
  2618. /**
  2619. * 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).
  2620. */
  2621. slerpAmount: number;
  2622. private _minYaw;
  2623. private _maxYaw;
  2624. private _minPitch;
  2625. private _maxPitch;
  2626. private _minYawSin;
  2627. private _minYawCos;
  2628. private _maxYawSin;
  2629. private _maxYawCos;
  2630. private _midYawConstraint;
  2631. private _minPitchTan;
  2632. private _maxPitchTan;
  2633. private _boneQuat;
  2634. private _slerping;
  2635. private _transformYawPitch;
  2636. private _transformYawPitchInv;
  2637. private _firstFrameSkipped;
  2638. private _yawRange;
  2639. private _fowardAxis;
  2640. /**
  2641. * Get/set the minimum yaw angle that the bone can look to.
  2642. */
  2643. minYaw: number;
  2644. /**
  2645. * Get/set the maximum yaw angle that the bone can look to.
  2646. */
  2647. maxYaw: number;
  2648. /**
  2649. * Get/set the minimum pitch angle that the bone can look to.
  2650. */
  2651. minPitch: number;
  2652. /**
  2653. * Get/set the maximum pitch angle that the bone can look to.
  2654. */
  2655. maxPitch: number;
  2656. /**
  2657. * Create a BoneLookController
  2658. * @param mesh the mesh that the bone belongs to
  2659. * @param bone the bone that will be looking to the target
  2660. * @param target the target Vector3 to look at
  2661. * @param settings optional settings:
  2662. * - maxYaw: the maximum angle the bone will yaw to
  2663. * - minYaw: the minimum angle the bone will yaw to
  2664. * - maxPitch: the maximum angle the bone will pitch to
  2665. * - minPitch: the minimum angle the bone will yaw to
  2666. * - slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  2667. * - upAxis: the up axis of the coordinate system
  2668. * - upAxisSpace: the space that the up axis is in - BABYLON.Space.BONE, BABYLON.Space.LOCAL (default), or BABYLON.Space.WORLD.
  2669. * - yawAxis: set yawAxis if the bone does not yaw on the y axis
  2670. * - pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  2671. * - adjustYaw: used to make an adjustment to the yaw of the bone
  2672. * - adjustPitch: used to make an adjustment to the pitch of the bone
  2673. * - adjustRoll: used to make an adjustment to the roll of the bone
  2674. **/
  2675. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  2676. maxYaw?: number;
  2677. minYaw?: number;
  2678. maxPitch?: number;
  2679. minPitch?: number;
  2680. slerpAmount?: number;
  2681. upAxis?: Vector3;
  2682. upAxisSpace?: Space;
  2683. yawAxis?: Vector3;
  2684. pitchAxis?: Vector3;
  2685. adjustYaw?: number;
  2686. adjustPitch?: number;
  2687. adjustRoll?: number;
  2688. });
  2689. /**
  2690. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender()).
  2691. */
  2692. update(): void;
  2693. private _getAngleDiff(ang1, ang2);
  2694. private _getAngleBetween(ang1, ang2);
  2695. private _isAngleBetween(ang, ang1, ang2);
  2696. }
  2697. }
  2698. declare module BABYLON {
  2699. class Skeleton implements IAnimatable {
  2700. name: string;
  2701. id: string;
  2702. bones: Bone[];
  2703. dimensionsAtRest: Vector3;
  2704. needInitialSkinMatrix: boolean;
  2705. animations: Array<Animation>;
  2706. private _scene;
  2707. private _isDirty;
  2708. private _transformMatrices;
  2709. private _meshesWithPoseMatrix;
  2710. private _animatables;
  2711. private _identity;
  2712. private _synchronizedWithMesh;
  2713. private _ranges;
  2714. private _lastAbsoluteTransformsUpdateId;
  2715. /**
  2716. * An event triggered before computing the skeleton's matrices
  2717. * @type {BABYLON.Observable}
  2718. */
  2719. onBeforeComputeObservable: Observable<Skeleton>;
  2720. constructor(name: string, id: string, scene: Scene);
  2721. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  2722. getScene(): Scene;
  2723. /**
  2724. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2725. */
  2726. toString(fullDetails?: boolean): string;
  2727. /**
  2728. * Get bone's index searching by name
  2729. * @param {string} name is bone's name to search for
  2730. * @return {number} Indice of the bone. Returns -1 if not found
  2731. */
  2732. getBoneIndexByName(name: string): number;
  2733. createAnimationRange(name: string, from: number, to: number): void;
  2734. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  2735. getAnimationRange(name: string): Nullable<AnimationRange>;
  2736. /**
  2737. * Returns as an Array, all AnimationRanges defined on this skeleton
  2738. */
  2739. getAnimationRanges(): Nullable<AnimationRange>[];
  2740. /**
  2741. * note: This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  2742. */
  2743. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  2744. returnToRest(): void;
  2745. private _getHighestAnimationFrame();
  2746. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  2747. _markAsDirty(): void;
  2748. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  2749. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  2750. _computeTransformMatrices(targetMatrix: Float32Array, initialSkinMatrix: Nullable<Matrix>): void;
  2751. prepare(): void;
  2752. getAnimatables(): IAnimatable[];
  2753. clone(name: string, id: string): Skeleton;
  2754. enableBlending(blendingSpeed?: number): void;
  2755. dispose(): void;
  2756. serialize(): any;
  2757. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  2758. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  2759. getPoseMatrix(): Nullable<Matrix>;
  2760. sortBones(): void;
  2761. private _sortBones(index, bones, visited);
  2762. }
  2763. }
  2764. declare module BABYLON {
  2765. class ArcRotateCamera extends TargetCamera {
  2766. alpha: number;
  2767. beta: number;
  2768. radius: number;
  2769. protected _target: Vector3;
  2770. protected _targetHost: Nullable<AbstractMesh>;
  2771. target: Vector3;
  2772. inertialAlphaOffset: number;
  2773. inertialBetaOffset: number;
  2774. inertialRadiusOffset: number;
  2775. lowerAlphaLimit: Nullable<number>;
  2776. upperAlphaLimit: Nullable<number>;
  2777. lowerBetaLimit: number;
  2778. upperBetaLimit: number;
  2779. lowerRadiusLimit: Nullable<number>;
  2780. upperRadiusLimit: Nullable<number>;
  2781. inertialPanningX: number;
  2782. inertialPanningY: number;
  2783. pinchToPanMaxDistance: number;
  2784. panningDistanceLimit: Nullable<number>;
  2785. panningOriginTarget: Vector3;
  2786. panningInertia: number;
  2787. angularSensibilityX: number;
  2788. angularSensibilityY: number;
  2789. pinchPrecision: number;
  2790. pinchDeltaPercentage: number;
  2791. panningSensibility: number;
  2792. keysUp: number[];
  2793. keysDown: number[];
  2794. keysLeft: number[];
  2795. keysRight: number[];
  2796. wheelPrecision: number;
  2797. wheelDeltaPercentage: number;
  2798. zoomOnFactor: number;
  2799. targetScreenOffset: Vector2;
  2800. allowUpsideDown: boolean;
  2801. _viewMatrix: Matrix;
  2802. _useCtrlForPanning: boolean;
  2803. _panningMouseButton: number;
  2804. inputs: ArcRotateCameraInputsManager;
  2805. _reset: () => void;
  2806. panningAxis: Vector3;
  2807. protected _localDirection: Vector3;
  2808. protected _transformedDirection: Vector3;
  2809. private _bouncingBehavior;
  2810. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  2811. useBouncingBehavior: boolean;
  2812. private _framingBehavior;
  2813. readonly framingBehavior: Nullable<FramingBehavior>;
  2814. useFramingBehavior: boolean;
  2815. private _autoRotationBehavior;
  2816. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  2817. useAutoRotationBehavior: boolean;
  2818. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  2819. onCollide: (collidedMesh: AbstractMesh) => void;
  2820. checkCollisions: boolean;
  2821. collisionRadius: Vector3;
  2822. protected _collider: Collider;
  2823. protected _previousPosition: Vector3;
  2824. protected _collisionVelocity: Vector3;
  2825. protected _newPosition: Vector3;
  2826. protected _previousAlpha: number;
  2827. protected _previousBeta: number;
  2828. protected _previousRadius: number;
  2829. protected _collisionTriggered: boolean;
  2830. protected _targetBoundingCenter: Nullable<Vector3>;
  2831. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene);
  2832. _initCache(): void;
  2833. _updateCache(ignoreParentClass?: boolean): void;
  2834. protected _getTargetPosition(): Vector3;
  2835. /**
  2836. * Store current camera state (fov, position, etc..)
  2837. */
  2838. private _storedAlpha;
  2839. private _storedBeta;
  2840. private _storedRadius;
  2841. private _storedTarget;
  2842. storeState(): Camera;
  2843. /**
  2844. * Restored camera state. You must call storeState() first
  2845. */
  2846. _restoreStateValues(): boolean;
  2847. _isSynchronizedViewMatrix(): boolean;
  2848. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  2849. detachControl(element: HTMLElement): void;
  2850. _checkInputs(): void;
  2851. protected _checkLimits(): void;
  2852. rebuildAnglesAndRadius(): void;
  2853. setPosition(position: Vector3): void;
  2854. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  2855. _getViewMatrix(): Matrix;
  2856. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  2857. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  2858. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  2859. min: Vector3;
  2860. max: Vector3;
  2861. distance: number;
  2862. }, doNotUpdateMaxZ?: boolean): void;
  2863. /**
  2864. * @override
  2865. * Override Camera.createRigCamera
  2866. */
  2867. createRigCamera(name: string, cameraIndex: number): Camera;
  2868. /**
  2869. * @override
  2870. * Override Camera._updateRigCameras
  2871. */
  2872. _updateRigCameras(): void;
  2873. dispose(): void;
  2874. getClassName(): string;
  2875. }
  2876. }
  2877. declare module BABYLON {
  2878. class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  2879. constructor(camera: ArcRotateCamera);
  2880. addMouseWheel(): ArcRotateCameraInputsManager;
  2881. addPointers(): ArcRotateCameraInputsManager;
  2882. addKeyboard(): ArcRotateCameraInputsManager;
  2883. addGamepad(): ArcRotateCameraInputsManager;
  2884. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  2885. }
  2886. }
  2887. declare module BABYLON {
  2888. class Camera extends Node {
  2889. inputs: CameraInputsManager<Camera>;
  2890. private static _PERSPECTIVE_CAMERA;
  2891. private static _ORTHOGRAPHIC_CAMERA;
  2892. private static _FOVMODE_VERTICAL_FIXED;
  2893. private static _FOVMODE_HORIZONTAL_FIXED;
  2894. private static _RIG_MODE_NONE;
  2895. private static _RIG_MODE_STEREOSCOPIC_ANAGLYPH;
  2896. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL;
  2897. private static _RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED;
  2898. private static _RIG_MODE_STEREOSCOPIC_OVERUNDER;
  2899. private static _RIG_MODE_VR;
  2900. private static _RIG_MODE_WEBVR;
  2901. static readonly PERSPECTIVE_CAMERA: number;
  2902. static readonly ORTHOGRAPHIC_CAMERA: number;
  2903. /**
  2904. * This is the default FOV mode for perspective cameras.
  2905. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  2906. *
  2907. */
  2908. static readonly FOVMODE_VERTICAL_FIXED: number;
  2909. /**
  2910. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  2911. *
  2912. */
  2913. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  2914. static readonly RIG_MODE_NONE: number;
  2915. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  2916. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  2917. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  2918. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  2919. static readonly RIG_MODE_VR: number;
  2920. static readonly RIG_MODE_WEBVR: number;
  2921. static ForceAttachControlToAlwaysPreventDefault: boolean;
  2922. static UseAlternateWebVRRendering: boolean;
  2923. position: Vector3;
  2924. upVector: Vector3;
  2925. orthoLeft: Nullable<number>;
  2926. orthoRight: Nullable<number>;
  2927. orthoBottom: Nullable<number>;
  2928. orthoTop: Nullable<number>;
  2929. /**
  2930. * default : 0.8
  2931. * FOV is set in Radians.
  2932. */
  2933. fov: number;
  2934. minZ: number;
  2935. maxZ: number;
  2936. inertia: number;
  2937. mode: number;
  2938. isIntermediate: boolean;
  2939. viewport: Viewport;
  2940. /**
  2941. * Restricts the camera to viewing objects with the same layerMask.
  2942. * A camera with a layerMask of 1 will render meshes with no layerMask and meshes with a layerMask of 1.
  2943. */
  2944. layerMask: number;
  2945. /**
  2946. * default : FOVMODE_VERTICAL_FIXED
  2947. * fovMode sets the camera frustum bounds to the viewport bounds.
  2948. */
  2949. fovMode: number;
  2950. cameraRigMode: number;
  2951. interaxialDistance: number;
  2952. isStereoscopicSideBySide: boolean;
  2953. _cameraRigParams: any;
  2954. _rigCameras: Camera[];
  2955. _rigPostProcess: Nullable<PostProcess>;
  2956. protected _webvrViewMatrix: Matrix;
  2957. _skipRendering: boolean;
  2958. _alternateCamera: Camera;
  2959. customRenderTargets: RenderTargetTexture[];
  2960. onViewMatrixChangedObservable: Observable<Camera>;
  2961. onProjectionMatrixChangedObservable: Observable<Camera>;
  2962. onAfterCheckInputsObservable: Observable<Camera>;
  2963. onRestoreStateObservable: Observable<Camera>;
  2964. private _computedViewMatrix;
  2965. _projectionMatrix: Matrix;
  2966. private _doNotComputeProjectionMatrix;
  2967. private _worldMatrix;
  2968. _postProcesses: PostProcess[];
  2969. private _transformMatrix;
  2970. _activeMeshes: SmartArray<AbstractMesh>;
  2971. private _globalPosition;
  2972. private _frustumPlanes;
  2973. private _refreshFrustumPlanes;
  2974. constructor(name: string, position: Vector3, scene: Scene);
  2975. private _storedFov;
  2976. private _stateStored;
  2977. /**
  2978. * Store current camera state (fov, position, etc..)
  2979. */
  2980. storeState(): Camera;
  2981. /**
  2982. * Restores the camera state values if it has been stored. You must call storeState() first
  2983. */
  2984. protected _restoreStateValues(): boolean;
  2985. /**
  2986. * Restored camera state. You must call storeState() first
  2987. */
  2988. restoreState(): boolean;
  2989. getClassName(): string;
  2990. /**
  2991. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  2992. */
  2993. toString(fullDetails?: boolean): string;
  2994. readonly globalPosition: Vector3;
  2995. getActiveMeshes(): SmartArray<AbstractMesh>;
  2996. isActiveMesh(mesh: Mesh): boolean;
  2997. _initCache(): void;
  2998. _updateCache(ignoreParentClass?: boolean): void;
  2999. _isSynchronized(): boolean;
  3000. _isSynchronizedViewMatrix(): boolean;
  3001. _isSynchronizedProjectionMatrix(): boolean;
  3002. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3003. detachControl(element: HTMLElement): void;
  3004. update(): void;
  3005. _checkInputs(): void;
  3006. readonly rigCameras: Camera[];
  3007. readonly rigPostProcess: Nullable<PostProcess>;
  3008. private _cascadePostProcessesToRigCams();
  3009. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  3010. detachPostProcess(postProcess: PostProcess): void;
  3011. getWorldMatrix(): Matrix;
  3012. _getViewMatrix(): Matrix;
  3013. getViewMatrix(force?: boolean): Matrix;
  3014. freezeProjectionMatrix(projection?: Matrix): void;
  3015. unfreezeProjectionMatrix(): void;
  3016. getProjectionMatrix(force?: boolean): Matrix;
  3017. getTranformationMatrix(): Matrix;
  3018. private updateFrustumPlanes();
  3019. isInFrustum(target: ICullable): boolean;
  3020. isCompletelyInFrustum(target: ICullable): boolean;
  3021. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  3022. dispose(): void;
  3023. readonly leftCamera: Nullable<FreeCamera>;
  3024. readonly rightCamera: Nullable<FreeCamera>;
  3025. getLeftTarget(): Nullable<Vector3>;
  3026. getRightTarget(): Nullable<Vector3>;
  3027. setCameraRigMode(mode: number, rigParams: any): void;
  3028. private _getVRProjectionMatrix();
  3029. protected _updateCameraRotationMatrix(): void;
  3030. protected _updateWebVRCameraRotationMatrix(): void;
  3031. /**
  3032. * This function MUST be overwritten by the different WebVR cameras available.
  3033. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3034. */
  3035. protected _getWebVRProjectionMatrix(): Matrix;
  3036. /**
  3037. * This function MUST be overwritten by the different WebVR cameras available.
  3038. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  3039. */
  3040. protected _getWebVRViewMatrix(): Matrix;
  3041. setCameraRigParameter(name: string, value: any): void;
  3042. /**
  3043. * needs to be overridden by children so sub has required properties to be copied
  3044. */
  3045. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3046. /**
  3047. * May need to be overridden by children
  3048. */
  3049. _updateRigCameras(): void;
  3050. _setupInputs(): void;
  3051. serialize(): any;
  3052. clone(name: string): Camera;
  3053. getDirection(localAxis: Vector3): Vector3;
  3054. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  3055. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  3056. computeWorldMatrix(): Matrix;
  3057. static Parse(parsedCamera: any, scene: Scene): Camera;
  3058. }
  3059. }
  3060. declare module BABYLON {
  3061. var CameraInputTypes: {};
  3062. interface ICameraInput<TCamera extends Camera> {
  3063. camera: Nullable<TCamera>;
  3064. getClassName(): string;
  3065. getSimpleName(): string;
  3066. attachControl: (element: HTMLElement, noPreventDefault?: boolean) => void;
  3067. detachControl: (element: Nullable<HTMLElement>) => void;
  3068. checkInputs?: () => void;
  3069. }
  3070. interface CameraInputsMap<TCamera extends Camera> {
  3071. [name: string]: ICameraInput<TCamera>;
  3072. [idx: number]: ICameraInput<TCamera>;
  3073. }
  3074. class CameraInputsManager<TCamera extends Camera> {
  3075. attached: CameraInputsMap<TCamera>;
  3076. attachedElement: Nullable<HTMLElement>;
  3077. noPreventDefault: boolean;
  3078. camera: TCamera;
  3079. checkInputs: () => void;
  3080. constructor(camera: TCamera);
  3081. add(input: ICameraInput<TCamera>): void;
  3082. remove(inputToRemove: ICameraInput<TCamera>): void;
  3083. removeByType(inputType: string): void;
  3084. private _addCheckInputs(fn);
  3085. attachInput(input: ICameraInput<TCamera>): void;
  3086. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  3087. detachElement(element: HTMLElement, disconnect?: boolean): void;
  3088. rebuildInputCheck(): void;
  3089. clear(): void;
  3090. serialize(serializedCamera: any): void;
  3091. parse(parsedCamera: any): void;
  3092. }
  3093. }
  3094. declare module BABYLON {
  3095. /**
  3096. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  3097. * being tilted forward or back and left or right.
  3098. */
  3099. class DeviceOrientationCamera extends FreeCamera {
  3100. private _initialQuaternion;
  3101. private _quaternionCache;
  3102. /**
  3103. * Creates a new device orientation camera. @see DeviceOrientationCamera
  3104. * @param name The name of the camera
  3105. * @param position The starts position camera
  3106. * @param scene The scene the camera belongs to
  3107. */
  3108. constructor(name: string, position: Vector3, scene: Scene);
  3109. /**
  3110. * Gets the current instance class name ("DeviceOrientationCamera").
  3111. * This helps avoiding instanceof at run time.
  3112. * @returns the class name
  3113. */
  3114. getClassName(): string;
  3115. /**
  3116. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  3117. */
  3118. _checkInputs(): void;
  3119. /**
  3120. * Reset the camera to its default orientation on the specified axis only.
  3121. * @param axis The axis to reset
  3122. */
  3123. resetToCurrentRotation(axis?: Axis): void;
  3124. }
  3125. }
  3126. declare module BABYLON {
  3127. class FollowCamera extends TargetCamera {
  3128. radius: number;
  3129. rotationOffset: number;
  3130. heightOffset: number;
  3131. cameraAcceleration: number;
  3132. maxCameraSpeed: number;
  3133. lockedTarget: Nullable<AbstractMesh>;
  3134. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  3135. private getRadians(degrees);
  3136. private follow(cameraTarget);
  3137. _checkInputs(): void;
  3138. getClassName(): string;
  3139. }
  3140. class ArcFollowCamera extends TargetCamera {
  3141. alpha: number;
  3142. beta: number;
  3143. radius: number;
  3144. target: Nullable<AbstractMesh>;
  3145. private _cartesianCoordinates;
  3146. constructor(name: string, alpha: number, beta: number, radius: number, target: Nullable<AbstractMesh>, scene: Scene);
  3147. private follow();
  3148. _checkInputs(): void;
  3149. getClassName(): string;
  3150. }
  3151. }
  3152. declare module BABYLON {
  3153. class FreeCamera extends TargetCamera {
  3154. ellipsoid: Vector3;
  3155. ellipsoidOffset: Vector3;
  3156. checkCollisions: boolean;
  3157. applyGravity: boolean;
  3158. inputs: FreeCameraInputsManager;
  3159. angularSensibility: number;
  3160. keysUp: number[];
  3161. keysDown: number[];
  3162. keysLeft: number[];
  3163. keysRight: number[];
  3164. onCollide: (collidedMesh: AbstractMesh) => void;
  3165. private _collider;
  3166. private _needMoveForGravity;
  3167. private _oldPosition;
  3168. private _diffPosition;
  3169. private _newPosition;
  3170. _localDirection: Vector3;
  3171. _transformedDirection: Vector3;
  3172. constructor(name: string, position: Vector3, scene: Scene);
  3173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  3174. detachControl(element: HTMLElement): void;
  3175. private _collisionMask;
  3176. collisionMask: number;
  3177. _collideWithWorld(displacement: Vector3): void;
  3178. private _onCollisionPositionChange;
  3179. _checkInputs(): void;
  3180. _decideIfNeedsToMove(): boolean;
  3181. _updatePosition(): void;
  3182. dispose(): void;
  3183. getClassName(): string;
  3184. }
  3185. }
  3186. declare module BABYLON {
  3187. class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  3188. constructor(camera: FreeCamera);
  3189. addKeyboard(): FreeCameraInputsManager;
  3190. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  3191. addGamepad(): FreeCameraInputsManager;
  3192. addDeviceOrientation(): FreeCameraInputsManager;
  3193. addTouch(): FreeCameraInputsManager;
  3194. addVirtualJoystick(): FreeCameraInputsManager;
  3195. }
  3196. }
  3197. declare module BABYLON {
  3198. class GamepadCamera extends UniversalCamera {
  3199. gamepadAngularSensibility: number;
  3200. gamepadMoveSensibility: number;
  3201. constructor(name: string, position: Vector3, scene: Scene);
  3202. getClassName(): string;
  3203. }
  3204. }
  3205. declare module BABYLON {
  3206. class AnaglyphFreeCamera extends FreeCamera {
  3207. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3208. getClassName(): string;
  3209. }
  3210. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  3211. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  3212. getClassName(): string;
  3213. }
  3214. class AnaglyphGamepadCamera extends GamepadCamera {
  3215. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3216. getClassName(): string;
  3217. }
  3218. class AnaglyphUniversalCamera extends UniversalCamera {
  3219. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  3220. getClassName(): string;
  3221. }
  3222. class StereoscopicFreeCamera extends FreeCamera {
  3223. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3224. getClassName(): string;
  3225. }
  3226. class StereoscopicArcRotateCamera extends ArcRotateCamera {
  3227. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3228. getClassName(): string;
  3229. }
  3230. class StereoscopicGamepadCamera extends GamepadCamera {
  3231. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3232. getClassName(): string;
  3233. }
  3234. class StereoscopicUniversalCamera extends UniversalCamera {
  3235. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  3236. getClassName(): string;
  3237. }
  3238. }
  3239. declare module BABYLON {
  3240. class TargetCamera extends Camera {
  3241. cameraDirection: Vector3;
  3242. cameraRotation: Vector2;
  3243. rotation: Vector3;
  3244. rotationQuaternion: Quaternion;
  3245. speed: number;
  3246. noRotationConstraint: boolean;
  3247. lockedTarget: any;
  3248. _currentTarget: Vector3;
  3249. _viewMatrix: Matrix;
  3250. _camMatrix: Matrix;
  3251. _cameraTransformMatrix: Matrix;
  3252. _cameraRotationMatrix: Matrix;
  3253. private _rigCamTransformMatrix;
  3254. _referencePoint: Vector3;
  3255. private _currentUpVector;
  3256. _transformedReferencePoint: Vector3;
  3257. _lookAtTemp: Matrix;
  3258. _tempMatrix: Matrix;
  3259. _reset: () => void;
  3260. constructor(name: string, position: Vector3, scene: Scene);
  3261. getFrontPosition(distance: number): Vector3;
  3262. _getLockedTargetPosition(): Nullable<Vector3>;
  3263. /**
  3264. * Store current camera state (fov, position, etc..)
  3265. */
  3266. private _storedPosition;
  3267. private _storedRotation;
  3268. private _storedRotationQuaternion;
  3269. storeState(): Camera;
  3270. /**
  3271. * Restored camera state. You must call storeState() first
  3272. */
  3273. _restoreStateValues(): boolean;
  3274. _initCache(): void;
  3275. _updateCache(ignoreParentClass?: boolean): void;
  3276. _isSynchronizedViewMatrix(): boolean;
  3277. _computeLocalCameraSpeed(): number;
  3278. setTarget(target: Vector3): void;
  3279. /**
  3280. * Return the current target position of the camera. This value is expressed in local space.
  3281. */
  3282. getTarget(): Vector3;
  3283. _decideIfNeedsToMove(): boolean;
  3284. _updatePosition(): void;
  3285. _checkInputs(): void;
  3286. protected _updateCameraRotationMatrix(): void;
  3287. _getViewMatrix(): Matrix;
  3288. /**
  3289. * @override
  3290. * Override Camera.createRigCamera
  3291. */
  3292. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  3293. /**
  3294. * @override
  3295. * Override Camera._updateRigCameras
  3296. */
  3297. _updateRigCameras(): void;
  3298. private _getRigCamPosition(halfSpace, result);
  3299. getClassName(): string;
  3300. }
  3301. }
  3302. declare module BABYLON {
  3303. class TouchCamera extends FreeCamera {
  3304. touchAngularSensibility: number;
  3305. touchMoveSensibility: number;
  3306. constructor(name: string, position: Vector3, scene: Scene);
  3307. getClassName(): string;
  3308. _setupInputs(): void;
  3309. }
  3310. }
  3311. declare module BABYLON {
  3312. class UniversalCamera extends TouchCamera {
  3313. gamepadAngularSensibility: number;
  3314. gamepadMoveSensibility: number;
  3315. constructor(name: string, position: Vector3, scene: Scene);
  3316. getClassName(): string;
  3317. }
  3318. }
  3319. declare module BABYLON {
  3320. class VirtualJoysticksCamera extends FreeCamera {
  3321. constructor(name: string, position: Vector3, scene: Scene);
  3322. getClassName(): string;
  3323. }
  3324. }
  3325. declare module BABYLON {
  3326. class Collider {
  3327. /** Define if a collision was found */
  3328. collisionFound: boolean;
  3329. /**
  3330. * Define last intersection point in local space
  3331. */
  3332. intersectionPoint: Vector3;
  3333. /**
  3334. * Define last collided mesh
  3335. */
  3336. collidedMesh: Nullable<AbstractMesh>;
  3337. private _collisionPoint;
  3338. private _planeIntersectionPoint;
  3339. private _tempVector;
  3340. private _tempVector2;
  3341. private _tempVector3;
  3342. private _tempVector4;
  3343. private _edge;
  3344. private _baseToVertex;
  3345. private _destinationPoint;
  3346. private _slidePlaneNormal;
  3347. private _displacementVector;
  3348. _radius: Vector3;
  3349. _retry: number;
  3350. private _velocity;
  3351. private _basePoint;
  3352. private _epsilon;
  3353. _velocityWorldLength: number;
  3354. _basePointWorld: Vector3;
  3355. private _velocityWorld;
  3356. private _normalizedVelocity;
  3357. _initialVelocity: Vector3;
  3358. _initialPosition: Vector3;
  3359. private _nearestDistance;
  3360. private _collisionMask;
  3361. collisionMask: number;
  3362. /**
  3363. * Gets the plane normal used to compute the sliding response (in local space)
  3364. */
  3365. readonly slidePlaneNormal: Vector3;
  3366. _initialize(source: Vector3, dir: Vector3, e: number): void;
  3367. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  3368. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  3369. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  3370. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  3371. _getResponse(pos: Vector3, vel: Vector3): void;
  3372. }
  3373. }
  3374. declare module BABYLON {
  3375. var CollisionWorker: string;
  3376. interface ICollisionCoordinator {
  3377. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3378. init(scene: Scene): void;
  3379. destroy(): void;
  3380. onMeshAdded(mesh: AbstractMesh): void;
  3381. onMeshUpdated(mesh: AbstractMesh): void;
  3382. onMeshRemoved(mesh: AbstractMesh): void;
  3383. onGeometryAdded(geometry: Geometry): void;
  3384. onGeometryUpdated(geometry: Geometry): void;
  3385. onGeometryDeleted(geometry: Geometry): void;
  3386. }
  3387. interface SerializedMesh {
  3388. id: string;
  3389. name: string;
  3390. uniqueId: number;
  3391. geometryId: Nullable<string>;
  3392. sphereCenter: Array<number>;
  3393. sphereRadius: number;
  3394. boxMinimum: Array<number>;
  3395. boxMaximum: Array<number>;
  3396. worldMatrixFromCache: any;
  3397. subMeshes: Array<SerializedSubMesh>;
  3398. checkCollisions: boolean;
  3399. }
  3400. interface SerializedSubMesh {
  3401. position: number;
  3402. verticesStart: number;
  3403. verticesCount: number;
  3404. indexStart: number;
  3405. indexCount: number;
  3406. hasMaterial: boolean;
  3407. sphereCenter: Array<number>;
  3408. sphereRadius: number;
  3409. boxMinimum: Array<number>;
  3410. boxMaximum: Array<number>;
  3411. }
  3412. interface SerializedGeometry {
  3413. id: string;
  3414. positions: Float32Array;
  3415. indices: Uint32Array;
  3416. normals: Float32Array;
  3417. }
  3418. interface BabylonMessage {
  3419. taskType: WorkerTaskType;
  3420. payload: InitPayload | CollidePayload | UpdatePayload;
  3421. }
  3422. interface SerializedColliderToWorker {
  3423. position: Array<number>;
  3424. velocity: Array<number>;
  3425. radius: Array<number>;
  3426. }
  3427. enum WorkerTaskType {
  3428. INIT = 0,
  3429. UPDATE = 1,
  3430. COLLIDE = 2,
  3431. }
  3432. interface WorkerReply {
  3433. error: WorkerReplyType;
  3434. taskType: WorkerTaskType;
  3435. payload?: any;
  3436. }
  3437. interface CollisionReplyPayload {
  3438. newPosition: Array<number>;
  3439. collisionId: number;
  3440. collidedMeshUniqueId: number;
  3441. }
  3442. interface InitPayload {
  3443. }
  3444. interface CollidePayload {
  3445. collisionId: number;
  3446. collider: SerializedColliderToWorker;
  3447. maximumRetry: number;
  3448. excludedMeshUniqueId: Nullable<number>;
  3449. }
  3450. interface UpdatePayload {
  3451. updatedMeshes: {
  3452. [n: number]: SerializedMesh;
  3453. };
  3454. updatedGeometries: {
  3455. [s: string]: SerializedGeometry;
  3456. };
  3457. removedMeshes: Array<number>;
  3458. removedGeometries: Array<string>;
  3459. }
  3460. enum WorkerReplyType {
  3461. SUCCESS = 0,
  3462. UNKNOWN_ERROR = 1,
  3463. }
  3464. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  3465. private _scene;
  3466. private _scaledPosition;
  3467. private _scaledVelocity;
  3468. private _collisionsCallbackArray;
  3469. private _init;
  3470. private _runningUpdated;
  3471. private _worker;
  3472. private _addUpdateMeshesList;
  3473. private _addUpdateGeometriesList;
  3474. private _toRemoveMeshesArray;
  3475. private _toRemoveGeometryArray;
  3476. constructor();
  3477. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  3478. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  3479. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3480. init(scene: Scene): void;
  3481. destroy(): void;
  3482. onMeshAdded(mesh: AbstractMesh): void;
  3483. onMeshUpdated: (transformNode: TransformNode) => void;
  3484. onMeshRemoved(mesh: AbstractMesh): void;
  3485. onGeometryAdded(geometry: Geometry): void;
  3486. onGeometryUpdated: (geometry: Geometry) => void;
  3487. onGeometryDeleted(geometry: Geometry): void;
  3488. private _afterRender;
  3489. private _onMessageFromWorker;
  3490. }
  3491. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  3492. private _scene;
  3493. private _scaledPosition;
  3494. private _scaledVelocity;
  3495. private _finalPosition;
  3496. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  3497. init(scene: Scene): void;
  3498. destroy(): void;
  3499. onMeshAdded(mesh: AbstractMesh): void;
  3500. onMeshUpdated(mesh: AbstractMesh): void;
  3501. onMeshRemoved(mesh: AbstractMesh): void;
  3502. onGeometryAdded(geometry: Geometry): void;
  3503. onGeometryUpdated(geometry: Geometry): void;
  3504. onGeometryDeleted(geometry: Geometry): void;
  3505. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  3506. }
  3507. }
  3508. declare function importScripts(...urls: string[]): void;
  3509. declare module BABYLON {
  3510. var WorkerIncluded: boolean;
  3511. class CollisionCache {
  3512. private _meshes;
  3513. private _geometries;
  3514. getMeshes(): {
  3515. [n: number]: SerializedMesh;
  3516. };
  3517. getGeometries(): {
  3518. [s: number]: SerializedGeometry;
  3519. };
  3520. getMesh(id: any): SerializedMesh;
  3521. addMesh(mesh: SerializedMesh): void;
  3522. removeMesh(uniqueId: number): void;
  3523. getGeometry(id: string): SerializedGeometry;
  3524. addGeometry(geometry: SerializedGeometry): void;
  3525. removeGeometry(id: string): void;
  3526. }
  3527. class CollideWorker {
  3528. collider: Collider;
  3529. private _collisionCache;
  3530. private finalPosition;
  3531. private collisionsScalingMatrix;
  3532. private collisionTranformationMatrix;
  3533. constructor(collider: Collider, _collisionCache: CollisionCache, finalPosition: Vector3);
  3534. collideWithWorld(position: Vector3, velocity: Vector3, maximumRetry: number, excludedMeshUniqueId: Nullable<number>): void;
  3535. private checkCollision(mesh);
  3536. private processCollisionsForSubMeshes(transformMatrix, mesh);
  3537. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  3538. private checkSubmeshCollision(subMesh);
  3539. }
  3540. interface ICollisionDetector {
  3541. onInit(payload: InitPayload): void;
  3542. onUpdate(payload: UpdatePayload): void;
  3543. onCollision(payload: CollidePayload): void;
  3544. }
  3545. class CollisionDetectorTransferable implements ICollisionDetector {
  3546. private _collisionCache;
  3547. onInit(payload: InitPayload): void;
  3548. onUpdate(payload: UpdatePayload): void;
  3549. onCollision(payload: CollidePayload): void;
  3550. }
  3551. }
  3552. declare module BABYLON {
  3553. class IntersectionInfo {
  3554. bu: Nullable<number>;
  3555. bv: Nullable<number>;
  3556. distance: number;
  3557. faceId: number;
  3558. subMeshId: number;
  3559. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  3560. }
  3561. class PickingInfo {
  3562. hit: boolean;
  3563. distance: number;
  3564. pickedPoint: Nullable<Vector3>;
  3565. pickedMesh: Nullable<AbstractMesh>;
  3566. bu: number;
  3567. bv: number;
  3568. faceId: number;
  3569. subMeshId: number;
  3570. pickedSprite: Nullable<Sprite>;
  3571. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  3572. getTextureCoordinates(): Nullable<Vector2>;
  3573. }
  3574. }
  3575. declare module BABYLON {
  3576. class BoundingBox implements ICullable {
  3577. minimum: Vector3;
  3578. maximum: Vector3;
  3579. vectors: Vector3[];
  3580. center: Vector3;
  3581. centerWorld: Vector3;
  3582. extendSize: Vector3;
  3583. extendSizeWorld: Vector3;
  3584. directions: Vector3[];
  3585. vectorsWorld: Vector3[];
  3586. minimumWorld: Vector3;
  3587. maximumWorld: Vector3;
  3588. private _worldMatrix;
  3589. constructor(minimum: Vector3, maximum: Vector3);
  3590. getWorldMatrix(): Matrix;
  3591. setWorldMatrix(matrix: Matrix): BoundingBox;
  3592. _update(world: Matrix): void;
  3593. isInFrustum(frustumPlanes: Plane[]): boolean;
  3594. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3595. intersectsPoint(point: Vector3): boolean;
  3596. intersectsSphere(sphere: BoundingSphere): boolean;
  3597. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  3598. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  3599. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  3600. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3601. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  3602. }
  3603. }
  3604. declare module BABYLON {
  3605. interface ICullable {
  3606. isInFrustum(frustumPlanes: Plane[]): boolean;
  3607. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3608. }
  3609. class BoundingInfo implements ICullable {
  3610. minimum: Vector3;
  3611. maximum: Vector3;
  3612. boundingBox: BoundingBox;
  3613. boundingSphere: BoundingSphere;
  3614. private _isLocked;
  3615. constructor(minimum: Vector3, maximum: Vector3);
  3616. isLocked: boolean;
  3617. update(world: Matrix): void;
  3618. /**
  3619. * Recreate the bounding info to be centered around a specific point given a specific extend.
  3620. * @param center New center of the bounding info
  3621. * @param extend New extend of the bounding info
  3622. */
  3623. centerOn(center: Vector3, extend: Vector3): BoundingInfo;
  3624. isInFrustum(frustumPlanes: Plane[]): boolean;
  3625. /**
  3626. * Gets the world distance between the min and max points of the bounding box
  3627. */
  3628. readonly diagonalLength: number;
  3629. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  3630. _checkCollision(collider: Collider): boolean;
  3631. intersectsPoint(point: Vector3): boolean;
  3632. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  3633. }
  3634. }
  3635. declare module BABYLON {
  3636. class BoundingSphere {
  3637. minimum: Vector3;
  3638. maximum: Vector3;
  3639. center: Vector3;
  3640. radius: number;
  3641. centerWorld: Vector3;
  3642. radiusWorld: number;
  3643. private _tempRadiusVector;
  3644. constructor(minimum: Vector3, maximum: Vector3);
  3645. _update(world: Matrix): void;
  3646. isInFrustum(frustumPlanes: Plane[]): boolean;
  3647. intersectsPoint(point: Vector3): boolean;
  3648. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  3649. }
  3650. }
  3651. declare module BABYLON {
  3652. class Ray {
  3653. origin: Vector3;
  3654. direction: Vector3;
  3655. length: number;
  3656. private _edge1;
  3657. private _edge2;
  3658. private _pvec;
  3659. private _tvec;
  3660. private _qvec;
  3661. private _tmpRay;
  3662. constructor(origin: Vector3, direction: Vector3, length?: number);
  3663. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3664. intersectsBox(box: BoundingBox): boolean;
  3665. intersectsSphere(sphere: BoundingSphere): boolean;
  3666. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): Nullable<IntersectionInfo>;
  3667. intersectsPlane(plane: Plane): Nullable<number>;
  3668. intersectsMesh(mesh: AbstractMesh, fastCheck?: boolean): PickingInfo;
  3669. intersectsMeshes(meshes: Array<AbstractMesh>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  3670. private _comparePickingInfo(pickingInfoA, pickingInfoB);
  3671. private static smallnum;
  3672. private static rayl;
  3673. /**
  3674. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  3675. * @param sega the first point of the segment to test the intersection against
  3676. * @param segb the second point of the segment to test the intersection against
  3677. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  3678. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  3679. */
  3680. intersectionSegment(sega: Vector3, segb: Vector3, threshold: number): number;
  3681. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3682. static Zero(): Ray;
  3683. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3684. /**
  3685. * 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
  3686. * transformed to the given world matrix.
  3687. * @param origin The origin point
  3688. * @param end The end point
  3689. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3690. */
  3691. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3692. static Transform(ray: Ray, matrix: Matrix): Ray;
  3693. static TransformToRef(ray: Ray, matrix: Matrix, result: Ray): void;
  3694. }
  3695. }
  3696. declare module BABYLON {
  3697. class DebugLayer {
  3698. private _scene;
  3699. static InspectorURL: string;
  3700. private _inspector;
  3701. private BJSINSPECTOR;
  3702. constructor(scene: Scene);
  3703. /** Creates the inspector window. */
  3704. private _createInspector(config?);
  3705. isVisible(): boolean;
  3706. hide(): void;
  3707. show(config?: {
  3708. popup?: boolean;
  3709. initialTab?: number;
  3710. parentElement?: HTMLElement;
  3711. newColors?: {
  3712. backgroundColor?: string;
  3713. backgroundColorLighter?: string;
  3714. backgroundColorLighter2?: string;
  3715. backgroundColorLighter3?: string;
  3716. color?: string;
  3717. colorTop?: string;
  3718. colorBot?: string;
  3719. };
  3720. }): void;
  3721. }
  3722. }
  3723. declare module BABYLON {
  3724. class Debug {
  3725. static AxesViewer: {
  3726. new (scene: Scene, scaleLines?: number): {
  3727. _xline: Vector3[];
  3728. _yline: Vector3[];
  3729. _zline: Vector3[];
  3730. _xmesh: Nullable<LinesMesh>;
  3731. _ymesh: Nullable<LinesMesh>;
  3732. _zmesh: Nullable<LinesMesh>;
  3733. scene: Nullable<Scene>;
  3734. scaleLines: number;
  3735. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  3736. dispose(): void;
  3737. };
  3738. };
  3739. static BoneAxesViewer: {
  3740. new (scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number): {
  3741. mesh: Nullable<Mesh>;
  3742. bone: Nullable<Bone>;
  3743. pos: Vector3;
  3744. xaxis: Vector3;
  3745. yaxis: Vector3;
  3746. zaxis: Vector3;
  3747. update(): void;
  3748. dispose(): void;
  3749. _xline: Vector3[];
  3750. _yline: Vector3[];
  3751. _zline: Vector3[];
  3752. _xmesh: Nullable<LinesMesh>;
  3753. _ymesh: Nullable<LinesMesh>;
  3754. _zmesh: Nullable<LinesMesh>;
  3755. scene: Nullable<Scene>;
  3756. scaleLines: number;
  3757. };
  3758. };
  3759. static PhysicsViewer: {
  3760. new (scene: Scene): {
  3761. _impostors: Nullable<PhysicsImpostor>[];
  3762. _meshes: Nullable<AbstractMesh>[];
  3763. _scene: Nullable<Scene>;
  3764. _numMeshes: number;
  3765. _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  3766. _renderFunction: () => void;
  3767. _debugBoxMesh: Mesh;
  3768. _debugSphereMesh: Mesh;
  3769. _debugMaterial: StandardMaterial;
  3770. _updateDebugMeshes(): void;
  3771. showImpostor(impostor: PhysicsImpostor): void;
  3772. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  3773. _getDebugMaterial(scene: Scene): Material;
  3774. _getDebugBoxMesh(scene: Scene): AbstractMesh;
  3775. _getDebugSphereMesh(scene: Scene): AbstractMesh;
  3776. _getDebugMesh(impostor: PhysicsImpostor, scene: Scene): Nullable<AbstractMesh>;
  3777. dispose(): void;
  3778. };
  3779. };
  3780. static SkeletonViewer: {
  3781. new (skeleton: Skeleton, mesh: AbstractMesh, scene: Scene, autoUpdateBonesMatrices?: boolean, renderingGroupId?: number): {
  3782. color: Color3;
  3783. _scene: Scene;
  3784. _debugLines: Vector3[][];
  3785. _debugMesh: Nullable<LinesMesh>;
  3786. _isEnabled: boolean;
  3787. _renderFunction: () => void;
  3788. skeleton: Skeleton;
  3789. mesh: AbstractMesh;
  3790. autoUpdateBonesMatrices: boolean;
  3791. renderingGroupId: number;
  3792. isEnabled: boolean;
  3793. _getBonePosition(position: Vector3, bone: Bone, meshMat: Matrix, x?: number, y?: number, z?: number): void;
  3794. _getLinesForBonesWithLength(bones: Bone[], meshMat: Matrix): void;
  3795. _getLinesForBonesNoLength(bones: Bone[], meshMat: Matrix): void;
  3796. update(): void;
  3797. dispose(): void;
  3798. };
  3799. };
  3800. }
  3801. }
  3802. declare module BABYLON {
  3803. class RayHelper {
  3804. ray: Nullable<Ray>;
  3805. private _renderPoints;
  3806. private _renderLine;
  3807. private _renderFunction;
  3808. private _scene;
  3809. private _updateToMeshFunction;
  3810. private _attachedToMesh;
  3811. private _meshSpaceDirection;
  3812. private _meshSpaceOrigin;
  3813. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  3814. constructor(ray: Ray);
  3815. show(scene: Scene, color: Color3): void;
  3816. hide(): void;
  3817. private _render();
  3818. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  3819. detachFromMesh(): void;
  3820. private _updateToMesh();
  3821. dispose(): void;
  3822. }
  3823. }
  3824. declare module BABYLON {
  3825. class InstancingAttributeInfo {
  3826. /**
  3827. * Index/offset of the attribute in the vertex shader
  3828. */
  3829. index: number;
  3830. /**
  3831. * size of the attribute, 1, 2, 3 or 4
  3832. */
  3833. attributeSize: number;
  3834. /**
  3835. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  3836. * default is FLOAT
  3837. */
  3838. attribyteType: number;
  3839. /**
  3840. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  3841. */
  3842. normalized: boolean;
  3843. /**
  3844. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  3845. */
  3846. offset: number;
  3847. /**
  3848. * Name of the GLSL attribute, for debugging purpose only
  3849. */
  3850. attributeName: string;
  3851. }
  3852. /**
  3853. * Define options used to create a render target texture
  3854. */
  3855. class RenderTargetCreationOptions {
  3856. generateMipMaps?: boolean;
  3857. generateDepthBuffer?: boolean;
  3858. generateStencilBuffer?: boolean;
  3859. type?: number;
  3860. samplingMode?: number;
  3861. }
  3862. /**
  3863. * Regroup several parameters relative to the browser in use
  3864. */
  3865. class EngineCapabilities {
  3866. /** The maximum textures image */
  3867. maxTexturesImageUnits: number;
  3868. maxVertexTextureImageUnits: number;
  3869. maxCombinedTexturesImageUnits: number;
  3870. /** The maximum texture size */
  3871. maxTextureSize: number;
  3872. maxCubemapTextureSize: number;
  3873. maxRenderTextureSize: number;
  3874. maxVertexAttribs: number;
  3875. maxVaryingVectors: number;
  3876. maxVertexUniformVectors: number;
  3877. maxFragmentUniformVectors: number;
  3878. standardDerivatives: boolean;
  3879. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  3880. pvrtc: any;
  3881. etc1: any;
  3882. etc2: any;
  3883. astc: any;
  3884. textureFloat: boolean;
  3885. vertexArrayObject: boolean;
  3886. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  3887. maxAnisotropy: number;
  3888. instancedArrays: boolean;
  3889. uintIndices: boolean;
  3890. highPrecisionShaderSupported: boolean;
  3891. fragmentDepthSupported: boolean;
  3892. textureFloatLinearFiltering: boolean;
  3893. textureFloatRender: boolean;
  3894. textureHalfFloat: boolean;
  3895. textureHalfFloatLinearFiltering: boolean;
  3896. textureHalfFloatRender: boolean;
  3897. textureLOD: boolean;
  3898. drawBuffersExtension: boolean;
  3899. depthTextureExtension: boolean;
  3900. colorBufferFloat: boolean;
  3901. timerQuery: EXT_disjoint_timer_query;
  3902. canUseTimestampForTimerQuery: boolean;
  3903. }
  3904. interface EngineOptions extends WebGLContextAttributes {
  3905. limitDeviceRatio?: number;
  3906. autoEnableWebVR?: boolean;
  3907. disableWebGL2Support?: boolean;
  3908. audioEngine?: boolean;
  3909. deterministicLockstep?: boolean;
  3910. lockstepMaxSteps?: number;
  3911. doNotHandleContextLost?: boolean;
  3912. }
  3913. interface IDisplayChangedEventArgs {
  3914. vrDisplay: any;
  3915. vrSupported: boolean;
  3916. }
  3917. /**
  3918. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  3919. */
  3920. class Engine {
  3921. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  3922. static ExceptionList: ({
  3923. key: string;
  3924. capture: string;
  3925. captureConstraint: number;
  3926. targets: string[];
  3927. } | {
  3928. key: string;
  3929. capture: null;
  3930. captureConstraint: null;
  3931. targets: string[];
  3932. })[];
  3933. static Instances: Engine[];
  3934. static readonly LastCreatedEngine: Nullable<Engine>;
  3935. static readonly LastCreatedScene: Nullable<Scene>;
  3936. /**
  3937. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  3938. */
  3939. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  3940. private static _ALPHA_DISABLE;
  3941. private static _ALPHA_ADD;
  3942. private static _ALPHA_COMBINE;
  3943. private static _ALPHA_SUBTRACT;
  3944. private static _ALPHA_MULTIPLY;
  3945. private static _ALPHA_MAXIMIZED;
  3946. private static _ALPHA_ONEONE;
  3947. private static _ALPHA_PREMULTIPLIED;
  3948. private static _ALPHA_PREMULTIPLIED_PORTERDUFF;
  3949. private static _ALPHA_INTERPOLATE;
  3950. private static _ALPHA_SCREENMODE;
  3951. private static _DELAYLOADSTATE_NONE;
  3952. private static _DELAYLOADSTATE_LOADED;
  3953. private static _DELAYLOADSTATE_LOADING;
  3954. private static _DELAYLOADSTATE_NOTLOADED;
  3955. private static _TEXTUREFORMAT_ALPHA;
  3956. private static _TEXTUREFORMAT_LUMINANCE;
  3957. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  3958. private static _TEXTUREFORMAT_RGB;
  3959. private static _TEXTUREFORMAT_RGBA;
  3960. private static _TEXTURETYPE_UNSIGNED_INT;
  3961. private static _TEXTURETYPE_FLOAT;
  3962. private static _TEXTURETYPE_HALF_FLOAT;
  3963. private static _NEVER;
  3964. private static _ALWAYS;
  3965. private static _LESS;
  3966. private static _EQUAL;
  3967. private static _LEQUAL;
  3968. private static _GREATER;
  3969. private static _GEQUAL;
  3970. private static _NOTEQUAL;
  3971. static readonly NEVER: number;
  3972. static readonly ALWAYS: number;
  3973. static readonly LESS: number;
  3974. static readonly EQUAL: number;
  3975. static readonly LEQUAL: number;
  3976. static readonly GREATER: number;
  3977. static readonly GEQUAL: number;
  3978. static readonly NOTEQUAL: number;
  3979. private static _KEEP;
  3980. private static _REPLACE;
  3981. private static _INCR;
  3982. private static _DECR;
  3983. private static _INVERT;
  3984. private static _INCR_WRAP;
  3985. private static _DECR_WRAP;
  3986. static readonly KEEP: number;
  3987. static readonly REPLACE: number;
  3988. static readonly INCR: number;
  3989. static readonly DECR: number;
  3990. static readonly INVERT: number;
  3991. static readonly INCR_WRAP: number;
  3992. static readonly DECR_WRAP: number;
  3993. static readonly ALPHA_DISABLE: number;
  3994. static readonly ALPHA_ONEONE: number;
  3995. static readonly ALPHA_ADD: number;
  3996. static readonly ALPHA_COMBINE: number;
  3997. static readonly ALPHA_SUBTRACT: number;
  3998. static readonly ALPHA_MULTIPLY: number;
  3999. static readonly ALPHA_MAXIMIZED: number;
  4000. static readonly ALPHA_PREMULTIPLIED: number;
  4001. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4002. static readonly ALPHA_INTERPOLATE: number;
  4003. static readonly ALPHA_SCREENMODE: number;
  4004. static readonly DELAYLOADSTATE_NONE: number;
  4005. static readonly DELAYLOADSTATE_LOADED: number;
  4006. static readonly DELAYLOADSTATE_LOADING: number;
  4007. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4008. static readonly TEXTUREFORMAT_ALPHA: number;
  4009. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4010. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4011. static readonly TEXTUREFORMAT_RGB: number;
  4012. static readonly TEXTUREFORMAT_RGBA: number;
  4013. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4014. static readonly TEXTURETYPE_FLOAT: number;
  4015. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4016. private static _SCALEMODE_FLOOR;
  4017. private static _SCALEMODE_NEAREST;
  4018. private static _SCALEMODE_CEILING;
  4019. static readonly SCALEMODE_FLOOR: number;
  4020. static readonly SCALEMODE_NEAREST: number;
  4021. static readonly SCALEMODE_CEILING: number;
  4022. static readonly Version: string;
  4023. static CollisionsEpsilon: number;
  4024. static CodeRepository: string;
  4025. static ShadersRepository: string;
  4026. forcePOTTextures: boolean;
  4027. isFullscreen: boolean;
  4028. isPointerLock: boolean;
  4029. cullBackFaces: boolean;
  4030. renderEvenInBackground: boolean;
  4031. preventCacheWipeBetweenFrames: boolean;
  4032. enableOfflineSupport: boolean;
  4033. scenes: Scene[];
  4034. postProcesses: PostProcess[];
  4035. /**
  4036. * Observable event triggered each time the rendering canvas is resized
  4037. */
  4038. onResizeObservable: Observable<Engine>;
  4039. /**
  4040. * Observable event triggered each time the canvas loses focus
  4041. */
  4042. onCanvasBlurObservable: Observable<Engine>;
  4043. /**
  4044. * Observable event triggered each time the canvas gains focus
  4045. */
  4046. onCanvasFocusObservable: Observable<Engine>;
  4047. /**
  4048. * Observable event triggered each time the canvas receives pointerout event
  4049. */
  4050. onCanvasPointerOutObservable: Observable<Engine>;
  4051. /**
  4052. * Observable event triggered before each texture is initialized
  4053. */
  4054. onBeforeTextureInitObservable: Observable<Texture>;
  4055. private _vrDisplay;
  4056. private _vrSupported;
  4057. private _oldSize;
  4058. private _oldHardwareScaleFactor;
  4059. private _vrExclusivePointerMode;
  4060. readonly isInVRExclusivePointerMode: boolean;
  4061. disableUniformBuffers: boolean;
  4062. _uniformBuffers: UniformBuffer[];
  4063. readonly supportsUniformBuffers: boolean;
  4064. /**
  4065. * Observable raised when the engine begins a new frame
  4066. */
  4067. onBeginFrameObservable: Observable<Engine>;
  4068. /**
  4069. * Observable raised when the engine ends the current frame
  4070. */
  4071. onEndFrameObservable: Observable<Engine>;
  4072. /**
  4073. * Observable raised when the engine is about to compile a shader
  4074. */
  4075. onBeforeShaderCompilationObservable: Observable<Engine>;
  4076. /**
  4077. * Observable raised when the engine has jsut compiled a shader
  4078. */
  4079. onAfterShaderCompilationObservable: Observable<Engine>;
  4080. private _gl;
  4081. private _renderingCanvas;
  4082. private _windowIsBackground;
  4083. private _webGLVersion;
  4084. readonly needPOTTextures: boolean;
  4085. private _badOS;
  4086. readonly badOS: boolean;
  4087. private _badDesktopOS;
  4088. readonly badDesktopOS: boolean;
  4089. /**
  4090. * Gets or sets a value indicating if we want to disable texture binding optmization.
  4091. * This could be required on some buggy drivers which wants to have textures bound in a progressive order
  4092. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is.
  4093. */
  4094. disableTextureBindingOptimization: boolean;
  4095. static audioEngine: AudioEngine;
  4096. private _onFocus;
  4097. private _onBlur;
  4098. private _onCanvasPointerOut;
  4099. private _onCanvasBlur;
  4100. private _onCanvasFocus;
  4101. private _onFullscreenChange;
  4102. private _onPointerLockChange;
  4103. private _onVRDisplayPointerRestricted;
  4104. private _onVRDisplayPointerUnrestricted;
  4105. private _onVrDisplayConnect;
  4106. private _onVrDisplayDisconnect;
  4107. private _onVrDisplayPresentChange;
  4108. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  4109. onVRRequestPresentComplete: Observable<boolean>;
  4110. onVRRequestPresentStart: Observable<Engine>;
  4111. private _hardwareScalingLevel;
  4112. protected _caps: EngineCapabilities;
  4113. private _pointerLockRequested;
  4114. private _isStencilEnable;
  4115. private _colorWrite;
  4116. private _loadingScreen;
  4117. _drawCalls: PerfCounter;
  4118. _textureCollisions: PerfCounter;
  4119. private _glVersion;
  4120. private _glRenderer;
  4121. private _glVendor;
  4122. private _videoTextureSupported;
  4123. private _renderingQueueLaunched;
  4124. private _activeRenderLoops;
  4125. private _deterministicLockstep;
  4126. private _lockstepMaxSteps;
  4127. onContextLostObservable: Observable<Engine>;
  4128. onContextRestoredObservable: Observable<Engine>;
  4129. private _onContextLost;
  4130. private _onContextRestored;
  4131. private _contextWasLost;
  4132. private _doNotHandleContextLost;
  4133. private _performanceMonitor;
  4134. private _fps;
  4135. private _deltaTime;
  4136. /**
  4137. * Turn this value on if you want to pause FPS computation when in background
  4138. */
  4139. disablePerformanceMonitorInBackground: boolean;
  4140. readonly performanceMonitor: PerformanceMonitor;
  4141. protected _depthCullingState: _DepthCullingState;
  4142. protected _stencilState: _StencilState;
  4143. protected _alphaState: _AlphaState;
  4144. protected _alphaMode: number;
  4145. private _internalTexturesCache;
  4146. protected _activeChannel: number;
  4147. private _currentTextureChannel;
  4148. protected _boundTexturesCache: {
  4149. [key: string]: Nullable<InternalTexture>;
  4150. };
  4151. protected _currentEffect: Nullable<Effect>;
  4152. protected _currentProgram: Nullable<WebGLProgram>;
  4153. private _compiledEffects;
  4154. private _vertexAttribArraysEnabled;
  4155. protected _cachedViewport: Nullable<Viewport>;
  4156. private _cachedVertexArrayObject;
  4157. protected _cachedVertexBuffers: any;
  4158. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  4159. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  4160. protected _currentRenderTarget: Nullable<InternalTexture>;
  4161. private _uintIndicesCurrentlySet;
  4162. private _currentBoundBuffer;
  4163. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  4164. private _currentBufferPointers;
  4165. private _currentInstanceLocations;
  4166. private _currentInstanceBuffers;
  4167. private _textureUnits;
  4168. private _firstBoundInternalTextureTracker;
  4169. private _lastBoundInternalTextureTracker;
  4170. private _workingCanvas;
  4171. private _workingContext;
  4172. private _rescalePostProcess;
  4173. private _dummyFramebuffer;
  4174. private _externalData;
  4175. private _bindedRenderFunction;
  4176. private _vaoRecordInProgress;
  4177. private _mustWipeVertexAttributes;
  4178. private _emptyTexture;
  4179. private _emptyCubeTexture;
  4180. private _emptyTexture3D;
  4181. private _frameHandler;
  4182. private _nextFreeTextureSlots;
  4183. private _maxSimultaneousTextures;
  4184. private _activeRequests;
  4185. private _texturesSupported;
  4186. private _textureFormatInUse;
  4187. readonly texturesSupported: Array<string>;
  4188. readonly textureFormatInUse: Nullable<string>;
  4189. readonly currentViewport: Nullable<Viewport>;
  4190. readonly emptyTexture: InternalTexture;
  4191. readonly emptyTexture3D: InternalTexture;
  4192. readonly emptyCubeTexture: InternalTexture;
  4193. /**
  4194. * @constructor
  4195. * @param canvasOrContext defines the canvas or WebGL context to use for rendering
  4196. * @param antialias defines enable antialiasing (default: false)
  4197. * @param options defines further options to be sent to the getContext() function
  4198. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  4199. */
  4200. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  4201. private _rebuildInternalTextures();
  4202. private _rebuildEffects();
  4203. private _rebuildBuffers();
  4204. private _initGLContext();
  4205. readonly webGLVersion: number;
  4206. /**
  4207. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  4208. */
  4209. readonly isStencilEnable: boolean;
  4210. private _prepareWorkingCanvas();
  4211. resetTextureCache(): void;
  4212. isDeterministicLockStep(): boolean;
  4213. getLockstepMaxSteps(): number;
  4214. getGlInfo(): {
  4215. vendor: string;
  4216. renderer: string;
  4217. version: string;
  4218. };
  4219. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  4220. getRenderWidth(useScreen?: boolean): number;
  4221. getRenderHeight(useScreen?: boolean): number;
  4222. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  4223. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  4224. setHardwareScalingLevel(level: number): void;
  4225. getHardwareScalingLevel(): number;
  4226. getLoadedTexturesCache(): InternalTexture[];
  4227. getCaps(): EngineCapabilities;
  4228. /** The number of draw calls submitted last frame */
  4229. readonly drawCalls: number;
  4230. readonly drawCallsPerfCounter: Nullable<PerfCounter>;
  4231. getDepthFunction(): Nullable<number>;
  4232. setDepthFunction(depthFunc: number): void;
  4233. setDepthFunctionToGreater(): void;
  4234. setDepthFunctionToGreaterOrEqual(): void;
  4235. setDepthFunctionToLess(): void;
  4236. setDepthFunctionToLessOrEqual(): void;
  4237. getStencilBuffer(): boolean;
  4238. setStencilBuffer(enable: boolean): void;
  4239. getStencilMask(): number;
  4240. setStencilMask(mask: number): void;
  4241. getStencilFunction(): number;
  4242. getStencilFunctionReference(): number;
  4243. getStencilFunctionMask(): number;
  4244. setStencilFunction(stencilFunc: number): void;
  4245. setStencilFunctionReference(reference: number): void;
  4246. setStencilFunctionMask(mask: number): void;
  4247. getStencilOperationFail(): number;
  4248. getStencilOperationDepthFail(): number;
  4249. getStencilOperationPass(): number;
  4250. setStencilOperationFail(operation: number): void;
  4251. setStencilOperationDepthFail(operation: number): void;
  4252. setStencilOperationPass(operation: number): void;
  4253. setDitheringState(value: boolean): void;
  4254. setRasterizerState(value: boolean): void;
  4255. /**
  4256. * stop executing a render loop function and remove it from the execution array
  4257. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  4258. */
  4259. stopRenderLoop(renderFunction?: () => void): void;
  4260. _renderLoop(): void;
  4261. /**
  4262. * Register and execute a render loop. The engine can have more than one render function.
  4263. * @param {Function} renderFunction - the function to continuously execute starting the next render loop.
  4264. * @example
  4265. * engine.runRenderLoop(function () {
  4266. * scene.render()
  4267. * })
  4268. */
  4269. runRenderLoop(renderFunction: () => void): void;
  4270. /**
  4271. * Toggle full screen mode.
  4272. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  4273. * @param {any} options - an options object to be sent to the requestFullscreen function
  4274. */
  4275. switchFullscreen(requestPointerLock: boolean): void;
  4276. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4277. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  4278. /**
  4279. * Set the WebGL's viewport
  4280. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  4281. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  4282. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  4283. */
  4284. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4285. /**
  4286. * Directly set the WebGL Viewport
  4287. * The x, y, width & height are directly passed to the WebGL call
  4288. * @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.
  4289. */
  4290. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  4291. beginFrame(): void;
  4292. endFrame(): void;
  4293. /**
  4294. * resize the view according to the canvas' size.
  4295. * @example
  4296. * window.addEventListener("resize", function () {
  4297. * engine.resize();
  4298. * });
  4299. */
  4300. resize(): void;
  4301. /**
  4302. * force a specific size of the canvas
  4303. * @param {number} width - the new canvas' width
  4304. * @param {number} height - the new canvas' height
  4305. */
  4306. setSize(width: number, height: number): void;
  4307. isVRDevicePresent(): boolean;
  4308. getVRDevice(): any;
  4309. initWebVR(): Observable<{
  4310. vrDisplay: any;
  4311. vrSupported: any;
  4312. }>;
  4313. enableVR(): void;
  4314. disableVR(): void;
  4315. private _onVRFullScreenTriggered;
  4316. private _getVRDisplays(callback);
  4317. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  4318. private bindUnboundFramebuffer(framebuffer);
  4319. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4320. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4321. generateMipMapsForCubemap(texture: InternalTexture): void;
  4322. flushFramebuffer(): void;
  4323. restoreDefaultFramebuffer(): void;
  4324. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  4325. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  4326. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  4327. private _resetVertexBufferBinding();
  4328. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4329. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4330. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4331. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4332. private _resetIndexBufferBinding();
  4333. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  4334. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  4335. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  4336. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  4337. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  4338. private bindIndexBuffer(buffer);
  4339. private bindBuffer(buffer, target);
  4340. updateArrayBuffer(data: Float32Array): void;
  4341. private vertexAttribPointer(buffer, indx, size, type, normalized, stride, offset);
  4342. private _bindIndexBufferWithCache(indexBuffer);
  4343. private _bindVertexBuffersAttributes(vertexBuffers, effect);
  4344. recordVertexArrayObject(vertexBuffers: {
  4345. [key: string]: VertexBuffer;
  4346. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  4347. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  4348. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  4349. private _unbindVertexArrayObject();
  4350. bindBuffers(vertexBuffers: {
  4351. [key: string]: Nullable<VertexBuffer>;
  4352. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  4353. unbindInstanceAttributes(): void;
  4354. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  4355. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4356. createInstancesBuffer(capacity: number): WebGLBuffer;
  4357. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  4358. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  4359. applyStates(): void;
  4360. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4361. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4362. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4363. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4364. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4365. private DrawMode(fillMode);
  4366. _releaseEffect(effect: Effect): void;
  4367. _deleteProgram(program: WebGLProgram): void;
  4368. /**
  4369. * @param baseName The base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  4370. * @param samplers An array of string used to represent textures
  4371. */
  4372. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, indexParameters?: any): Effect;
  4373. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  4374. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4375. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  4376. private _createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings?);
  4377. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  4378. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4379. enableEffect(effect: Nullable<Effect>): void;
  4380. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4381. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4382. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4383. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  4384. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4385. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4386. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4387. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  4388. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4389. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4390. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4391. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  4392. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  4393. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  4394. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4395. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  4396. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4397. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  4398. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  4399. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  4400. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  4401. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  4402. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  4403. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  4404. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4405. setZOffset(value: number): void;
  4406. getZOffset(): number;
  4407. setDepthBuffer(enable: boolean): void;
  4408. getDepthWrite(): boolean;
  4409. setDepthWrite(enable: boolean): void;
  4410. setColorWrite(enable: boolean): void;
  4411. getColorWrite(): boolean;
  4412. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  4413. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4414. getAlphaMode(): number;
  4415. wipeCaches(bruteForce?: boolean): void;
  4416. /**
  4417. * Set the compressed texture format to use, based on the formats you have, and the formats
  4418. * supported by the hardware / browser.
  4419. *
  4420. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  4421. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  4422. * to API arguments needed to compressed textures. This puts the burden on the container
  4423. * generator to house the arcane code for determining these for current & future formats.
  4424. *
  4425. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  4426. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  4427. *
  4428. * Note: The result of this call is not taken into account when a texture is base64.
  4429. *
  4430. * @param {Array<string>} formatsAvailable- The list of those format families you have created
  4431. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  4432. *
  4433. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  4434. * @returns The extension selected.
  4435. */
  4436. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  4437. _createTexture(): WebGLTexture;
  4438. /**
  4439. * Usually called from BABYLON.Texture.ts. Passed information to create a WebGLTexture.
  4440. * @param {string} urlArg- This contains one of the following:
  4441. * 1. A conventional http URL, e.g. 'http://...' or 'file://...'
  4442. * 2. A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  4443. * 3. An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  4444. *
  4445. * @param {boolean} noMipmap- When true, no mipmaps shall be generated. Ignored for compressed textures. They must be in the file.
  4446. * @param {boolean} invertY- When true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file.
  4447. * @param {Scene} scene- Needed for loading to the correct scene.
  4448. * @param {number} samplingMode- Mode with should be used sample / access the texture. Default: TRILINEAR
  4449. * @param {callback} onLoad- Optional callback to be called upon successful completion.
  4450. * @param {callback} onError- Optional callback to be called upon failure.
  4451. * @param {ArrayBuffer | HTMLImageElement} buffer- A source of a file previously fetched as either an ArrayBuffer (compressed or image format) or HTMLImageElement (image format)
  4452. * @param {WebGLTexture} fallback- An internal argument in case the function must be called again, due to etc1 not having alpha capabilities.
  4453. * @param {number} format- Internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures.
  4454. *
  4455. * @returns {WebGLTexture} for assignment back into BABYLON.Texture
  4456. */
  4457. 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<ArrayBuffer | HTMLImageElement>, fallBack?: Nullable<InternalTexture>, format?: Nullable<number>): InternalTexture;
  4458. private _rescaleTexture(source, destination, scene, internalFormat, onComplete);
  4459. private _getInternalFormat(format);
  4460. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>, type?: number): void;
  4461. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  4462. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  4463. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4464. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  4465. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  4466. createRenderTargetTexture(size: number | {
  4467. width: number;
  4468. height: number;
  4469. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4470. createMultipleRenderTarget(size: any, options: any): InternalTexture[];
  4471. private _setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height, samples?);
  4472. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  4473. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  4474. _uploadDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, format: number, type: number, data: ArrayBufferView): void;
  4475. _uploadCompressedDataToTexture(target: number, lod: number, internalFormat: number, width: number, height: number, data: ArrayBufferView): void;
  4476. createRenderTargetCubeTexture(size: number, options?: RenderTargetCreationOptions): InternalTexture;
  4477. createPrefilteredCubeTexture(rootUrl: string, scene: Nullable<Scene>, scale: number, offset: number, onLoad?: Nullable<(internalTexture: Nullable<InternalTexture>) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  4478. createCubeTexture(rootUrl: string, scene: Nullable<Scene>, files: Nullable<string[]>, noMipmap?: boolean, onLoad?: Nullable<(data?: any) => void>, onError?: Nullable<(message?: string, exception?: any) => void>, format?: number, forcedExtension?: any): InternalTexture;
  4479. private setCubeMapTextureParams(gl, loadMipmap);
  4480. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>, level?: number): void;
  4481. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4482. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, samplingMode?: number, invertY?: boolean): InternalTexture;
  4483. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression?: Nullable<string>): void;
  4484. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  4485. private _prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  4486. private _prepareWebGLTexture(texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode?);
  4487. private _convertRGBtoRGBATextureData(rgbData, width, height, textureType);
  4488. _releaseFramebufferObjects(texture: InternalTexture): void;
  4489. _releaseTexture(texture: InternalTexture): void;
  4490. private setProgram(program);
  4491. private _boundUniforms;
  4492. bindSamplers(effect: Effect): void;
  4493. private _moveBoundTextureOnTop(internalTexture);
  4494. private _getCorrectTextureChannel(channel, internalTexture);
  4495. private _linkTrackers(previous, next);
  4496. private _removeDesignatedSlot(internalTexture);
  4497. private _activateCurrentTexture();
  4498. protected _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean): void;
  4499. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  4500. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  4501. unbindAllTextures(): void;
  4502. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  4503. private _bindSamplerUniformToChannel(sourceSlot, destination);
  4504. private _setTexture(channel, texture, isPartOfTextureArray?);
  4505. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  4506. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  4507. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  4508. /**
  4509. * Add an externaly attached data from its key.
  4510. * This method call will fail and return false, if such key already exists.
  4511. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  4512. * @param key the unique key that identifies the data
  4513. * @param data the data object to associate to the key for this Engine instance
  4514. * @return true if no such key were already present and the data was added successfully, false otherwise
  4515. */
  4516. addExternalData<T>(key: string, data: T): boolean;
  4517. /**
  4518. * Get an externaly attached data from its key
  4519. * @param key the unique key that identifies the data
  4520. * @return the associated data, if present (can be null), or undefined if not present
  4521. */
  4522. getExternalData<T>(key: string): T;
  4523. /**
  4524. * Get an externaly attached data from its key, create it using a factory if it's not already present
  4525. * @param key the unique key that identifies the data
  4526. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  4527. * @return the associated data, can be null if the factory returned null.
  4528. */
  4529. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  4530. /**
  4531. * Remove an externaly attached data from the Engine instance
  4532. * @param key the unique key that identifies the data
  4533. * @return true if the data was successfully removed, false if it doesn't exist
  4534. */
  4535. removeExternalData(key: string): boolean;
  4536. unbindAllAttributes(): void;
  4537. releaseEffects(): void;
  4538. dispose(): void;
  4539. displayLoadingUI(): void;
  4540. hideLoadingUI(): void;
  4541. loadingScreen: ILoadingScreen;
  4542. loadingUIText: string;
  4543. loadingUIBackgroundColor: string;
  4544. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4545. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  4546. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  4547. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  4548. getError(): number;
  4549. getFps(): number;
  4550. getDeltaTime(): number;
  4551. private _measureFps();
  4552. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number): ArrayBufferView;
  4553. private _canRenderToFloatFramebuffer();
  4554. private _canRenderToHalfFloatFramebuffer();
  4555. private _canRenderToFramebuffer(type);
  4556. _getWebGLTextureType(type: number): number;
  4557. _getRGBABufferInternalSizedFormat(type: number): number;
  4558. _getRGBAMultiSampleBufferFormat(type: number): number;
  4559. createQuery(): WebGLQuery;
  4560. deleteQuery(query: WebGLQuery): Engine;
  4561. isQueryResultAvailable(query: WebGLQuery): boolean;
  4562. getQueryResult(query: WebGLQuery): number;
  4563. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  4564. endOcclusionQuery(algorithmType: number): Engine;
  4565. private _createTimeQuery();
  4566. private _deleteTimeQuery(query);
  4567. private _getTimeQueryResult(query);
  4568. private _getTimeQueryAvailability(query);
  4569. private _currentNonTimestampToken;
  4570. startTimeQuery(): Nullable<_TimeToken>;
  4571. endTimeQuery(token: _TimeToken): int;
  4572. private getGlAlgorithmType(algorithmType);
  4573. createTransformFeedback(): WebGLTransformFeedback;
  4574. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  4575. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  4576. beginTransformFeedback(usePoints?: boolean): void;
  4577. endTransformFeedback(): void;
  4578. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  4579. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  4580. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  4581. private _partialLoadFile(url, index, loadedFiles, scene, onfinish, onErrorCallBack?);
  4582. private _cascadeLoadFiles(rootUrl, scene, onfinish, files, onError?);
  4583. static isSupported(): boolean;
  4584. }
  4585. }
  4586. declare module BABYLON {
  4587. class NullEngineOptions {
  4588. renderWidth: number;
  4589. renderHeight: number;
  4590. textureSize: number;
  4591. deterministicLockstep: boolean;
  4592. lockstepMaxSteps: number;
  4593. }
  4594. /**
  4595. * The null engine class provides support for headless version of babylon.js.
  4596. * This can be used in server side scenario or for testing purposes
  4597. */
  4598. class NullEngine extends Engine {
  4599. private _options;
  4600. isDeterministicLockStep(): boolean;
  4601. getLockstepMaxSteps(): number;
  4602. constructor(options?: NullEngineOptions);
  4603. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4604. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  4605. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  4606. getRenderWidth(useScreen?: boolean): number;
  4607. getRenderHeight(useScreen?: boolean): number;
  4608. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  4609. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  4610. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  4611. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  4612. bindSamplers(effect: Effect): void;
  4613. enableEffect(effect: Effect): void;
  4614. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  4615. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  4616. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  4617. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  4618. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  4619. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  4620. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  4621. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  4622. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  4623. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  4624. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  4625. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  4626. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  4627. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  4628. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  4629. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  4630. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  4631. setFloat(uniform: WebGLUniformLocation, value: number): void;
  4632. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  4633. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  4634. setBool(uniform: WebGLUniformLocation, bool: number): void;
  4635. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  4636. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  4637. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  4638. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  4639. bindBuffers(vertexBuffers: {
  4640. [key: string]: VertexBuffer;
  4641. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  4642. wipeCaches(bruteForce?: boolean): void;
  4643. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  4644. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  4645. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  4646. _createTexture(): WebGLTexture;
  4647. 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;
  4648. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  4649. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  4650. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  4651. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  4652. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  4653. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  4654. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, offset?: number, count?: number): void;
  4655. protected _bindTextureDirectly(target: number, texture: InternalTexture): void;
  4656. _bindTexture(channel: number, texture: InternalTexture): void;
  4657. _releaseBuffer(buffer: WebGLBuffer): boolean;
  4658. }
  4659. }
  4660. interface WebGLRenderingContext {
  4661. readonly RASTERIZER_DISCARD: number;
  4662. readonly TEXTURE_3D: number;
  4663. readonly TEXTURE_2D_ARRAY: number;
  4664. readonly TEXTURE_WRAP_R: number;
  4665. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  4666. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  4667. 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;
  4668. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  4669. readonly TRANSFORM_FEEDBACK: number;
  4670. readonly INTERLEAVED_ATTRIBS: number;
  4671. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  4672. createTransformFeedback(): WebGLTransformFeedback;
  4673. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  4674. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  4675. beginTransformFeedback(primitiveMode: number): void;
  4676. endTransformFeedback(): void;
  4677. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  4678. }
  4679. interface ImageBitmap {
  4680. readonly width: number;
  4681. readonly height: number;
  4682. close(): void;
  4683. }
  4684. interface WebGLQuery extends WebGLObject {
  4685. }
  4686. declare var WebGLQuery: {
  4687. prototype: WebGLQuery;
  4688. new (): WebGLQuery;
  4689. };
  4690. interface WebGLSampler extends WebGLObject {
  4691. }
  4692. declare var WebGLSampler: {
  4693. prototype: WebGLSampler;
  4694. new (): WebGLSampler;
  4695. };
  4696. interface WebGLSync extends WebGLObject {
  4697. }
  4698. declare var WebGLSync: {
  4699. prototype: WebGLSync;
  4700. new (): WebGLSync;
  4701. };
  4702. interface WebGLTransformFeedback extends WebGLObject {
  4703. }
  4704. declare var WebGLTransformFeedback: {
  4705. prototype: WebGLTransformFeedback;
  4706. new (): WebGLTransformFeedback;
  4707. };
  4708. interface WebGLVertexArrayObject extends WebGLObject {
  4709. }
  4710. declare var WebGLVertexArrayObject: {
  4711. prototype: WebGLVertexArrayObject;
  4712. new (): WebGLVertexArrayObject;
  4713. };
  4714. declare module BABYLON {
  4715. class KeyboardEventTypes {
  4716. static _KEYDOWN: number;
  4717. static _KEYUP: number;
  4718. static readonly KEYDOWN: number;
  4719. static readonly KEYUP: number;
  4720. }
  4721. class KeyboardInfo {
  4722. type: number;
  4723. event: KeyboardEvent;
  4724. constructor(type: number, event: KeyboardEvent);
  4725. }
  4726. /**
  4727. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  4728. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  4729. */
  4730. class KeyboardInfoPre extends KeyboardInfo {
  4731. constructor(type: number, event: KeyboardEvent);
  4732. skipOnPointerObservable: boolean;
  4733. }
  4734. }
  4735. declare module BABYLON {
  4736. class PointerEventTypes {
  4737. static _POINTERDOWN: number;
  4738. static _POINTERUP: number;
  4739. static _POINTERMOVE: number;
  4740. static _POINTERWHEEL: number;
  4741. static _POINTERPICK: number;
  4742. static _POINTERTAP: number;
  4743. static _POINTERDOUBLETAP: number;
  4744. static readonly POINTERDOWN: number;
  4745. static readonly POINTERUP: number;
  4746. static readonly POINTERMOVE: number;
  4747. static readonly POINTERWHEEL: number;
  4748. static readonly POINTERPICK: number;
  4749. static readonly POINTERTAP: number;
  4750. static readonly POINTERDOUBLETAP: number;
  4751. }
  4752. class PointerInfoBase {
  4753. type: number;
  4754. event: PointerEvent | MouseWheelEvent;
  4755. constructor(type: number, event: PointerEvent | MouseWheelEvent);
  4756. }
  4757. /**
  4758. * This class is used to store pointer related info for the onPrePointerObservable event.
  4759. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  4760. */
  4761. class PointerInfoPre extends PointerInfoBase {
  4762. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  4763. localPosition: Vector2;
  4764. skipOnPointerObservable: boolean;
  4765. }
  4766. /**
  4767. * This type contains all the data related to a pointer event in Babylon.js.
  4768. * 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.
  4769. */
  4770. class PointerInfo extends PointerInfoBase {
  4771. pickInfo: Nullable<PickingInfo>;
  4772. constructor(type: number, event: PointerEvent | MouseWheelEvent, pickInfo: Nullable<PickingInfo>);
  4773. }
  4774. }
  4775. declare module BABYLON {
  4776. /**
  4777. * Represents the different options available during the creation of
  4778. * a Environment helper.
  4779. *
  4780. * This can control the default ground, skybox and image processing setup of your scene.
  4781. */
  4782. interface IEnvironmentHelperOptions {
  4783. /**
  4784. * Specifies wether or not to create a ground.
  4785. * True by default.
  4786. */
  4787. createGround: boolean;
  4788. /**
  4789. * Specifies the ground size.
  4790. * 15 by default.
  4791. */
  4792. groundSize: number;
  4793. /**
  4794. * The texture used on the ground for the main color.
  4795. * Comes from the BabylonJS CDN by default.
  4796. *
  4797. * Remarks: Can be either a texture or a url.
  4798. */
  4799. groundTexture: string | BaseTexture;
  4800. /**
  4801. * The color mixed in the ground texture by default.
  4802. * BabylonJS clearColor by default.
  4803. */
  4804. groundColor: Color3;
  4805. /**
  4806. * Specifies the ground opacity.
  4807. * 1 by default.
  4808. */
  4809. groundOpacity: number;
  4810. /**
  4811. * Enables the ground to receive shadows.
  4812. * True by default.
  4813. */
  4814. enableGroundShadow: boolean;
  4815. /**
  4816. * Helps preventing the shadow to be fully black on the ground.
  4817. * 0.5 by default.
  4818. */
  4819. groundShadowLevel: number;
  4820. /**
  4821. * Creates a mirror texture attach to the ground.
  4822. * false by default.
  4823. */
  4824. enableGroundMirror: boolean;
  4825. /**
  4826. * Specifies the ground mirror size ratio.
  4827. * 0.3 by default as the default kernel is 64.
  4828. */
  4829. groundMirrorSizeRatio: number;
  4830. /**
  4831. * Specifies the ground mirror blur kernel size.
  4832. * 64 by default.
  4833. */
  4834. groundMirrorBlurKernel: number;
  4835. /**
  4836. * Specifies the ground mirror visibility amount.
  4837. * 1 by default
  4838. */
  4839. groundMirrorAmount: number;
  4840. /**
  4841. * Specifies the ground mirror reflectance weight.
  4842. * This uses the standard weight of the background material to setup the fresnel effect
  4843. * of the mirror.
  4844. * 1 by default.
  4845. */
  4846. groundMirrorFresnelWeight: number;
  4847. /**
  4848. * Specifies the ground mirror Falloff distance.
  4849. * This can helps reducing the size of the reflection.
  4850. * 0 by Default.
  4851. */
  4852. groundMirrorFallOffDistance: number;
  4853. /**
  4854. * Specifies the ground mirror texture type.
  4855. * Unsigned Int by Default.
  4856. */
  4857. groundMirrorTextureType: number;
  4858. /**
  4859. * Specifies a bias applied to the ground vertical position to prevent z-fighyting with
  4860. * the shown objects.
  4861. */
  4862. groundYBias: number;
  4863. /**
  4864. * Specifies wether or not to create a skybox.
  4865. * True by default.
  4866. */
  4867. createSkybox: boolean;
  4868. /**
  4869. * Specifies the skybox size.
  4870. * 20 by default.
  4871. */
  4872. skyboxSize: number;
  4873. /**
  4874. * The texture used on the skybox for the main color.
  4875. * Comes from the BabylonJS CDN by default.
  4876. *
  4877. * Remarks: Can be either a texture or a url.
  4878. */
  4879. skyboxTexture: string | BaseTexture;
  4880. /**
  4881. * The color mixed in the skybox texture by default.
  4882. * BabylonJS clearColor by default.
  4883. */
  4884. skyboxColor: Color3;
  4885. /**
  4886. * The background rotation around the Y axis of the scene.
  4887. * This helps aligning the key lights of your scene with the background.
  4888. * 0 by default.
  4889. */
  4890. backgroundYRotation: number;
  4891. /**
  4892. * Compute automatically the size of the elements to best fit with the scene.
  4893. */
  4894. sizeAuto: boolean;
  4895. /**
  4896. * Default position of the rootMesh if autoSize is not true.
  4897. */
  4898. rootPosition: Vector3;
  4899. /**
  4900. * Sets up the image processing in the scene.
  4901. * true by default.
  4902. */
  4903. setupImageProcessing: boolean;
  4904. /**
  4905. * The texture used as your environment texture in the scene.
  4906. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  4907. *
  4908. * Remarks: Can be either a texture or a url.
  4909. */
  4910. environmentTexture: string | BaseTexture;
  4911. /**
  4912. * The value of the exposure to apply to the scene.
  4913. * 0.6 by default if setupImageProcessing is true.
  4914. */
  4915. cameraExposure: number;
  4916. /**
  4917. * The value of the contrast to apply to the scene.
  4918. * 1.6 by default if setupImageProcessing is true.
  4919. */
  4920. cameraContrast: number;
  4921. /**
  4922. * Specifies wether or not tonemapping should be enabled in the scene.
  4923. * true by default if setupImageProcessing is true.
  4924. */
  4925. toneMappingEnabled: boolean;
  4926. }
  4927. /**
  4928. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  4929. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  4930. * It also helps with the default setup of your imageProcessing configuration.
  4931. */
  4932. class EnvironmentHelper {
  4933. /**
  4934. * Default ground texture URL.
  4935. */
  4936. private static _groundTextureCDNUrl;
  4937. /**
  4938. * Default skybox texture URL.
  4939. */
  4940. private static _skyboxTextureCDNUrl;
  4941. /**
  4942. * Default environment texture URL.
  4943. */
  4944. private static _environmentTextureCDNUrl;
  4945. /**
  4946. * Creates the default options for the helper.
  4947. */
  4948. private static _getDefaultOptions();
  4949. private _rootMesh;
  4950. /**
  4951. * Gets the root mesh created by the helper.
  4952. */
  4953. readonly rootMesh: Mesh;
  4954. private _skybox;
  4955. /**
  4956. * Gets the skybox created by the helper.
  4957. */
  4958. readonly skybox: Nullable<Mesh>;
  4959. private _skyboxTexture;
  4960. /**
  4961. * Gets the skybox texture created by the helper.
  4962. */
  4963. readonly skyboxTexture: Nullable<BaseTexture>;
  4964. private _skyboxMaterial;
  4965. /**
  4966. * Gets the skybox material created by the helper.
  4967. */
  4968. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  4969. private _ground;
  4970. /**
  4971. * Gets the ground mesh created by the helper.
  4972. */
  4973. readonly ground: Nullable<Mesh>;
  4974. private _groundTexture;
  4975. /**
  4976. * Gets the ground texture created by the helper.
  4977. */
  4978. readonly groundTexture: Nullable<BaseTexture>;
  4979. private _groundMirror;
  4980. /**
  4981. * Gets the ground mirror created by the helper.
  4982. */
  4983. readonly groundMirror: Nullable<MirrorTexture>;
  4984. /**
  4985. * Gets the ground mirror render list to helps pushing the meshes
  4986. * you wish in the ground reflection.
  4987. */
  4988. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  4989. private _groundMaterial;
  4990. /**
  4991. * Gets the ground material created by the helper.
  4992. */
  4993. readonly groundMaterial: Nullable<BackgroundMaterial>;
  4994. /**
  4995. * Stores the creation options.
  4996. */
  4997. private readonly _scene;
  4998. private _options;
  4999. /**
  5000. * constructor
  5001. * @param options
  5002. * @param scene The scene to add the material to
  5003. */
  5004. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  5005. /**
  5006. * Updates the background according to the new options
  5007. * @param options
  5008. */
  5009. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  5010. /**
  5011. * Sets the primary color of all the available elements.
  5012. * @param color
  5013. */
  5014. setMainColor(color: Color3): void;
  5015. /**
  5016. * Setup the image processing according to the specified options.
  5017. */
  5018. private _setupImageProcessing();
  5019. /**
  5020. * Setup the environment texture according to the specified options.
  5021. */
  5022. private _setupEnvironmentTexture();
  5023. /**
  5024. * Setup the background according to the specified options.
  5025. */
  5026. private _setupBackground();
  5027. /**
  5028. * Get the scene sizes according to the setup.
  5029. */
  5030. private _getSceneSize();
  5031. /**
  5032. * Setup the ground according to the specified options.
  5033. */
  5034. private _setupGround(sceneSize);
  5035. /**
  5036. * Setup the ground material according to the specified options.
  5037. */
  5038. private _setupGroundMaterial();
  5039. /**
  5040. * Setup the ground diffuse texture according to the specified options.
  5041. */
  5042. private _setupGroundDiffuseTexture();
  5043. /**
  5044. * Setup the ground mirror texture according to the specified options.
  5045. */
  5046. private _setupGroundMirrorTexture(sceneSize);
  5047. /**
  5048. * Setup the ground to receive the mirror texture.
  5049. */
  5050. private _setupMirrorInGroundMaterial();
  5051. /**
  5052. * Setup the skybox according to the specified options.
  5053. */
  5054. private _setupSkybox(sceneSize);
  5055. /**
  5056. * Setup the skybox material according to the specified options.
  5057. */
  5058. private _setupSkyboxMaterial();
  5059. /**
  5060. * Setup the skybox reflection texture according to the specified options.
  5061. */
  5062. private _setupSkyboxReflectionTexture();
  5063. /**
  5064. * Dispose all the elements created by the Helper.
  5065. */
  5066. dispose(): void;
  5067. }
  5068. }
  5069. declare module BABYLON {
  5070. class StickValues {
  5071. x: number;
  5072. y: number;
  5073. constructor(x: number, y: number);
  5074. }
  5075. interface GamepadButtonChanges {
  5076. changed: boolean;
  5077. pressChanged: boolean;
  5078. touchChanged: boolean;
  5079. valueChanged: boolean;
  5080. }
  5081. class Gamepad {
  5082. id: string;
  5083. index: number;
  5084. browserGamepad: any;
  5085. type: number;
  5086. private _leftStick;
  5087. private _rightStick;
  5088. _isConnected: boolean;
  5089. private _leftStickAxisX;
  5090. private _leftStickAxisY;
  5091. private _rightStickAxisX;
  5092. private _rightStickAxisY;
  5093. private _onleftstickchanged;
  5094. private _onrightstickchanged;
  5095. static GAMEPAD: number;
  5096. static GENERIC: number;
  5097. static XBOX: number;
  5098. static POSE_ENABLED: number;
  5099. protected _invertLeftStickY: boolean;
  5100. readonly isConnected: boolean;
  5101. constructor(id: string, index: number, browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  5102. onleftstickchanged(callback: (values: StickValues) => void): void;
  5103. onrightstickchanged(callback: (values: StickValues) => void): void;
  5104. leftStick: StickValues;
  5105. rightStick: StickValues;
  5106. update(): void;
  5107. dispose(): void;
  5108. }
  5109. class GenericPad extends Gamepad {
  5110. private _buttons;
  5111. private _onbuttondown;
  5112. private _onbuttonup;
  5113. onButtonDownObservable: Observable<number>;
  5114. onButtonUpObservable: Observable<number>;
  5115. onbuttondown(callback: (buttonPressed: number) => void): void;
  5116. onbuttonup(callback: (buttonReleased: number) => void): void;
  5117. constructor(id: string, index: number, browserGamepad: any);
  5118. private _setButtonValue(newValue, currentValue, buttonIndex);
  5119. update(): void;
  5120. dispose(): void;
  5121. }
  5122. }
  5123. declare module BABYLON {
  5124. class GamepadManager {
  5125. private _scene;
  5126. private _babylonGamepads;
  5127. private _oneGamepadConnected;
  5128. _isMonitoring: boolean;
  5129. private _gamepadEventSupported;
  5130. private _gamepadSupport;
  5131. onGamepadConnectedObservable: Observable<Gamepad>;
  5132. onGamepadDisconnectedObservable: Observable<Gamepad>;
  5133. private _onGamepadConnectedEvent;
  5134. private _onGamepadDisconnectedEvent;
  5135. constructor(_scene?: Scene | undefined);
  5136. readonly gamepads: Gamepad[];
  5137. getGamepadByType(type?: number): Nullable<Gamepad>;
  5138. dispose(): void;
  5139. private _addNewGamepad(gamepad);
  5140. private _startMonitoringGamepads();
  5141. private _stopMonitoringGamepads();
  5142. _checkGamepadsStatus(): void;
  5143. private _updateGamepadObjects();
  5144. }
  5145. }
  5146. declare module BABYLON {
  5147. enum Xbox360Button {
  5148. A = 0,
  5149. B = 1,
  5150. X = 2,
  5151. Y = 3,
  5152. Start = 4,
  5153. Back = 5,
  5154. LB = 6,
  5155. RB = 7,
  5156. LeftStick = 8,
  5157. RightStick = 9,
  5158. }
  5159. enum Xbox360Dpad {
  5160. Up = 0,
  5161. Down = 1,
  5162. Left = 2,
  5163. Right = 3,
  5164. }
  5165. class Xbox360Pad extends Gamepad {
  5166. private _leftTrigger;
  5167. private _rightTrigger;
  5168. private _onlefttriggerchanged;
  5169. private _onrighttriggerchanged;
  5170. private _onbuttondown;
  5171. private _onbuttonup;
  5172. private _ondpaddown;
  5173. private _ondpadup;
  5174. onButtonDownObservable: Observable<Xbox360Button>;
  5175. onButtonUpObservable: Observable<Xbox360Button>;
  5176. onPadDownObservable: Observable<Xbox360Dpad>;
  5177. onPadUpObservable: Observable<Xbox360Dpad>;
  5178. private _buttonA;
  5179. private _buttonB;
  5180. private _buttonX;
  5181. private _buttonY;
  5182. private _buttonBack;
  5183. private _buttonStart;
  5184. private _buttonLB;
  5185. private _buttonRB;
  5186. private _buttonLeftStick;
  5187. private _buttonRightStick;
  5188. private _dPadUp;
  5189. private _dPadDown;
  5190. private _dPadLeft;
  5191. private _dPadRight;
  5192. private _isXboxOnePad;
  5193. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  5194. onlefttriggerchanged(callback: (value: number) => void): void;
  5195. onrighttriggerchanged(callback: (value: number) => void): void;
  5196. leftTrigger: number;
  5197. rightTrigger: number;
  5198. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5199. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5200. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5201. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5202. private _setButtonValue(newValue, currentValue, buttonType);
  5203. private _setDPadValue(newValue, currentValue, buttonType);
  5204. buttonA: number;
  5205. buttonB: number;
  5206. buttonX: number;
  5207. buttonY: number;
  5208. buttonStart: number;
  5209. buttonBack: number;
  5210. buttonLB: number;
  5211. buttonRB: number;
  5212. buttonLeftStick: number;
  5213. buttonRightStick: number;
  5214. dPadUp: number;
  5215. dPadDown: number;
  5216. dPadLeft: number;
  5217. dPadRight: number;
  5218. update(): void;
  5219. dispose(): void;
  5220. }
  5221. }
  5222. declare module BABYLON {
  5223. /**
  5224. * This class can be used to get instrumentation data from a Babylon engine
  5225. */
  5226. class EngineInstrumentation implements IDisposable {
  5227. engine: Engine;
  5228. private _captureGPUFrameTime;
  5229. private _gpuFrameTimeToken;
  5230. private _gpuFrameTime;
  5231. private _captureShaderCompilationTime;
  5232. private _shaderCompilationTime;
  5233. private _onBeginFrameObserver;
  5234. private _onEndFrameObserver;
  5235. private _onBeforeShaderCompilationObserver;
  5236. private _onAfterShaderCompilationObserver;
  5237. /**
  5238. * Gets the perf counter used for GPU frame time
  5239. */
  5240. readonly gpuFrameTimeCounter: PerfCounter;
  5241. /**
  5242. * Gets the GPU frame time capture status
  5243. */
  5244. /**
  5245. * Enable or disable the GPU frame time capture
  5246. */
  5247. captureGPUFrameTime: boolean;
  5248. /**
  5249. * Gets the perf counter used for shader compilation time
  5250. */
  5251. readonly shaderCompilationTimeCounter: PerfCounter;
  5252. /**
  5253. * Gets the shader compilation time capture status
  5254. */
  5255. /**
  5256. * Enable or disable the shader compilation time capture
  5257. */
  5258. captureShaderCompilationTime: boolean;
  5259. constructor(engine: Engine);
  5260. dispose(): void;
  5261. }
  5262. }
  5263. declare module BABYLON {
  5264. /**
  5265. * This class can be used to get instrumentation data from a Babylon engine
  5266. */
  5267. class SceneInstrumentation implements IDisposable {
  5268. scene: Scene;
  5269. private _captureActiveMeshesEvaluationTime;
  5270. private _activeMeshesEvaluationTime;
  5271. private _captureRenderTargetsRenderTime;
  5272. private _renderTargetsRenderTime;
  5273. private _captureFrameTime;
  5274. private _frameTime;
  5275. private _captureRenderTime;
  5276. private _renderTime;
  5277. private _captureInterFrameTime;
  5278. private _interFrameTime;
  5279. private _captureParticlesRenderTime;
  5280. private _particlesRenderTime;
  5281. private _captureSpritesRenderTime;
  5282. private _spritesRenderTime;
  5283. private _capturePhysicsTime;
  5284. private _physicsTime;
  5285. private _captureAnimationsTime;
  5286. private _animationsTime;
  5287. private _onBeforeActiveMeshesEvaluationObserver;
  5288. private _onAfterActiveMeshesEvaluationObserver;
  5289. private _onBeforeRenderTargetsRenderObserver;
  5290. private _onAfterRenderTargetsRenderObserver;
  5291. private _onAfterRenderObserver;
  5292. private _onBeforeDrawPhaseObserver;
  5293. private _onAfterDrawPhaseObserver;
  5294. private _onBeforeAnimationsObserver;
  5295. private _onBeforeParticlesRenderingObserver;
  5296. private _onAfterParticlesRenderingObserver;
  5297. private _onBeforeSpritesRenderingObserver;
  5298. private _onAfterSpritesRenderingObserver;
  5299. private _onBeforePhysicsObserver;
  5300. private _onAfterPhysicsObserver;
  5301. private _onAfterAnimationsObserver;
  5302. /**
  5303. * Gets the perf counter used for active meshes evaluation time
  5304. */
  5305. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  5306. /**
  5307. * Gets the active meshes evaluation time capture status
  5308. */
  5309. /**
  5310. * Enable or disable the active meshes evaluation time capture
  5311. */
  5312. captureActiveMeshesEvaluationTime: boolean;
  5313. /**
  5314. * Gets the perf counter used for render targets render time
  5315. */
  5316. readonly renderTargetsRenderTimeCounter: PerfCounter;
  5317. /**
  5318. * Gets the render targets render time capture status
  5319. */
  5320. /**
  5321. * Enable or disable the render targets render time capture
  5322. */
  5323. captureRenderTargetsRenderTime: boolean;
  5324. /**
  5325. * Gets the perf counter used for particles render time
  5326. */
  5327. readonly particlesRenderTimeCounter: PerfCounter;
  5328. /**
  5329. * Gets the particles render time capture status
  5330. */
  5331. /**
  5332. * Enable or disable the particles render time capture
  5333. */
  5334. captureParticlesRenderTime: boolean;
  5335. /**
  5336. * Gets the perf counter used for sprites render time
  5337. */
  5338. readonly spritesRenderTimeCounter: PerfCounter;
  5339. /**
  5340. * Gets the sprites render time capture status
  5341. */
  5342. /**
  5343. * Enable or disable the sprites render time capture
  5344. */
  5345. captureSpritesRenderTime: boolean;
  5346. /**
  5347. * Gets the perf counter used for physics time
  5348. */
  5349. readonly physicsTimeCounter: PerfCounter;
  5350. /**
  5351. * Gets the physics time capture status
  5352. */
  5353. /**
  5354. * Enable or disable the physics time capture
  5355. */
  5356. capturePhysicsTime: boolean;
  5357. /**
  5358. * Gets the perf counter used for animations time
  5359. */
  5360. readonly animationsTimeCounter: PerfCounter;
  5361. /**
  5362. * Gets the animations time capture status
  5363. */
  5364. /**
  5365. * Enable or disable the animations time capture
  5366. */
  5367. captureAnimationsTime: boolean;
  5368. /**
  5369. * Gets the perf counter used for frame time capture
  5370. */
  5371. readonly frameTimeCounter: PerfCounter;
  5372. /**
  5373. * Gets the frame time capture status
  5374. */
  5375. /**
  5376. * Enable or disable the frame time capture
  5377. */
  5378. captureFrameTime: boolean;
  5379. /**
  5380. * Gets the perf counter used for inter-frames time capture
  5381. */
  5382. readonly interFrameTimeCounter: PerfCounter;
  5383. /**
  5384. * Gets the inter-frames time capture status
  5385. */
  5386. /**
  5387. * Enable or disable the inter-frames time capture
  5388. */
  5389. captureInterFrameTime: boolean;
  5390. /**
  5391. * Gets the perf counter used for render time capture
  5392. */
  5393. readonly renderTimeCounter: PerfCounter;
  5394. /**
  5395. * Gets the render time capture status
  5396. */
  5397. /**
  5398. * Enable or disable the render time capture
  5399. */
  5400. captureRenderTime: boolean;
  5401. /**
  5402. * Gets the perf counter used for draw calls
  5403. */
  5404. readonly drawCallsCounter: PerfCounter;
  5405. /**
  5406. * Gets the perf counter used for texture collisions
  5407. */
  5408. readonly textureCollisionsCounter: PerfCounter;
  5409. constructor(scene: Scene);
  5410. dispose(): void;
  5411. }
  5412. }
  5413. declare module BABYLON {
  5414. class _TimeToken {
  5415. _startTimeQuery: Nullable<WebGLQuery>;
  5416. _endTimeQuery: Nullable<WebGLQuery>;
  5417. _timeElapsedQuery: Nullable<WebGLQuery>;
  5418. _timeElapsedQueryEnded: boolean;
  5419. }
  5420. }
  5421. declare module BABYLON {
  5422. /**
  5423. * Highlight layer options. This helps customizing the behaviour
  5424. * of the highlight layer.
  5425. */
  5426. interface IHighlightLayerOptions {
  5427. /**
  5428. * Multiplication factor apply to the canvas size to compute the render target size
  5429. * used to generated the glowing objects (the smaller the faster).
  5430. */
  5431. mainTextureRatio: number;
  5432. /**
  5433. * Enforces a fixed size texture to ensure resize independant blur.
  5434. */
  5435. mainTextureFixedSize?: number;
  5436. /**
  5437. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  5438. * of the picture to blur (the smaller the faster).
  5439. */
  5440. blurTextureSizeRatio: number;
  5441. /**
  5442. * How big in texel of the blur texture is the vertical blur.
  5443. */
  5444. blurVerticalSize: number;
  5445. /**
  5446. * How big in texel of the blur texture is the horizontal blur.
  5447. */
  5448. blurHorizontalSize: number;
  5449. /**
  5450. * Alpha blending mode used to apply the blur. Default is combine.
  5451. */
  5452. alphaBlendingMode: number;
  5453. /**
  5454. * The camera attached to the layer.
  5455. */
  5456. camera: Nullable<Camera>;
  5457. /**
  5458. * Should we display highlight as a solid stroke?
  5459. */
  5460. isStroke?: boolean;
  5461. }
  5462. /**
  5463. * The highlight layer Helps adding a glow effect around a mesh.
  5464. *
  5465. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  5466. * glowy meshes to your scene.
  5467. *
  5468. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  5469. */
  5470. class HighlightLayer {
  5471. name: string;
  5472. /**
  5473. * The neutral color used during the preparation of the glow effect.
  5474. * This is black by default as the blend operation is a blend operation.
  5475. */
  5476. static neutralColor: Color4;
  5477. /**
  5478. * Stencil value used for glowing meshes.
  5479. */
  5480. static glowingMeshStencilReference: number;
  5481. /**
  5482. * Stencil value used for the other meshes in the scene.
  5483. */
  5484. static normalMeshStencilReference: number;
  5485. private _scene;
  5486. private _engine;
  5487. private _options;
  5488. private _vertexBuffers;
  5489. private _indexBuffer;
  5490. private _downSamplePostprocess;
  5491. private _horizontalBlurPostprocess;
  5492. private _verticalBlurPostprocess;
  5493. private _cachedDefines;
  5494. private _glowMapGenerationEffect;
  5495. private _glowMapMergeEffect;
  5496. private _blurTexture;
  5497. private _mainTexture;
  5498. private _mainTextureDesiredSize;
  5499. private _meshes;
  5500. private _maxSize;
  5501. private _shouldRender;
  5502. private _instanceGlowingMeshStencilReference;
  5503. private _excludedMeshes;
  5504. /**
  5505. * Specifies whether or not the inner glow is ACTIVE in the layer.
  5506. */
  5507. innerGlow: boolean;
  5508. /**
  5509. * Specifies whether or not the outer glow is ACTIVE in the layer.
  5510. */
  5511. outerGlow: boolean;
  5512. /**
  5513. * Specifies wether the highlight layer is enabled or not.
  5514. */
  5515. isEnabled: boolean;
  5516. /**
  5517. * Gets the horizontal size of the blur.
  5518. */
  5519. /**
  5520. * Specifies the horizontal size of the blur.
  5521. */
  5522. blurHorizontalSize: number;
  5523. /**
  5524. * Gets the vertical size of the blur.
  5525. */
  5526. /**
  5527. * Specifies the vertical size of the blur.
  5528. */
  5529. blurVerticalSize: number;
  5530. /**
  5531. * Gets the camera attached to the layer.
  5532. */
  5533. readonly camera: Nullable<Camera>;
  5534. /**
  5535. * An event triggered when the highlight layer has been disposed.
  5536. * @type {BABYLON.Observable}
  5537. */
  5538. onDisposeObservable: Observable<HighlightLayer>;
  5539. /**
  5540. * An event triggered when the highlight layer is about rendering the main texture with the glowy parts.
  5541. * @type {BABYLON.Observable}
  5542. */
  5543. onBeforeRenderMainTextureObservable: Observable<HighlightLayer>;
  5544. /**
  5545. * An event triggered when the highlight layer is being blurred.
  5546. * @type {BABYLON.Observable}
  5547. */
  5548. onBeforeBlurObservable: Observable<HighlightLayer>;
  5549. /**
  5550. * An event triggered when the highlight layer has been blurred.
  5551. * @type {BABYLON.Observable}
  5552. */
  5553. onAfterBlurObservable: Observable<HighlightLayer>;
  5554. /**
  5555. * An event triggered when the glowing blurred texture is being merged in the scene.
  5556. * @type {BABYLON.Observable}
  5557. */
  5558. onBeforeComposeObservable: Observable<HighlightLayer>;
  5559. /**
  5560. * An event triggered when the glowing blurred texture has been merged in the scene.
  5561. * @type {BABYLON.Observable}
  5562. */
  5563. onAfterComposeObservable: Observable<HighlightLayer>;
  5564. /**
  5565. * An event triggered when the highlight layer changes its size.
  5566. * @type {BABYLON.Observable}
  5567. */
  5568. onSizeChangedObservable: Observable<HighlightLayer>;
  5569. /**
  5570. * Instantiates a new highlight Layer and references it to the scene..
  5571. * @param name The name of the layer
  5572. * @param scene The scene to use the layer in
  5573. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  5574. */
  5575. constructor(name: string, scene: Scene, options?: IHighlightLayerOptions);
  5576. private _createIndexBuffer();
  5577. _rebuild(): void;
  5578. /**
  5579. * Creates the render target textures and post processes used in the highlight layer.
  5580. */
  5581. private createTextureAndPostProcesses();
  5582. /**
  5583. * Checks for the readiness of the element composing the layer.
  5584. * @param subMesh the mesh to check for
  5585. * @param useInstances specify wether or not to use instances to render the mesh
  5586. * @param emissiveTexture the associated emissive texture used to generate the glow
  5587. * @return true if ready otherwise, false
  5588. */
  5589. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5590. /**
  5591. * Checks for the readiness of the element composing the layer.
  5592. * @param subMesh the mesh to check for
  5593. * @param useInstances specify wether or not to use instances to render the mesh
  5594. * @param emissiveTexture the associated emissive texture used to generate the glow
  5595. * @return true if ready otherwise, false
  5596. */
  5597. private _isReady(subMesh, useInstances, emissiveTexture);
  5598. /**
  5599. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  5600. */
  5601. render(): void;
  5602. /**
  5603. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  5604. * @param mesh The mesh to exclude from the highlight layer
  5605. */
  5606. addExcludedMesh(mesh: Mesh): void;
  5607. /**
  5608. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  5609. * @param mesh The mesh to highlight
  5610. */
  5611. removeExcludedMesh(mesh: Mesh): void;
  5612. /**
  5613. * Determine if a given mesh will be highlighted by the current HighlightLayer
  5614. * @param mesh mesh to test
  5615. * @returns true if the mesh will be highlighted by the current HighlightLayer
  5616. */
  5617. hasMesh(mesh: AbstractMesh): boolean;
  5618. /**
  5619. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  5620. * @param mesh The mesh to highlight
  5621. * @param color The color of the highlight
  5622. * @param glowEmissiveOnly Extract the glow from the emissive texture
  5623. */
  5624. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  5625. /**
  5626. * Remove a mesh from the highlight layer in order to make it stop glowing.
  5627. * @param mesh The mesh to highlight
  5628. */
  5629. removeMesh(mesh: Mesh): void;
  5630. /**
  5631. * Returns true if the layer contains information to display, otherwise false.
  5632. */
  5633. shouldRender(): boolean;
  5634. /**
  5635. * Sets the main texture desired size which is the closest power of two
  5636. * of the engine canvas size.
  5637. */
  5638. private setMainTextureSize();
  5639. /**
  5640. * Force the stencil to the normal expected value for none glowing parts
  5641. */
  5642. private defaultStencilReference(mesh);
  5643. /**
  5644. * Dispose only the render target textures and post process.
  5645. */
  5646. private disposeTextureAndPostProcesses();
  5647. /**
  5648. * Dispose the highlight layer and free resources.
  5649. */
  5650. dispose(): void;
  5651. }
  5652. }
  5653. declare module BABYLON {
  5654. class Layer {
  5655. name: string;
  5656. texture: Nullable<Texture>;
  5657. isBackground: boolean;
  5658. color: Color4;
  5659. scale: Vector2;
  5660. offset: Vector2;
  5661. alphaBlendingMode: number;
  5662. alphaTest: boolean;
  5663. layerMask: number;
  5664. private _scene;
  5665. private _vertexBuffers;
  5666. private _indexBuffer;
  5667. private _effect;
  5668. private _alphaTestEffect;
  5669. /**
  5670. * An event triggered when the layer is disposed.
  5671. * @type {BABYLON.Observable}
  5672. */
  5673. onDisposeObservable: Observable<Layer>;
  5674. private _onDisposeObserver;
  5675. onDispose: () => void;
  5676. /**
  5677. * An event triggered before rendering the scene
  5678. * @type {BABYLON.Observable}
  5679. */
  5680. onBeforeRenderObservable: Observable<Layer>;
  5681. private _onBeforeRenderObserver;
  5682. onBeforeRender: () => void;
  5683. /**
  5684. * An event triggered after rendering the scene
  5685. * @type {BABYLON.Observable}
  5686. */
  5687. onAfterRenderObservable: Observable<Layer>;
  5688. private _onAfterRenderObserver;
  5689. onAfterRender: () => void;
  5690. constructor(name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  5691. private _createIndexBuffer();
  5692. _rebuild(): void;
  5693. render(): void;
  5694. dispose(): void;
  5695. }
  5696. }
  5697. declare module BABYLON {
  5698. class LensFlare {
  5699. size: number;
  5700. position: number;
  5701. color: Color3;
  5702. texture: Nullable<Texture>;
  5703. alphaMode: number;
  5704. private _system;
  5705. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  5706. constructor(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  5707. dispose(): void;
  5708. }
  5709. }
  5710. declare module BABYLON {
  5711. class LensFlareSystem {
  5712. name: string;
  5713. lensFlares: LensFlare[];
  5714. borderLimit: number;
  5715. viewportBorder: number;
  5716. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  5717. layerMask: number;
  5718. id: string;
  5719. private _scene;
  5720. private _emitter;
  5721. private _vertexBuffers;
  5722. private _indexBuffer;
  5723. private _effect;
  5724. private _positionX;
  5725. private _positionY;
  5726. private _isEnabled;
  5727. constructor(name: string, emitter: any, scene: Scene);
  5728. isEnabled: boolean;
  5729. getScene(): Scene;
  5730. getEmitter(): any;
  5731. setEmitter(newEmitter: any): void;
  5732. getEmitterPosition(): Vector3;
  5733. computeEffectivePosition(globalViewport: Viewport): boolean;
  5734. _isVisible(): boolean;
  5735. render(): boolean;
  5736. dispose(): void;
  5737. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  5738. serialize(): any;
  5739. }
  5740. }
  5741. declare module BABYLON {
  5742. class DirectionalLight extends ShadowLight {
  5743. private _shadowFrustumSize;
  5744. /**
  5745. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  5746. */
  5747. /**
  5748. * Specifies a fix frustum size for the shadow generation.
  5749. */
  5750. shadowFrustumSize: number;
  5751. private _shadowOrthoScale;
  5752. shadowOrthoScale: number;
  5753. autoUpdateExtends: boolean;
  5754. private _orthoLeft;
  5755. private _orthoRight;
  5756. private _orthoTop;
  5757. private _orthoBottom;
  5758. /**
  5759. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  5760. * The directional light is emitted from everywhere in the given direction.
  5761. * It can cast shawdows.
  5762. * Documentation : http://doc.babylonjs.com/tutorials/lights
  5763. */
  5764. constructor(name: string, direction: Vector3, scene: Scene);
  5765. /**
  5766. * Returns the string "DirectionalLight".
  5767. */
  5768. getClassName(): string;
  5769. /**
  5770. * Returns the integer 1.
  5771. */
  5772. getTypeID(): number;
  5773. /**
  5774. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  5775. * Returns the DirectionalLight Shadow projection matrix.
  5776. */
  5777. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5778. /**
  5779. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  5780. * Returns the DirectionalLight Shadow projection matrix.
  5781. */
  5782. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix): void;
  5783. /**
  5784. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  5785. * Returns the DirectionalLight Shadow projection matrix.
  5786. */
  5787. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  5788. protected _buildUniformLayout(): void;
  5789. /**
  5790. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  5791. * Returns the DirectionalLight.
  5792. */
  5793. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  5794. /**
  5795. * Gets the minZ used for shadow according to both the scene and the light.
  5796. *
  5797. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  5798. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  5799. * @param activeCamera
  5800. */
  5801. getDepthMinZ(activeCamera: Camera): number;
  5802. /**
  5803. * Gets the maxZ used for shadow according to both the scene and the light.
  5804. *
  5805. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  5806. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  5807. * @param activeCamera
  5808. */
  5809. getDepthMaxZ(activeCamera: Camera): number;
  5810. }
  5811. }
  5812. declare module BABYLON {
  5813. class HemisphericLight extends Light {
  5814. groundColor: Color3;
  5815. direction: Vector3;
  5816. private _worldMatrix;
  5817. /**
  5818. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  5819. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  5820. * The HemisphericLight can't cast shadows.
  5821. * Documentation : http://doc.babylonjs.com/tutorials/lights
  5822. */
  5823. constructor(name: string, direction: Vector3, scene: Scene);
  5824. protected _buildUniformLayout(): void;
  5825. /**
  5826. * Returns the string "HemisphericLight".
  5827. */
  5828. getClassName(): string;
  5829. /**
  5830. * Sets the HemisphericLight direction towards the passed target (Vector3).
  5831. * Returns the updated direction.
  5832. */
  5833. setDirectionToTarget(target: Vector3): Vector3;
  5834. getShadowGenerator(): Nullable<ShadowGenerator>;
  5835. /**
  5836. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  5837. * Returns the HemisphericLight.
  5838. */
  5839. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  5840. _getWorldMatrix(): Matrix;
  5841. /**
  5842. * Returns the integer 3.
  5843. */
  5844. getTypeID(): number;
  5845. }
  5846. }
  5847. declare module BABYLON {
  5848. class Light extends Node {
  5849. private static _LIGHTMAP_DEFAULT;
  5850. private static _LIGHTMAP_SPECULAR;
  5851. private static _LIGHTMAP_SHADOWSONLY;
  5852. /**
  5853. * If every light affecting the material is in this lightmapMode,
  5854. * material.lightmapTexture adds or multiplies
  5855. * (depends on material.useLightmapAsShadowmap)
  5856. * after every other light calculations.
  5857. */
  5858. static readonly LIGHTMAP_DEFAULT: number;
  5859. /**
  5860. * material.lightmapTexture as only diffuse lighting from this light
  5861. * adds only specular lighting from this light
  5862. * adds dynamic shadows
  5863. */
  5864. static readonly LIGHTMAP_SPECULAR: number;
  5865. /**
  5866. * material.lightmapTexture as only lighting
  5867. * no light calculation from this light
  5868. * only adds dynamic shadows from this light
  5869. */
  5870. static readonly LIGHTMAP_SHADOWSONLY: number;
  5871. private static _INTENSITYMODE_AUTOMATIC;
  5872. private static _INTENSITYMODE_LUMINOUSPOWER;
  5873. private static _INTENSITYMODE_LUMINOUSINTENSITY;
  5874. private static _INTENSITYMODE_ILLUMINANCE;
  5875. private static _INTENSITYMODE_LUMINANCE;
  5876. /**
  5877. * Each light type uses the default quantity according to its type:
  5878. * point/spot lights use luminous intensity
  5879. * directional lights use illuminance
  5880. */
  5881. static readonly INTENSITYMODE_AUTOMATIC: number;
  5882. /**
  5883. * lumen (lm)
  5884. */
  5885. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  5886. /**
  5887. * candela (lm/sr)
  5888. */
  5889. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  5890. /**
  5891. * lux (lm/m^2)
  5892. */
  5893. static readonly INTENSITYMODE_ILLUMINANCE: number;
  5894. /**
  5895. * nit (cd/m^2)
  5896. */
  5897. static readonly INTENSITYMODE_LUMINANCE: number;
  5898. private static _LIGHTTYPEID_POINTLIGHT;
  5899. private static _LIGHTTYPEID_DIRECTIONALLIGHT;
  5900. private static _LIGHTTYPEID_SPOTLIGHT;
  5901. private static _LIGHTTYPEID_HEMISPHERICLIGHT;
  5902. /**
  5903. * Light type const id of the point light.
  5904. */
  5905. static readonly LIGHTTYPEID_POINTLIGHT: number;
  5906. /**
  5907. * Light type const id of the directional light.
  5908. */
  5909. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  5910. /**
  5911. * Light type const id of the spot light.
  5912. */
  5913. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  5914. /**
  5915. * Light type const id of the hemispheric light.
  5916. */
  5917. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  5918. diffuse: Color3;
  5919. specular: Color3;
  5920. intensity: number;
  5921. range: number;
  5922. /**
  5923. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  5924. * of light.
  5925. */
  5926. private _photometricScale;
  5927. private _intensityMode;
  5928. /**
  5929. * Gets the photometric scale used to interpret the intensity.
  5930. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  5931. */
  5932. /**
  5933. * Sets the photometric scale used to interpret the intensity.
  5934. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  5935. */
  5936. intensityMode: number;
  5937. private _radius;
  5938. /**
  5939. * Gets the light radius used by PBR Materials to simulate soft area lights.
  5940. */
  5941. /**
  5942. * sets the light radius used by PBR Materials to simulate soft area lights.
  5943. */
  5944. radius: number;
  5945. /**
  5946. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  5947. * exceeding the number allowed of the materials.
  5948. */
  5949. private _renderPriority;
  5950. renderPriority: number;
  5951. /**
  5952. * Defines wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  5953. * the current shadow generator.
  5954. */
  5955. shadowEnabled: boolean;
  5956. private _includedOnlyMeshes;
  5957. includedOnlyMeshes: AbstractMesh[];
  5958. private _excludedMeshes;
  5959. excludedMeshes: AbstractMesh[];
  5960. private _excludeWithLayerMask;
  5961. excludeWithLayerMask: number;
  5962. private _includeOnlyWithLayerMask;
  5963. includeOnlyWithLayerMask: number;
  5964. private _lightmapMode;
  5965. lightmapMode: number;
  5966. private _parentedWorldMatrix;
  5967. _shadowGenerator: Nullable<IShadowGenerator>;
  5968. _excludedMeshesIds: string[];
  5969. _includedOnlyMeshesIds: string[];
  5970. _uniformBuffer: UniformBuffer;
  5971. /**
  5972. * Creates a Light object in the scene.
  5973. * Documentation : http://doc.babylonjs.com/tutorials/lights
  5974. */
  5975. constructor(name: string, scene: Scene);
  5976. protected _buildUniformLayout(): void;
  5977. /**
  5978. * Returns the string "Light".
  5979. */
  5980. getClassName(): string;
  5981. /**
  5982. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  5983. */
  5984. toString(fullDetails?: boolean): string;
  5985. /**
  5986. * Set the enabled state of this node.
  5987. * @param {boolean} value - the new enabled state
  5988. * @see isEnabled
  5989. */
  5990. setEnabled(value: boolean): void;
  5991. /**
  5992. * Returns the Light associated shadow generator.
  5993. */
  5994. getShadowGenerator(): Nullable<IShadowGenerator>;
  5995. /**
  5996. * Returns a Vector3, the absolute light position in the World.
  5997. */
  5998. getAbsolutePosition(): Vector3;
  5999. transferToEffect(effect: Effect, lightIndex: string): void;
  6000. _getWorldMatrix(): Matrix;
  6001. /**
  6002. * Boolean : True if the light will affect the passed mesh.
  6003. */
  6004. canAffectMesh(mesh: AbstractMesh): boolean;
  6005. /**
  6006. * Returns the light World matrix.
  6007. */
  6008. getWorldMatrix(): Matrix;
  6009. /**
  6010. * Sort function to order lights for rendering.
  6011. * @param a First Light object to compare to second.
  6012. * @param b Second Light object to compare first.
  6013. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  6014. */
  6015. static compareLightsPriority(a: Light, b: Light): number;
  6016. /**
  6017. * Disposes the light.
  6018. */
  6019. dispose(): void;
  6020. /**
  6021. * Returns the light type ID (integer).
  6022. */
  6023. getTypeID(): number;
  6024. /**
  6025. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  6026. */
  6027. getScaledIntensity(): number;
  6028. /**
  6029. * Returns a new Light object, named "name", from the current one.
  6030. */
  6031. clone(name: string): Nullable<Light>;
  6032. /**
  6033. * Serializes the current light into a Serialization object.
  6034. * Returns the serialized object.
  6035. */
  6036. serialize(): any;
  6037. /**
  6038. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  6039. * This new light is named "name" and added to the passed scene.
  6040. */
  6041. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  6042. /**
  6043. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  6044. */
  6045. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  6046. private _hookArrayForExcluded(array);
  6047. private _hookArrayForIncludedOnly(array);
  6048. private _resyncMeshes();
  6049. _markMeshesAsLightDirty(): void;
  6050. /**
  6051. * Recomputes the cached photometric scale if needed.
  6052. */
  6053. private _computePhotometricScale();
  6054. /**
  6055. * Returns the Photometric Scale according to the light type and intensity mode.
  6056. */
  6057. private _getPhotometricScale();
  6058. _reorderLightsInScene(): void;
  6059. }
  6060. }
  6061. declare module BABYLON {
  6062. class PointLight extends ShadowLight {
  6063. private _shadowAngle;
  6064. /**
  6065. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6066. * This specifies what angle the shadow will use to be created.
  6067. *
  6068. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  6069. */
  6070. /**
  6071. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6072. * This specifies what angle the shadow will use to be created.
  6073. *
  6074. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  6075. */
  6076. shadowAngle: number;
  6077. /**
  6078. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  6079. */
  6080. direction: Vector3;
  6081. /**
  6082. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  6083. * A PointLight emits the light in every direction.
  6084. * It can cast shadows.
  6085. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  6086. * ```javascript
  6087. * var pointLight = new BABYLON.PointLight("pl", camera.position, scene);
  6088. * ```
  6089. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6090. */
  6091. constructor(name: string, position: Vector3, scene: Scene);
  6092. /**
  6093. * Returns the string "PointLight"
  6094. */
  6095. getClassName(): string;
  6096. /**
  6097. * Returns the integer 0.
  6098. */
  6099. getTypeID(): number;
  6100. /**
  6101. * Specifies wether or not the shadowmap should be a cube texture.
  6102. */
  6103. needCube(): boolean;
  6104. /**
  6105. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  6106. */
  6107. getShadowDirection(faceIndex?: number): Vector3;
  6108. /**
  6109. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  6110. * - fov = PI / 2
  6111. * - aspect ratio : 1.0
  6112. * - z-near and far equal to the active camera minZ and maxZ.
  6113. * Returns the PointLight.
  6114. */
  6115. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6116. protected _buildUniformLayout(): void;
  6117. /**
  6118. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  6119. * Returns the PointLight.
  6120. */
  6121. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  6122. }
  6123. }
  6124. declare module BABYLON {
  6125. interface IShadowLight extends Light {
  6126. id: string;
  6127. position: Vector3;
  6128. direction: Vector3;
  6129. transformedPosition: Vector3;
  6130. transformedDirection: Vector3;
  6131. name: string;
  6132. shadowMinZ: number;
  6133. shadowMaxZ: number;
  6134. computeTransformedInformation(): boolean;
  6135. getScene(): Scene;
  6136. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  6137. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  6138. getDepthScale(): number;
  6139. needCube(): boolean;
  6140. needProjectionMatrixCompute(): boolean;
  6141. forceProjectionMatrixCompute(): void;
  6142. getShadowDirection(faceIndex?: number): Vector3;
  6143. /**
  6144. * Gets the minZ used for shadow according to both the scene and the light.
  6145. * @param activeCamera
  6146. */
  6147. getDepthMinZ(activeCamera: Camera): number;
  6148. /**
  6149. * Gets the minZ used for shadow according to both the scene and the light.
  6150. * @param activeCamera
  6151. */
  6152. getDepthMaxZ(activeCamera: Camera): number;
  6153. }
  6154. abstract class ShadowLight extends Light implements IShadowLight {
  6155. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6156. position: Vector3;
  6157. protected _direction: Vector3;
  6158. direction: Vector3;
  6159. private _shadowMinZ;
  6160. shadowMinZ: number;
  6161. private _shadowMaxZ;
  6162. shadowMaxZ: number;
  6163. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  6164. transformedPosition: Vector3;
  6165. transformedDirection: Vector3;
  6166. private _worldMatrix;
  6167. private _needProjectionMatrixCompute;
  6168. /**
  6169. * Computes the light transformed position/direction in case the light is parented. Returns true if parented, else false.
  6170. */
  6171. computeTransformedInformation(): boolean;
  6172. /**
  6173. * Return the depth scale used for the shadow map.
  6174. */
  6175. getDepthScale(): number;
  6176. /**
  6177. * Returns the light direction (Vector3) for any passed face index.
  6178. */
  6179. getShadowDirection(faceIndex?: number): Vector3;
  6180. /**
  6181. * Returns the ShadowLight absolute position in the World.
  6182. */
  6183. getAbsolutePosition(): Vector3;
  6184. /**
  6185. * Sets the ShadowLight direction toward the passed target (Vector3).
  6186. * Returns the updated ShadowLight direction (Vector3).
  6187. */
  6188. setDirectionToTarget(target: Vector3): Vector3;
  6189. /**
  6190. * Returns the light rotation (Vector3).
  6191. */
  6192. getRotation(): Vector3;
  6193. /**
  6194. * Boolean : false by default.
  6195. */
  6196. needCube(): boolean;
  6197. /**
  6198. * Specifies wether or not the projection matrix should be recomputed this frame.
  6199. */
  6200. needProjectionMatrixCompute(): boolean;
  6201. /**
  6202. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  6203. */
  6204. forceProjectionMatrixCompute(): void;
  6205. /**
  6206. * Get the world matrix of the sahdow lights.
  6207. */
  6208. _getWorldMatrix(): Matrix;
  6209. /**
  6210. * Gets the minZ used for shadow according to both the scene and the light.
  6211. * @param activeCamera
  6212. */
  6213. getDepthMinZ(activeCamera: Camera): number;
  6214. /**
  6215. * Gets the maxZ used for shadow according to both the scene and the light.
  6216. * @param activeCamera
  6217. */
  6218. getDepthMaxZ(activeCamera: Camera): number;
  6219. /**
  6220. * Sets the projection matrix according to the type of light and custom projection matrix definition.
  6221. * Returns the light.
  6222. */
  6223. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  6224. }
  6225. }
  6226. declare module BABYLON {
  6227. class SpotLight extends ShadowLight {
  6228. private _angle;
  6229. angle: number;
  6230. private _shadowAngleScale;
  6231. /**
  6232. * Allows scaling the angle of the light for shadow generation only.
  6233. */
  6234. shadowAngleScale: number;
  6235. exponent: number;
  6236. /**
  6237. * Creates a SpotLight object in the scene with the passed parameters :
  6238. * - `position` (Vector3) is the initial SpotLight position,
  6239. * - `direction` (Vector3) is the initial SpotLight direction,
  6240. * - `angle` (float, in radians) is the spot light cone angle,
  6241. * - `exponent` (float) is the light decay speed with the distance from the emission spot.
  6242. * A spot light is a simply light oriented cone.
  6243. * It can cast shadows.
  6244. * Documentation : http://doc.babylonjs.com/tutorials/lights
  6245. */
  6246. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  6247. /**
  6248. * Returns the string "SpotLight".
  6249. */
  6250. getClassName(): string;
  6251. /**
  6252. * Returns the integer 2.
  6253. */
  6254. getTypeID(): number;
  6255. /**
  6256. * 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.
  6257. * Returns the SpotLight.
  6258. */
  6259. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  6260. protected _buildUniformLayout(): void;
  6261. /**
  6262. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  6263. * Return the SpotLight.
  6264. */
  6265. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  6266. }
  6267. }
  6268. declare module BABYLON {
  6269. interface ILoadingScreen {
  6270. displayLoadingUI: () => void;
  6271. hideLoadingUI: () => void;
  6272. loadingUIBackgroundColor: string;
  6273. loadingUIText: string;
  6274. }
  6275. class DefaultLoadingScreen implements ILoadingScreen {
  6276. private _renderingCanvas;
  6277. private _loadingText;
  6278. private _loadingDivBackgroundColor;
  6279. private _loadingDiv;
  6280. private _loadingTextDiv;
  6281. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  6282. displayLoadingUI(): void;
  6283. hideLoadingUI(): void;
  6284. loadingUIText: string;
  6285. loadingUIBackgroundColor: string;
  6286. private _resizeLoadingUI;
  6287. }
  6288. }
  6289. declare module BABYLON {
  6290. class SceneLoaderProgressEvent {
  6291. readonly lengthComputable: boolean;
  6292. readonly loaded: number;
  6293. readonly total: number;
  6294. constructor(lengthComputable: boolean, loaded: number, total: number);
  6295. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  6296. }
  6297. interface ISceneLoaderPluginExtensions {
  6298. [extension: string]: {
  6299. isBinary: boolean;
  6300. };
  6301. }
  6302. interface ISceneLoaderPluginFactory {
  6303. name: string;
  6304. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  6305. canDirectLoad?: (data: string) => boolean;
  6306. }
  6307. interface ISceneLoaderPlugin {
  6308. name: string;
  6309. extensions: string | ISceneLoaderPluginExtensions;
  6310. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void) => boolean;
  6311. load: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => boolean;
  6312. canDirectLoad?: (data: string) => boolean;
  6313. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6314. loadAssets: (scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void) => Nullable<AssetContainer>;
  6315. }
  6316. interface ISceneLoaderPluginAsync {
  6317. name: string;
  6318. extensions: string | ISceneLoaderPluginExtensions;
  6319. importMeshAsync: (meshesNames: any, scene: Scene, data: any, rootUrl: string, onSuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  6320. loadAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: () => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  6321. canDirectLoad?: (data: string) => boolean;
  6322. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  6323. loadAssetsAsync: (scene: Scene, data: string, rootUrl: string, onSuccess?: (assets: Nullable<AssetContainer>) => void, onProgress?: (event: SceneLoaderProgressEvent) => void, onError?: (message: string, exception?: any) => void) => void;
  6324. }
  6325. class SceneLoader {
  6326. private static _ForceFullSceneLoadingForIncremental;
  6327. private static _ShowLoadingScreen;
  6328. private static _CleanBoneMatrixWeights;
  6329. static readonly NO_LOGGING: number;
  6330. static readonly MINIMAL_LOGGING: number;
  6331. static readonly SUMMARY_LOGGING: number;
  6332. static readonly DETAILED_LOGGING: number;
  6333. private static _loggingLevel;
  6334. static ForceFullSceneLoadingForIncremental: boolean;
  6335. static ShowLoadingScreen: boolean;
  6336. static loggingLevel: number;
  6337. static CleanBoneMatrixWeights: boolean;
  6338. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  6339. private static _registeredPlugins;
  6340. private static _getDefaultPlugin();
  6341. private static _getPluginForExtension(extension);
  6342. private static _getPluginForDirectLoad(data);
  6343. private static _getPluginForFilename(sceneFilename);
  6344. private static _getDirectLoad(sceneFilename);
  6345. private static _loadData(rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, onDispose, pluginExtension);
  6346. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  6347. static IsPluginForExtensionAvailable(extension: string): boolean;
  6348. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  6349. /**
  6350. * Import meshes into a scene
  6351. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  6352. * @param rootUrl a string that defines the root url for scene and resources
  6353. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6354. * @param scene the instance of BABYLON.Scene to append to
  6355. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  6356. * @param onProgress a callback with a progress event for each file being loaded
  6357. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6358. */
  6359. static ImportMesh(meshNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onSuccess?: Nullable<(meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, onError?: Nullable<(scene: Scene, message: string, exception?: any) => void>, pluginExtension?: Nullable<string>): Nullable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  6360. /**
  6361. * Load a scene
  6362. * @param rootUrl a string that defines the root url for scene and resources
  6363. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6364. * @param engine is the instance of BABYLON.Engine to use to create the scene
  6365. * @param onSuccess a callback with the scene when import succeeds
  6366. * @param onProgress a callback with a progress event for each file being loaded
  6367. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6368. */
  6369. static Load(rootUrl: string, sceneFilename: any, engine: 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>;
  6370. /**
  6371. * Append a scene
  6372. * @param rootUrl a string that defines the root url for scene and resources
  6373. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  6374. * @param scene is the instance of BABYLON.Scene to append to
  6375. * @param onSuccess a callback with the scene when import succeeds
  6376. * @param onProgress a callback with a progress event for each file being loaded
  6377. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  6378. */
  6379. static Append(rootUrl: string, sceneFilename: any, scene: 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>;
  6380. static LoadAssetContainer(rootUrl: string, sceneFilename: any, scene: 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>;
  6381. }
  6382. }
  6383. declare module BABYLON {
  6384. class Scalar {
  6385. /**
  6386. * Two pi constants convenient for computation.
  6387. */
  6388. static TwoPi: number;
  6389. /**
  6390. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  6391. */
  6392. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  6393. /**
  6394. * Returns a string : the upper case translation of the number i to hexadecimal.
  6395. */
  6396. static ToHex(i: number): string;
  6397. /**
  6398. * Returns -1 if value is negative and +1 is value is positive.
  6399. * Returns the value itself if it's equal to zero.
  6400. */
  6401. static Sign(value: number): number;
  6402. /**
  6403. * Returns the value itself if it's between min and max.
  6404. * Returns min if the value is lower than min.
  6405. * Returns max if the value is greater than max.
  6406. */
  6407. static Clamp(value: number, min?: number, max?: number): number;
  6408. /**
  6409. * Returns the log2 of value.
  6410. */
  6411. static Log2(value: number): number;
  6412. /**
  6413. * Loops the value, so that it is never larger than length and never smaller than 0.
  6414. *
  6415. * This is similar to the modulo operator but it works with floating point numbers.
  6416. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  6417. * With t = 5 and length = 2.5, the result would be 0.0.
  6418. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  6419. */
  6420. static Repeat(value: number, length: number): number;
  6421. /**
  6422. * Normalize the value between 0.0 and 1.0 using min and max values
  6423. */
  6424. static Normalize(value: number, min: number, max: number): number;
  6425. /**
  6426. * Denormalize the value from 0.0 and 1.0 using min and max values
  6427. */
  6428. static Denormalize(normalized: number, min: number, max: number): number;
  6429. /**
  6430. * Calculates the shortest difference between two given angles given in degrees.
  6431. */
  6432. static DeltaAngle(current: number, target: number): number;
  6433. /**
  6434. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  6435. *
  6436. * The returned value will move back and forth between 0 and length
  6437. */
  6438. static PingPong(tx: number, length: number): number;
  6439. /**
  6440. * Interpolates between min and max with smoothing at the limits.
  6441. *
  6442. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  6443. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  6444. */
  6445. static SmoothStep(from: number, to: number, tx: number): number;
  6446. /**
  6447. * Moves a value current towards target.
  6448. *
  6449. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  6450. * Negative values of maxDelta pushes the value away from target.
  6451. */
  6452. static MoveTowards(current: number, target: number, maxDelta: number): number;
  6453. /**
  6454. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  6455. *
  6456. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  6457. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  6458. */
  6459. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  6460. /**
  6461. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  6462. */
  6463. static Lerp(start: number, end: number, amount: number): number;
  6464. /**
  6465. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  6466. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  6467. */
  6468. static LerpAngle(start: number, end: number, amount: number): number;
  6469. /**
  6470. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  6471. */
  6472. static InverseLerp(a: number, b: number, value: number): number;
  6473. /**
  6474. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  6475. */
  6476. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  6477. /**
  6478. * Returns a random float number between and min and max values
  6479. */
  6480. static RandomRange(min: number, max: number): number;
  6481. /**
  6482. * This function returns percentage of a number in a given range.
  6483. *
  6484. * RangeToPercent(40,20,60) will return 0.5 (50%)
  6485. * RangeToPercent(34,0,100) will return 0.34 (34%)
  6486. */
  6487. static RangeToPercent(number: number, min: number, max: number): number;
  6488. /**
  6489. * This function returns number that corresponds to the percentage in a given range.
  6490. *
  6491. * PercentToRange(0.34,0,100) will return 34.
  6492. */
  6493. static PercentToRange(percent: number, min: number, max: number): number;
  6494. /**
  6495. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  6496. * @param angle The angle to normalize in radian.
  6497. * @return The converted angle.
  6498. */
  6499. static NormalizeRadians(angle: number): number;
  6500. }
  6501. }
  6502. declare module BABYLON {
  6503. const ToGammaSpace: number;
  6504. const ToLinearSpace = 2.2;
  6505. const Epsilon = 0.001;
  6506. class Color3 {
  6507. r: number;
  6508. g: number;
  6509. b: number;
  6510. /**
  6511. * Creates a new Color3 object from red, green, blue values, all between 0 and 1.
  6512. */
  6513. constructor(r?: number, g?: number, b?: number);
  6514. /**
  6515. * Returns a string with the Color3 current values.
  6516. */
  6517. toString(): string;
  6518. /**
  6519. * Returns the string "Color3".
  6520. */
  6521. getClassName(): string;
  6522. /**
  6523. * Returns the Color3 hash code.
  6524. */
  6525. getHashCode(): number;
  6526. /**
  6527. * Stores in the passed array from the passed starting index the red, green, blue values as successive elements.
  6528. * Returns the Color3.
  6529. */
  6530. toArray(array: FloatArray, index?: number): Color3;
  6531. /**
  6532. * Returns a new Color4 object from the current Color3 and the passed alpha.
  6533. */
  6534. toColor4(alpha?: number): Color4;
  6535. /**
  6536. * Returns a new array populated with 3 numeric elements : red, green and blue values.
  6537. */
  6538. asArray(): number[];
  6539. /**
  6540. * Returns the luminance value (float).
  6541. */
  6542. toLuminance(): number;
  6543. /**
  6544. * Multiply each Color3 rgb values by the passed Color3 rgb values in a new Color3 object.
  6545. * Returns this new object.
  6546. */
  6547. multiply(otherColor: Color3): Color3;
  6548. /**
  6549. * Multiply the rgb values of the Color3 and the passed Color3 and stores the result in the object "result".
  6550. * Returns the current Color3.
  6551. */
  6552. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  6553. /**
  6554. * Boolean : True if the rgb values are equal to the passed ones.
  6555. */
  6556. equals(otherColor: Color3): boolean;
  6557. /**
  6558. * Boolean : True if the rgb values are equal to the passed ones.
  6559. */
  6560. equalsFloats(r: number, g: number, b: number): boolean;
  6561. /**
  6562. * Multiplies in place each rgb value by scale.
  6563. * Returns the updated Color3.
  6564. */
  6565. scale(scale: number): Color3;
  6566. /**
  6567. * Multiplies the rgb values by scale and stores the result into "result".
  6568. * Returns the unmodified current Color3.
  6569. */
  6570. scaleToRef(scale: number, result: Color3): Color3;
  6571. /**
  6572. * Returns a new Color3 set with the added values of the current Color3 and of the passed one.
  6573. */
  6574. add(otherColor: Color3): Color3;
  6575. /**
  6576. * Stores the result of the addition of the current Color3 and passed one rgb values into "result".
  6577. * Returns the unmodified current Color3.
  6578. */
  6579. addToRef(otherColor: Color3, result: Color3): Color3;
  6580. /**
  6581. * Returns a new Color3 set with the subtracted values of the passed one from the current Color3 .
  6582. */
  6583. subtract(otherColor: Color3): Color3;
  6584. /**
  6585. * Stores the result of the subtraction of passed one from the current Color3 rgb values into "result".
  6586. * Returns the unmodified current Color3.
  6587. */
  6588. subtractToRef(otherColor: Color3, result: Color3): Color3;
  6589. /**
  6590. * Returns a new Color3 copied the current one.
  6591. */
  6592. clone(): Color3;
  6593. /**
  6594. * Copies the rgb values from the source in the current Color3.
  6595. * Returns the updated Color3.
  6596. */
  6597. copyFrom(source: Color3): Color3;
  6598. /**
  6599. * Updates the Color3 rgb values from the passed floats.
  6600. * Returns the Color3.
  6601. */
  6602. copyFromFloats(r: number, g: number, b: number): Color3;
  6603. /**
  6604. * Updates the Color3 rgb values from the passed floats.
  6605. * Returns the Color3.
  6606. */
  6607. set(r: number, g: number, b: number): Color3;
  6608. /**
  6609. * Returns the Color3 hexadecimal code as a string.
  6610. */
  6611. toHexString(): string;
  6612. /**
  6613. * Returns a new Color3 converted to linear space.
  6614. */
  6615. toLinearSpace(): Color3;
  6616. /**
  6617. * Converts the Color3 values to linear space and stores the result in "convertedColor".
  6618. * Returns the unmodified Color3.
  6619. */
  6620. toLinearSpaceToRef(convertedColor: Color3): Color3;
  6621. /**
  6622. * Returns a new Color3 converted to gamma space.
  6623. */
  6624. toGammaSpace(): Color3;
  6625. /**
  6626. * Converts the Color3 values to gamma space and stores the result in "convertedColor".
  6627. * Returns the unmodified Color3.
  6628. */
  6629. toGammaSpaceToRef(convertedColor: Color3): Color3;
  6630. /**
  6631. * Creates a new Color3 from the string containing valid hexadecimal values.
  6632. */
  6633. static FromHexString(hex: string): Color3;
  6634. /**
  6635. * Creates a new Vector3 from the startind index of the passed array.
  6636. */
  6637. static FromArray(array: ArrayLike<number>, offset?: number): Color3;
  6638. /**
  6639. * Creates a new Color3 from integer values ( < 256).
  6640. */
  6641. static FromInts(r: number, g: number, b: number): Color3;
  6642. /**
  6643. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3.
  6644. */
  6645. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  6646. static Red(): Color3;
  6647. static Green(): Color3;
  6648. static Blue(): Color3;
  6649. static Black(): Color3;
  6650. static White(): Color3;
  6651. static Purple(): Color3;
  6652. static Magenta(): Color3;
  6653. static Yellow(): Color3;
  6654. static Gray(): Color3;
  6655. static Teal(): Color3;
  6656. static Random(): Color3;
  6657. }
  6658. class Color4 {
  6659. r: number;
  6660. g: number;
  6661. b: number;
  6662. a: number;
  6663. /**
  6664. * Creates a new Color4 object from the passed float values ( < 1) : red, green, blue, alpha.
  6665. */
  6666. constructor(r?: number, g?: number, b?: number, a?: number);
  6667. /**
  6668. * Adds in place the passed Color4 values to the current Color4.
  6669. * Returns the updated Color4.
  6670. */
  6671. addInPlace(right: Color4): Color4;
  6672. /**
  6673. * Returns a new array populated with 4 numeric elements : red, green, blue, alpha values.
  6674. */
  6675. asArray(): number[];
  6676. /**
  6677. * Stores from the starting index in the passed array the Color4 successive values.
  6678. * Returns the Color4.
  6679. */
  6680. toArray(array: number[], index?: number): Color4;
  6681. /**
  6682. * Returns a new Color4 set with the added values of the current Color4 and of the passed one.
  6683. */
  6684. add(right: Color4): Color4;
  6685. /**
  6686. * Returns a new Color4 set with the subtracted values of the passed one from the current Color4.
  6687. */
  6688. subtract(right: Color4): Color4;
  6689. /**
  6690. * Subtracts the passed ones from the current Color4 values and stores the results in "result".
  6691. * Returns the Color4.
  6692. */
  6693. subtractToRef(right: Color4, result: Color4): Color4;
  6694. /**
  6695. * Creates a new Color4 with the current Color4 values multiplied by scale.
  6696. */
  6697. scale(scale: number): Color4;
  6698. /**
  6699. * Multiplies the current Color4 values by scale and stores the result in "result".
  6700. * Returns the Color4.
  6701. */
  6702. scaleToRef(scale: number, result: Color4): Color4;
  6703. /**
  6704. * Multipy an RGBA Color4 value by another and return a new Color4 object
  6705. * @param color The Color4 (RGBA) value to multiply by
  6706. * @returns A new Color4.
  6707. */
  6708. multiply(color: Color4): Color4;
  6709. /**
  6710. * Multipy an RGBA Color4 value by another and push the result in a reference value
  6711. * @param color The Color4 (RGBA) value to multiply by
  6712. * @param result The Color4 (RGBA) to fill the result in
  6713. * @returns the result Color4.
  6714. */
  6715. multiplyToRef(color: Color4, result: Color4): Color4;
  6716. /**
  6717. * Returns a string with the Color4 values.
  6718. */
  6719. toString(): string;
  6720. /**
  6721. * Returns the string "Color4"
  6722. */
  6723. getClassName(): string;
  6724. /**
  6725. * Return the Color4 hash code as a number.
  6726. */
  6727. getHashCode(): number;
  6728. /**
  6729. * Creates a new Color4 copied from the current one.
  6730. */
  6731. clone(): Color4;
  6732. /**
  6733. * Copies the passed Color4 values into the current one.
  6734. * Returns the updated Color4.
  6735. */
  6736. copyFrom(source: Color4): Color4;
  6737. /**
  6738. * Copies the passed float values into the current one.
  6739. * Returns the updated Color4.
  6740. */
  6741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6742. /**
  6743. * Copies the passed float values into the current one.
  6744. * Returns the updated Color4.
  6745. */
  6746. set(r: number, g: number, b: number, a: number): Color4;
  6747. /**
  6748. * Returns a string containing the hexadecimal Color4 code.
  6749. */
  6750. toHexString(): string;
  6751. /**
  6752. * Returns a new Color4 converted to linear space.
  6753. */
  6754. toLinearSpace(): Color4;
  6755. /**
  6756. * Converts the Color4 values to linear space and stores the result in "convertedColor".
  6757. * Returns the unmodified Color4.
  6758. */
  6759. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6760. /**
  6761. * Returns a new Color4 converted to gamma space.
  6762. */
  6763. toGammaSpace(): Color4;
  6764. /**
  6765. * Converts the Color4 values to gamma space and stores the result in "convertedColor".
  6766. * Returns the unmodified Color4.
  6767. */
  6768. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6769. /**
  6770. * Creates a new Color4 from the valid hexadecimal value contained in the passed string.
  6771. */
  6772. static FromHexString(hex: string): Color4;
  6773. /**
  6774. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 and the right Color4.
  6775. */
  6776. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  6777. /**
  6778. * Set the passed "result" with the linearly interpolated values of "amount" between the left Color4 and the right Color4.
  6779. */
  6780. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  6781. /**
  6782. * Creates a new Color4 from the starting index element of the passed array.
  6783. */
  6784. static FromArray(array: ArrayLike<number>, offset?: number): Color4;
  6785. /**
  6786. * Creates a new Color4 from the passed integers ( < 256 ).
  6787. */
  6788. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6789. static CheckColors4(colors: number[], count: number): number[];
  6790. }
  6791. class Vector2 {
  6792. x: number;
  6793. y: number;
  6794. /**
  6795. * Creates a new Vector2 from the passed x and y coordinates.
  6796. */
  6797. constructor(x: number, y: number);
  6798. /**
  6799. * Returns a string with the Vector2 coordinates.
  6800. */
  6801. toString(): string;
  6802. /**
  6803. * Returns the string "Vector2"
  6804. */
  6805. getClassName(): string;
  6806. /**
  6807. * Returns the Vector2 hash code as a number.
  6808. */
  6809. getHashCode(): number;
  6810. /**
  6811. * Sets the Vector2 coordinates in the passed array or Float32Array from the passed index.
  6812. * Returns the Vector2.
  6813. */
  6814. toArray(array: FloatArray, index?: number): Vector2;
  6815. /**
  6816. * Returns a new array with 2 elements : the Vector2 coordinates.
  6817. */
  6818. asArray(): number[];
  6819. /**
  6820. * Sets the Vector2 coordinates with the passed Vector2 coordinates.
  6821. * Returns the updated Vector2.
  6822. */
  6823. copyFrom(source: Vector2): Vector2;
  6824. /**
  6825. * Sets the Vector2 coordinates with the passed floats.
  6826. * Returns the updated Vector2.
  6827. */
  6828. copyFromFloats(x: number, y: number): Vector2;
  6829. /**
  6830. * Sets the Vector2 coordinates with the passed floats.
  6831. * Returns the updated Vector2.
  6832. */
  6833. set(x: number, y: number): Vector2;
  6834. /**
  6835. * Returns a new Vector2 set with the addition of the current Vector2 and the passed one coordinates.
  6836. */
  6837. add(otherVector: Vector2): Vector2;
  6838. /**
  6839. * Sets the "result" coordinates with the addition of the current Vector2 and the passed one coordinates.
  6840. * Returns the Vector2.
  6841. */
  6842. addToRef(otherVector: Vector2, result: Vector2): Vector2;
  6843. /**
  6844. * Set the Vector2 coordinates by adding the passed Vector2 coordinates.
  6845. * Returns the updated Vector2.
  6846. */
  6847. addInPlace(otherVector: Vector2): Vector2;
  6848. /**
  6849. * Returns a new Vector2 by adding the current Vector2 coordinates to the passed Vector3 x, y coordinates.
  6850. */
  6851. addVector3(otherVector: Vector3): Vector2;
  6852. /**
  6853. * Returns a new Vector2 set with the subtracted coordinates of the passed one from the current Vector2.
  6854. */
  6855. subtract(otherVector: Vector2): Vector2;
  6856. /**
  6857. * Sets the "result" coordinates with the subtraction of the passed one from the current Vector2 coordinates.
  6858. * Returns the Vector2.
  6859. */
  6860. subtractToRef(otherVector: Vector2, result: Vector2): Vector2;
  6861. /**
  6862. * Sets the current Vector2 coordinates by subtracting from it the passed one coordinates.
  6863. * Returns the updated Vector2.
  6864. */
  6865. subtractInPlace(otherVector: Vector2): Vector2;
  6866. /**
  6867. * Multiplies in place the current Vector2 coordinates by the passed ones.
  6868. * Returns the updated Vector2.
  6869. */
  6870. multiplyInPlace(otherVector: Vector2): Vector2;
  6871. /**
  6872. * Returns a new Vector2 set with the multiplication of the current Vector2 and the passed one coordinates.
  6873. */
  6874. multiply(otherVector: Vector2): Vector2;
  6875. /**
  6876. * Sets "result" coordinates with the multiplication of the current Vector2 and the passed one coordinates.
  6877. * Returns the Vector2.
  6878. */
  6879. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  6880. /**
  6881. * Returns a new Vector2 set with the Vector2 coordinates multiplied by the passed floats.
  6882. */
  6883. multiplyByFloats(x: number, y: number): Vector2;
  6884. /**
  6885. * Returns a new Vector2 set with the Vector2 coordinates divided by the passed one coordinates.
  6886. */
  6887. divide(otherVector: Vector2): Vector2;
  6888. /**
  6889. * Sets the "result" coordinates with the Vector2 divided by the passed one coordinates.
  6890. * Returns the Vector2.
  6891. */
  6892. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  6893. /**
  6894. * Divides the current Vector3 coordinates by the passed ones.
  6895. * Returns the updated Vector3.
  6896. */
  6897. divideInPlace(otherVector: Vector2): Vector2;
  6898. /**
  6899. * Returns a new Vector2 with current Vector2 negated coordinates.
  6900. */
  6901. negate(): Vector2;
  6902. /**
  6903. * Multiply the Vector2 coordinates by scale.
  6904. * Returns the updated Vector2.
  6905. */
  6906. scaleInPlace(scale: number): Vector2;
  6907. /**
  6908. * Returns a new Vector2 scaled by "scale" from the current Vector2.
  6909. */
  6910. scale(scale: number): Vector2;
  6911. /**
  6912. * Boolean : True if the passed vector coordinates strictly equal the current Vector2 ones.
  6913. */
  6914. equals(otherVector: Vector2): boolean;
  6915. /**
  6916. * Boolean : True if the passed vector coordinates are close to the current ones by a distance of epsilon.
  6917. */
  6918. equalsWithEpsilon(otherVector: Vector2, epsilon?: number): boolean;
  6919. /**
  6920. * Returns the vector length (float).
  6921. */
  6922. length(): number;
  6923. /**
  6924. * Returns the vector squared length (float);
  6925. */
  6926. lengthSquared(): number;
  6927. /**
  6928. * Normalize the vector.
  6929. * Returns the updated Vector2.
  6930. */
  6931. normalize(): Vector2;
  6932. /**
  6933. * Returns a new Vector2 copied from the Vector2.
  6934. */
  6935. clone(): Vector2;
  6936. /**
  6937. * Returns a new Vector2(0, 0)
  6938. */
  6939. static Zero(): Vector2;
  6940. /**
  6941. * Returns a new Vector2(1, 1)
  6942. */
  6943. static One(): Vector2;
  6944. /**
  6945. * Returns a new Vector2 set from the passed index element of the passed array.
  6946. */
  6947. static FromArray(array: ArrayLike<number>, offset?: number): Vector2;
  6948. /**
  6949. * Sets "result" from the passed index element of the passed array.
  6950. */
  6951. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector2): void;
  6952. /**
  6953. * Retuns a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the passed four Vector2.
  6954. */
  6955. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  6956. /**
  6957. * 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".
  6958. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  6959. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate.
  6960. */
  6961. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  6962. /**
  6963. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2".
  6964. */
  6965. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  6966. /**
  6967. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  6968. */
  6969. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  6970. /**
  6971. * Returns the dot product (float) of the vector "left" and the vector "right".
  6972. */
  6973. static Dot(left: Vector2, right: Vector2): number;
  6974. /**
  6975. * Returns a new Vector2 equal to the normalized passed vector.
  6976. */
  6977. static Normalize(vector: Vector2): Vector2;
  6978. /**
  6979. * Returns a new Vecto2 set with the minimal coordinate values from the "left" and "right" vectors.
  6980. */
  6981. static Minimize(left: Vector2, right: Vector2): Vector2;
  6982. /**
  6983. * Returns a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors.
  6984. */
  6985. static Maximize(left: Vector2, right: Vector2): Vector2;
  6986. /**
  6987. * Returns a new Vecto2 set with the transformed coordinates of the passed vector by the passed transformation matrix.
  6988. */
  6989. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  6990. /**
  6991. * Transforms the passed vector coordinates by the passed transformation matrix and stores the result in the vector "result" coordinates.
  6992. */
  6993. static TransformToRef(vector: Vector2, transformation: Matrix, result: Vector2): void;
  6994. /**
  6995. * Boolean : True if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  6996. */
  6997. static PointInTriangle(p: Vector2, p0: Vector2, p1: Vector2, p2: Vector2): boolean;
  6998. /**
  6999. * Returns the distance (float) between the vectors "value1" and "value2".
  7000. */
  7001. static Distance(value1: Vector2, value2: Vector2): number;
  7002. /**
  7003. * Returns the squared distance (float) between the vectors "value1" and "value2".
  7004. */
  7005. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  7006. /**
  7007. * Returns a new Vecto2 located at the center of the vectors "value1" and "value2".
  7008. */
  7009. static Center(value1: Vector2, value2: Vector2): Vector2;
  7010. /**
  7011. * Returns the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  7012. */
  7013. static DistanceOfPointFromSegment(p: Vector2, segA: Vector2, segB: Vector2): number;
  7014. }
  7015. class Vector3 {
  7016. x: number;
  7017. y: number;
  7018. z: number;
  7019. /**
  7020. * Creates a new Vector3 object from the passed x, y, z (floats) coordinates.
  7021. * A Vector3 is the main object used in 3D geometry.
  7022. * It can represent etiher the coordinates of a point the space, either a direction.
  7023. */
  7024. constructor(x: number, y: number, z: number);
  7025. /**
  7026. * Returns a string with the Vector3 coordinates.
  7027. */
  7028. toString(): string;
  7029. /**
  7030. * Returns the string "Vector3"
  7031. */
  7032. getClassName(): string;
  7033. /**
  7034. * Returns the Vector hash code.
  7035. */
  7036. getHashCode(): number;
  7037. /**
  7038. * Returns a new array with three elements : the coordinates the Vector3.
  7039. */
  7040. asArray(): number[];
  7041. /**
  7042. * Populates the passed array or Float32Array from the passed index with the successive coordinates of the Vector3.
  7043. * Returns the Vector3.
  7044. */
  7045. toArray(array: FloatArray, index?: number): Vector3;
  7046. /**
  7047. * Returns a new Quaternion object, computed from the Vector3 coordinates.
  7048. */
  7049. toQuaternion(): Quaternion;
  7050. /**
  7051. * Adds the passed vector to the current Vector3.
  7052. * Returns the updated Vector3.
  7053. */
  7054. addInPlace(otherVector: Vector3): Vector3;
  7055. /**
  7056. * Returns a new Vector3, result of the addition the current Vector3 and the passed vector.
  7057. */
  7058. add(otherVector: Vector3): Vector3;
  7059. /**
  7060. * Adds the current Vector3 to the passed one and stores the result in the vector "result".
  7061. * Returns the current Vector3.
  7062. */
  7063. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  7064. /**
  7065. * Subtract the passed vector from the current Vector3.
  7066. * Returns the updated Vector3.
  7067. */
  7068. subtractInPlace(otherVector: Vector3): Vector3;
  7069. /**
  7070. * Returns a new Vector3, result of the subtraction of the passed vector from the current Vector3.
  7071. */
  7072. subtract(otherVector: Vector3): Vector3;
  7073. /**
  7074. * Subtracts the passed vector from the current Vector3 and stores the result in the vector "result".
  7075. * Returns the current Vector3.
  7076. */
  7077. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  7078. /**
  7079. * Returns a new Vector3 set with the subtraction of the passed floats from the current Vector3 coordinates.
  7080. */
  7081. subtractFromFloats(x: number, y: number, z: number): Vector3;
  7082. /**
  7083. * Subtracts the passed floats from the current Vector3 coordinates and set the passed vector "result" with this result.
  7084. * Returns the current Vector3.
  7085. */
  7086. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  7087. /**
  7088. * Returns a new Vector3 set with the current Vector3 negated coordinates.
  7089. */
  7090. negate(): Vector3;
  7091. /**
  7092. * Multiplies the Vector3 coordinates by the float "scale".
  7093. * Returns the updated Vector3.
  7094. */
  7095. scaleInPlace(scale: number): Vector3;
  7096. /**
  7097. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale".
  7098. */
  7099. scale(scale: number): Vector3;
  7100. /**
  7101. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the passed vector "result" coordinates.
  7102. * Returns the current Vector3.
  7103. */
  7104. scaleToRef(scale: number, result: Vector3): Vector3;
  7105. /**
  7106. * Boolean : True if the current Vector3 and the passed vector coordinates are strictly equal.
  7107. */
  7108. equals(otherVector: Vector3): boolean;
  7109. /**
  7110. * Boolean : True if the current Vector3 and the passed vector coordinates are distant less than epsilon.
  7111. */
  7112. equalsWithEpsilon(otherVector: Vector3, epsilon?: number): boolean;
  7113. /**
  7114. * Boolean : True if the current Vector3 coordinate equal the passed floats.
  7115. */
  7116. equalsToFloats(x: number, y: number, z: number): boolean;
  7117. /**
  7118. * Muliplies the current Vector3 coordinates by the passed ones.
  7119. * Returns the updated Vector3.
  7120. */
  7121. multiplyInPlace(otherVector: Vector3): Vector3;
  7122. /**
  7123. * Returns a new Vector3, result of the multiplication of the current Vector3 by the passed vector.
  7124. */
  7125. multiply(otherVector: Vector3): Vector3;
  7126. /**
  7127. * Multiplies the current Vector3 by the passed one and stores the result in the passed vector "result".
  7128. * Returns the current Vector3.
  7129. */
  7130. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  7131. /**
  7132. * Returns a new Vector3 set witth the result of the mulliplication of the current Vector3 coordinates by the passed floats.
  7133. */
  7134. multiplyByFloats(x: number, y: number, z: number): Vector3;
  7135. /**
  7136. * Returns a new Vector3 set witth the result of the division of the current Vector3 coordinates by the passed ones.
  7137. */
  7138. divide(otherVector: Vector3): Vector3;
  7139. /**
  7140. * Divides the current Vector3 coordinates by the passed ones and stores the result in the passed vector "result".
  7141. * Returns the current Vector3.
  7142. */
  7143. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  7144. /**
  7145. * Divides the current Vector3 coordinates by the passed ones.
  7146. * Returns the updated Vector3.
  7147. */
  7148. divideInPlace(otherVector: Vector3): Vector3;
  7149. /**
  7150. * Updates the current Vector3 with the minimal coordinate values between its and the passed vector ones.
  7151. * Returns the updated Vector3.
  7152. */
  7153. MinimizeInPlace(other: Vector3): Vector3;
  7154. /**
  7155. * Updates the current Vector3 with the maximal coordinate values between its and the passed vector ones.
  7156. * Returns the updated Vector3.
  7157. */
  7158. MaximizeInPlace(other: Vector3): Vector3;
  7159. /**
  7160. * Return true is the vector is non uniform meaning x, y or z are not all the same.
  7161. */
  7162. readonly isNonUniform: boolean;
  7163. /**
  7164. * Returns the length of the Vector3 (float).
  7165. */
  7166. length(): number;
  7167. /**
  7168. * Returns the squared length of the Vector3 (float).
  7169. */
  7170. lengthSquared(): number;
  7171. /**
  7172. * Normalize the current Vector3.
  7173. * Returns the updated Vector3.
  7174. * /!\ In place operation.
  7175. */
  7176. normalize(): Vector3;
  7177. /**
  7178. * Normalize the current Vector3 to a new vector.
  7179. * @returns the new Vector3.
  7180. */
  7181. normalizeToNew(): Vector3;
  7182. /**
  7183. * Normalize the current Vector3 to the reference.
  7184. * @param the reference to update.
  7185. * @returns the updated Vector3.
  7186. */
  7187. normalizeToRef(reference: Vector3): Vector3;
  7188. /**
  7189. * Returns a new Vector3 copied from the current Vector3.
  7190. */
  7191. clone(): Vector3;
  7192. /**
  7193. * Copies the passed vector coordinates to the current Vector3 ones.
  7194. * Returns the updated Vector3.
  7195. */
  7196. copyFrom(source: Vector3): Vector3;
  7197. /**
  7198. * Copies the passed floats to the current Vector3 coordinates.
  7199. * Returns the updated Vector3.
  7200. */
  7201. copyFromFloats(x: number, y: number, z: number): Vector3;
  7202. /**
  7203. * Copies the passed floats to the current Vector3 coordinates.
  7204. * Returns the updated Vector3.
  7205. */
  7206. set(x: number, y: number, z: number): Vector3;
  7207. /**
  7208. *
  7209. */
  7210. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: number): number;
  7211. /**
  7212. * Returns a new Vector3 set from the index "offset" of the passed array.
  7213. */
  7214. static FromArray(array: ArrayLike<number>, offset?: number): Vector3;
  7215. /**
  7216. * Returns a new Vector3 set from the index "offset" of the passed Float32Array.
  7217. * This function is deprecated. Use FromArray instead.
  7218. */
  7219. static FromFloatArray(array: Float32Array, offset?: number): Vector3;
  7220. /**
  7221. * Sets the passed vector "result" with the element values from the index "offset" of the passed array.
  7222. */
  7223. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector3): void;
  7224. /**
  7225. * Sets the passed vector "result" with the element values from the index "offset" of the passed Float32Array.
  7226. * This function is deprecated. Use FromArrayToRef instead.
  7227. */
  7228. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  7229. /**
  7230. * Sets the passed vector "result" with the passed floats.
  7231. */
  7232. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  7233. /**
  7234. * Returns a new Vector3 set to (0.0, 0.0, 0.0).
  7235. */
  7236. static Zero(): Vector3;
  7237. /**
  7238. * Returns a new Vector3 set to (1.0, 1.0, 1.0).
  7239. */
  7240. static One(): Vector3;
  7241. /**
  7242. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  7243. */
  7244. static Up(): Vector3;
  7245. /**
  7246. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  7247. */
  7248. static Forward(): Vector3;
  7249. /**
  7250. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  7251. */
  7252. static Right(): Vector3;
  7253. /**
  7254. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  7255. */
  7256. static Left(): Vector3;
  7257. /**
  7258. * Returns a new Vector3 set with the result of the transformation by the passed matrix of the passed vector.
  7259. * This method computes tranformed coordinates only, not transformed direction vectors.
  7260. */
  7261. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  7262. /**
  7263. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed vector.
  7264. * This method computes tranformed coordinates only, not transformed direction vectors.
  7265. */
  7266. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  7267. /**
  7268. * Sets the passed vector "result" coordinates with the result of the transformation by the passed matrix of the passed floats (x, y, z).
  7269. * This method computes tranformed coordinates only, not transformed direction vectors.
  7270. */
  7271. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  7272. /**
  7273. * Returns a new Vector3 set with the result of the normal transformation by the passed matrix of the passed vector.
  7274. * This methods computes transformed normalized direction vectors only.
  7275. */
  7276. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  7277. /**
  7278. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  7279. * This methods computes transformed normalized direction vectors only.
  7280. */
  7281. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  7282. /**
  7283. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z).
  7284. * This methods computes transformed normalized direction vectors only.
  7285. */
  7286. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  7287. /**
  7288. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4".
  7289. */
  7290. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  7291. /**
  7292. * 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".
  7293. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one.
  7294. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one.
  7295. */
  7296. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  7297. /**
  7298. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  7299. */
  7300. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  7301. /**
  7302. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end".
  7303. */
  7304. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  7305. /**
  7306. * Sets the passed vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end".
  7307. */
  7308. static LerpToRef(start: Vector3, end: Vector3, amount: number, result: Vector3): void;
  7309. /**
  7310. * Returns the dot product (float) between the vectors "left" and "right".
  7311. */
  7312. static Dot(left: Vector3, right: Vector3): number;
  7313. /**
  7314. * Returns a new Vector3 as the cross product of the vectors "left" and "right".
  7315. * The cross product is then orthogonal to both "left" and "right".
  7316. */
  7317. static Cross(left: Vector3, right: Vector3): Vector3;
  7318. /**
  7319. * Sets the passed vector "result" with the cross product of "left" and "right".
  7320. * The cross product is then orthogonal to both "left" and "right".
  7321. */
  7322. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  7323. /**
  7324. * Returns a new Vector3 as the normalization of the passed vector.
  7325. */
  7326. static Normalize(vector: Vector3): Vector3;
  7327. /**
  7328. * Sets the passed vector "result" with the normalization of the passed first vector.
  7329. */
  7330. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  7331. private static _viewportMatrixCache;
  7332. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  7333. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  7334. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  7335. static UnprojectToRef(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  7336. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix, result: Vector3): void;
  7337. static Minimize(left: Vector3, right: Vector3): Vector3;
  7338. static Maximize(left: Vector3, right: Vector3): Vector3;
  7339. /**
  7340. * Returns the distance (float) between the vectors "value1" and "value2".
  7341. */
  7342. static Distance(value1: Vector3, value2: Vector3): number;
  7343. /**
  7344. * Returns the squared distance (float) between the vectors "value1" and "value2".
  7345. */
  7346. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  7347. /**
  7348. * Returns a new Vector3 located at the center between "value1" and "value2".
  7349. */
  7350. static Center(value1: Vector3, value2: Vector3): Vector3;
  7351. /**
  7352. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  7353. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  7354. * to something in order to rotate it from its local system to the given target system.
  7355. * Note : axis1, axis2 and axis3 are normalized during this operation.
  7356. * Returns a new Vector3.
  7357. */
  7358. static RotationFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3): Vector3;
  7359. /**
  7360. * The same than RotationFromAxis but updates the passed ref Vector3 parameter instead of returning a new Vector3.
  7361. */
  7362. static RotationFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Vector3): void;
  7363. }
  7364. class Vector4 {
  7365. x: number;
  7366. y: number;
  7367. z: number;
  7368. w: number;
  7369. /**
  7370. * Creates a Vector4 object from the passed floats.
  7371. */
  7372. constructor(x: number, y: number, z: number, w: number);
  7373. /**
  7374. * Returns the string with the Vector4 coordinates.
  7375. */
  7376. toString(): string;
  7377. /**
  7378. * Returns the string "Vector4".
  7379. */
  7380. getClassName(): string;
  7381. /**
  7382. * Returns the Vector4 hash code.
  7383. */
  7384. getHashCode(): number;
  7385. /**
  7386. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  7387. */
  7388. asArray(): number[];
  7389. /**
  7390. * Populates the passed array from the passed index with the Vector4 coordinates.
  7391. * Returns the Vector4.
  7392. */
  7393. toArray(array: FloatArray, index?: number): Vector4;
  7394. /**
  7395. * Adds the passed vector to the current Vector4.
  7396. * Returns the updated Vector4.
  7397. */
  7398. addInPlace(otherVector: Vector4): Vector4;
  7399. /**
  7400. * Returns a new Vector4 as the result of the addition of the current Vector4 and the passed one.
  7401. */
  7402. add(otherVector: Vector4): Vector4;
  7403. /**
  7404. * Updates the passed vector "result" with the result of the addition of the current Vector4 and the passed one.
  7405. * Returns the current Vector4.
  7406. */
  7407. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  7408. /**
  7409. * Subtract in place the passed vector from the current Vector4.
  7410. * Returns the updated Vector4.
  7411. */
  7412. subtractInPlace(otherVector: Vector4): Vector4;
  7413. /**
  7414. * Returns a new Vector4 with the result of the subtraction of the passed vector from the current Vector4.
  7415. */
  7416. subtract(otherVector: Vector4): Vector4;
  7417. /**
  7418. * Sets the passed vector "result" with the result of the subtraction of the passed vector from the current Vector4.
  7419. * Returns the current Vector4.
  7420. */
  7421. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  7422. /**
  7423. * Returns a new Vector4 set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  7424. */
  7425. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  7426. /**
  7427. * Sets the passed vector "result" set with the result of the subtraction of the passed floats from the current Vector4 coordinates.
  7428. * Returns the current Vector4.
  7429. */
  7430. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  7431. /**
  7432. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  7433. */
  7434. negate(): Vector4;
  7435. /**
  7436. * Multiplies the current Vector4 coordinates by scale (float).
  7437. * Returns the updated Vector4.
  7438. */
  7439. scaleInPlace(scale: number): Vector4;
  7440. /**
  7441. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  7442. */
  7443. scale(scale: number): Vector4;
  7444. /**
  7445. * Sets the passed vector "result" with the current Vector4 coordinates multiplied by scale (float).
  7446. * Returns the current Vector4.
  7447. */
  7448. scaleToRef(scale: number, result: Vector4): Vector4;
  7449. /**
  7450. * Boolean : True if the current Vector4 coordinates are stricly equal to the passed ones.
  7451. */
  7452. equals(otherVector: Vector4): boolean;
  7453. /**
  7454. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the passed vector ones.
  7455. */
  7456. equalsWithEpsilon(otherVector: Vector4, epsilon?: number): boolean;
  7457. /**
  7458. * Boolean : True if the passed floats are strictly equal to the current Vector4 coordinates.
  7459. */
  7460. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  7461. /**
  7462. * Multiplies in place the current Vector4 by the passed one.
  7463. * Returns the updated Vector4.
  7464. */
  7465. multiplyInPlace(otherVector: Vector4): Vector4;
  7466. /**
  7467. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the passed one.
  7468. */
  7469. multiply(otherVector: Vector4): Vector4;
  7470. /**
  7471. * Updates the passed vector "result" with the multiplication result of the current Vector4 and the passed one.
  7472. * Returns the current Vector4.
  7473. */
  7474. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  7475. /**
  7476. * Returns a new Vector4 set with the multiplication result of the passed floats and the current Vector4 coordinates.
  7477. */
  7478. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  7479. /**
  7480. * Returns a new Vector4 set with the division result of the current Vector4 by the passed one.
  7481. */
  7482. divide(otherVector: Vector4): Vector4;
  7483. /**
  7484. * Updates the passed vector "result" with the division result of the current Vector4 by the passed one.
  7485. * Returns the current Vector4.
  7486. */
  7487. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  7488. /**
  7489. * Divides the current Vector3 coordinates by the passed ones.
  7490. * Returns the updated Vector3.
  7491. */
  7492. divideInPlace(otherVector: Vector4): Vector4;
  7493. /**
  7494. * Updates the Vector4 coordinates with the minimum values between its own and the passed vector ones.
  7495. */
  7496. MinimizeInPlace(other: Vector4): Vector4;
  7497. /**
  7498. * Updates the Vector4 coordinates with the maximum values between its own and the passed vector ones.
  7499. */
  7500. MaximizeInPlace(other: Vector4): Vector4;
  7501. /**
  7502. * Returns the Vector4 length (float).
  7503. */
  7504. length(): number;
  7505. /**
  7506. * Returns the Vector4 squared length (float).
  7507. */
  7508. lengthSquared(): number;
  7509. /**
  7510. * Normalizes in place the Vector4.
  7511. * Returns the updated Vector4.
  7512. */
  7513. normalize(): Vector4;
  7514. /**
  7515. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  7516. */
  7517. toVector3(): Vector3;
  7518. /**
  7519. * Returns a new Vector4 copied from the current one.
  7520. */
  7521. clone(): Vector4;
  7522. /**
  7523. * Updates the current Vector4 with the passed one coordinates.
  7524. * Returns the updated Vector4.
  7525. */
  7526. copyFrom(source: Vector4): Vector4;
  7527. /**
  7528. * Updates the current Vector4 coordinates with the passed floats.
  7529. * Returns the updated Vector4.
  7530. */
  7531. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  7532. /**
  7533. * Updates the current Vector4 coordinates with the passed floats.
  7534. * Returns the updated Vector4.
  7535. */
  7536. set(x: number, y: number, z: number, w: number): Vector4;
  7537. /**
  7538. * Returns a new Vector4 set from the starting index of the passed array.
  7539. */
  7540. static FromArray(array: ArrayLike<number>, offset?: number): Vector4;
  7541. /**
  7542. * Updates the passed vector "result" from the starting index of the passed array.
  7543. */
  7544. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Vector4): void;
  7545. /**
  7546. * Updates the passed vector "result" from the starting index of the passed Float32Array.
  7547. */
  7548. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  7549. /**
  7550. * Updates the passed vector "result" coordinates from the passed floats.
  7551. */
  7552. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  7553. /**
  7554. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  7555. */
  7556. static Zero(): Vector4;
  7557. /**
  7558. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  7559. */
  7560. static One(): Vector4;
  7561. /**
  7562. * Returns a new normalized Vector4 from the passed one.
  7563. */
  7564. static Normalize(vector: Vector4): Vector4;
  7565. /**
  7566. * Updates the passed vector "result" from the normalization of the passed one.
  7567. */
  7568. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  7569. static Minimize(left: Vector4, right: Vector4): Vector4;
  7570. static Maximize(left: Vector4, right: Vector4): Vector4;
  7571. /**
  7572. * Returns the distance (float) between the vectors "value1" and "value2".
  7573. */
  7574. static Distance(value1: Vector4, value2: Vector4): number;
  7575. /**
  7576. * Returns the squared distance (float) between the vectors "value1" and "value2".
  7577. */
  7578. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  7579. /**
  7580. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  7581. */
  7582. static Center(value1: Vector4, value2: Vector4): Vector4;
  7583. /**
  7584. * Returns a new Vector4 set with the result of the normal transformation by the passed matrix of the passed vector.
  7585. * This methods computes transformed normalized direction vectors only.
  7586. */
  7587. static TransformNormal(vector: Vector4, transformation: Matrix): Vector4;
  7588. /**
  7589. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed vector.
  7590. * This methods computes transformed normalized direction vectors only.
  7591. */
  7592. static TransformNormalToRef(vector: Vector4, transformation: Matrix, result: Vector4): void;
  7593. /**
  7594. * Sets the passed vector "result" with the result of the normal transformation by the passed matrix of the passed floats (x, y, z, w).
  7595. * This methods computes transformed normalized direction vectors only.
  7596. */
  7597. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: Matrix, result: Vector4): void;
  7598. }
  7599. interface ISize {
  7600. width: number;
  7601. height: number;
  7602. }
  7603. class Size implements ISize {
  7604. width: number;
  7605. height: number;
  7606. /**
  7607. * Creates a Size object from the passed width and height (floats).
  7608. */
  7609. constructor(width: number, height: number);
  7610. toString(): string;
  7611. /**
  7612. * Returns the string "Size"
  7613. */
  7614. getClassName(): string;
  7615. /**
  7616. * Returns the Size hash code.
  7617. */
  7618. getHashCode(): number;
  7619. /**
  7620. * Updates the current size from the passed one.
  7621. * Returns the updated Size.
  7622. */
  7623. copyFrom(src: Size): void;
  7624. /**
  7625. * Updates in place the current Size from the passed floats.
  7626. * Returns the updated Size.
  7627. */
  7628. copyFromFloats(width: number, height: number): Size;
  7629. /**
  7630. * Updates in place the current Size from the passed floats.
  7631. * Returns the updated Size.
  7632. */
  7633. set(width: number, height: number): Size;
  7634. /**
  7635. * Returns a new Size set with the multiplication result of the current Size and the passed floats.
  7636. */
  7637. multiplyByFloats(w: number, h: number): Size;
  7638. /**
  7639. * Returns a new Size copied from the passed one.
  7640. */
  7641. clone(): Size;
  7642. /**
  7643. * Boolean : True if the current Size and the passed one width and height are strictly equal.
  7644. */
  7645. equals(other: Size): boolean;
  7646. /**
  7647. * Returns the surface of the Size : width * height (float).
  7648. */
  7649. readonly surface: number;
  7650. /**
  7651. * Returns a new Size set to (0.0, 0.0)
  7652. */
  7653. static Zero(): Size;
  7654. /**
  7655. * Returns a new Size set as the addition result of the current Size and the passed one.
  7656. */
  7657. add(otherSize: Size): Size;
  7658. /**
  7659. * Returns a new Size set as the subtraction result of the passed one from the current Size.
  7660. */
  7661. subtract(otherSize: Size): Size;
  7662. /**
  7663. * Returns a new Size set at the linear interpolation "amount" between "start" and "end".
  7664. */
  7665. static Lerp(start: Size, end: Size, amount: number): Size;
  7666. }
  7667. class Quaternion {
  7668. x: number;
  7669. y: number;
  7670. z: number;
  7671. w: number;
  7672. /**
  7673. * Creates a new Quaternion from the passed floats.
  7674. */
  7675. constructor(x?: number, y?: number, z?: number, w?: number);
  7676. /**
  7677. * Returns a string with the Quaternion coordinates.
  7678. */
  7679. toString(): string;
  7680. /**
  7681. * Returns the string "Quaternion".
  7682. */
  7683. getClassName(): string;
  7684. /**
  7685. * Returns the Quaternion hash code.
  7686. */
  7687. getHashCode(): number;
  7688. /**
  7689. * Returns a new array populated with 4 elements : the Quaternion coordinates.
  7690. */
  7691. asArray(): number[];
  7692. /**
  7693. * Boolean : True if the current Quaterion and the passed one coordinates are strictly equal.
  7694. */
  7695. equals(otherQuaternion: Quaternion): boolean;
  7696. /**
  7697. * Returns a new Quaternion copied from the current one.
  7698. */
  7699. clone(): Quaternion;
  7700. /**
  7701. * Updates the current Quaternion from the passed one coordinates.
  7702. * Returns the updated Quaterion.
  7703. */
  7704. copyFrom(other: Quaternion): Quaternion;
  7705. /**
  7706. * Updates the current Quaternion from the passed float coordinates.
  7707. * Returns the updated Quaterion.
  7708. */
  7709. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  7710. /**
  7711. * Updates the current Quaternion from the passed float coordinates.
  7712. * Returns the updated Quaterion.
  7713. */
  7714. set(x: number, y: number, z: number, w: number): Quaternion;
  7715. /**
  7716. * Returns a new Quaternion as the addition result of the passed one and the current Quaternion.
  7717. */
  7718. add(other: Quaternion): Quaternion;
  7719. /**
  7720. * Returns a new Quaternion as the subtraction result of the passed one from the current Quaternion.
  7721. */
  7722. subtract(other: Quaternion): Quaternion;
  7723. /**
  7724. * Returns a new Quaternion set by multiplying the current Quaterion coordinates by the float "scale".
  7725. */
  7726. scale(value: number): Quaternion;
  7727. /**
  7728. * Returns a new Quaternion set as the quaternion mulplication result of the current one with the passed one "q1".
  7729. */
  7730. multiply(q1: Quaternion): Quaternion;
  7731. /**
  7732. * Sets the passed "result" as the quaternion mulplication result of the current one with the passed one "q1".
  7733. * Returns the current Quaternion.
  7734. */
  7735. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  7736. /**
  7737. * Updates the current Quaternion with the quaternion mulplication result of itself with the passed one "q1".
  7738. * Returns the updated Quaternion.
  7739. */
  7740. multiplyInPlace(q1: Quaternion): Quaternion;
  7741. /**
  7742. * Sets the passed "ref" with the conjugation of the current Quaternion.
  7743. * Returns the current Quaternion.
  7744. */
  7745. conjugateToRef(ref: Quaternion): Quaternion;
  7746. /**
  7747. * Conjugates in place the current Quaternion.
  7748. * Returns the updated Quaternion.
  7749. */
  7750. conjugateInPlace(): Quaternion;
  7751. /**
  7752. * Returns a new Quaternion as the conjugate of the current Quaternion.
  7753. */
  7754. conjugate(): Quaternion;
  7755. /**
  7756. * Returns the Quaternion length (float).
  7757. */
  7758. length(): number;
  7759. /**
  7760. * Normalize in place the current Quaternion.
  7761. * Returns the updated Quaternion.
  7762. */
  7763. normalize(): Quaternion;
  7764. /**
  7765. * Returns a new Vector3 set with the Euler angles translated from the current Quaternion.
  7766. */
  7767. toEulerAngles(order?: string): Vector3;
  7768. /**
  7769. * Sets the passed vector3 "result" with the Euler angles translated from the current Quaternion.
  7770. * Returns the current Quaternion.
  7771. */
  7772. toEulerAnglesToRef(result: Vector3, order?: string): Quaternion;
  7773. /**
  7774. * Updates the passed rotation matrix with the current Quaternion values.
  7775. * Returns the current Quaternion.
  7776. */
  7777. toRotationMatrix(result: Matrix): Quaternion;
  7778. /**
  7779. * Updates the current Quaternion from the passed rotation matrix values.
  7780. * Returns the updated Quaternion.
  7781. */
  7782. fromRotationMatrix(matrix: Matrix): Quaternion;
  7783. /**
  7784. * Returns a new Quaternion set from the passed rotation matrix values.
  7785. */
  7786. static FromRotationMatrix(matrix: Matrix): Quaternion;
  7787. /**
  7788. * Updates the passed quaternion "result" with the passed rotation matrix values.
  7789. */
  7790. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  7791. /**
  7792. * Returns a new Quaternion set to (0.0, 0.0, 0.0).
  7793. */
  7794. static Zero(): Quaternion;
  7795. /**
  7796. * Returns a new Quaternion as the inverted current Quaternion.
  7797. */
  7798. static Inverse(q: Quaternion): Quaternion;
  7799. /**
  7800. * Returns the identity Quaternion.
  7801. */
  7802. static Identity(): Quaternion;
  7803. static IsIdentity(quaternion: Quaternion): boolean;
  7804. /**
  7805. * Returns a new Quaternion set from the passed axis (Vector3) and angle in radians (float).
  7806. */
  7807. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  7808. /**
  7809. * Sets the passed quaternion "result" from the passed axis (Vector3) and angle in radians (float).
  7810. */
  7811. static RotationAxisToRef(axis: Vector3, angle: number, result: Quaternion): Quaternion;
  7812. /**
  7813. * Retuns a new Quaternion set from the starting index of the passed array.
  7814. */
  7815. static FromArray(array: ArrayLike<number>, offset?: number): Quaternion;
  7816. /**
  7817. * Returns a new Quaternion set from the passed Euler float angles (y, x, z).
  7818. */
  7819. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  7820. /**
  7821. * Sets the passed quaternion "result" from the passed float Euler angles (y, x, z).
  7822. */
  7823. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  7824. /**
  7825. * Returns a new Quaternion from the passed float Euler angles expressed in z-x-z orientation
  7826. */
  7827. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  7828. /**
  7829. * Sets the passed quaternion "result" from the passed float Euler angles expressed in z-x-z orientation
  7830. */
  7831. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  7832. /**
  7833. * Returns a new Quaternion as the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  7834. * cf to Vector3.RotationFromAxis() documentation.
  7835. * Note : axis1, axis2 and axis3 are normalized during this operation.
  7836. */
  7837. static RotationQuaternionFromAxis(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): Quaternion;
  7838. /**
  7839. * Sets the passed quaternion "ref" with the quaternion rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system.
  7840. * cf to Vector3.RotationFromAxis() documentation.
  7841. * Note : axis1, axis2 and axis3 are normalized during this operation.
  7842. */
  7843. static RotationQuaternionFromAxisToRef(axis1: Vector3, axis2: Vector3, axis3: Vector3, ref: Quaternion): void;
  7844. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  7845. static SlerpToRef(left: Quaternion, right: Quaternion, amount: number, result: Quaternion): void;
  7846. /**
  7847. * Returns a new Quaternion located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2".
  7848. */
  7849. static Hermite(value1: Quaternion, tangent1: Quaternion, value2: Quaternion, tangent2: Quaternion, amount: number): Quaternion;
  7850. }
  7851. class Matrix {
  7852. private static _tempQuaternion;
  7853. private static _xAxis;
  7854. private static _yAxis;
  7855. private static _zAxis;
  7856. private static _updateFlagSeed;
  7857. private static _identityReadOnly;
  7858. private _isIdentity;
  7859. private _isIdentityDirty;
  7860. updateFlag: number;
  7861. m: Float32Array;
  7862. _markAsUpdated(): void;
  7863. constructor();
  7864. /**
  7865. * Boolean : True is the matrix is the identity matrix
  7866. */
  7867. isIdentity(considerAsTextureMatrix?: boolean): boolean;
  7868. /**
  7869. * Returns the matrix determinant (float).
  7870. */
  7871. determinant(): number;
  7872. /**
  7873. * Returns the matrix underlying array.
  7874. */
  7875. toArray(): Float32Array;
  7876. /**
  7877. * Returns the matrix underlying array.
  7878. */
  7879. asArray(): Float32Array;
  7880. /**
  7881. * Inverts in place the Matrix.
  7882. * Returns the Matrix inverted.
  7883. */
  7884. invert(): Matrix;
  7885. /**
  7886. * Sets all the matrix elements to zero.
  7887. * Returns the Matrix.
  7888. */
  7889. reset(): Matrix;
  7890. /**
  7891. * Returns a new Matrix as the addition result of the current Matrix and the passed one.
  7892. */
  7893. add(other: Matrix): Matrix;
  7894. /**
  7895. * Sets the passed matrix "result" with the ddition result of the current Matrix and the passed one.
  7896. * Returns the Matrix.
  7897. */
  7898. addToRef(other: Matrix, result: Matrix): Matrix;
  7899. /**
  7900. * Adds in place the passed matrix to the current Matrix.
  7901. * Returns the updated Matrix.
  7902. */
  7903. addToSelf(other: Matrix): Matrix;
  7904. /**
  7905. * Sets the passed matrix with the current inverted Matrix.
  7906. * Returns the unmodified current Matrix.
  7907. */
  7908. invertToRef(other: Matrix): Matrix;
  7909. /**
  7910. * Inserts the translation vector (using 3 x floats) in the current Matrix.
  7911. * Returns the updated Matrix.
  7912. */
  7913. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  7914. /**
  7915. * Inserts the translation vector in the current Matrix.
  7916. * Returns the updated Matrix.
  7917. */
  7918. setTranslation(vector3: Vector3): Matrix;
  7919. /**
  7920. * Returns a new Vector3 as the extracted translation from the Matrix.
  7921. */
  7922. getTranslation(): Vector3;
  7923. /**
  7924. * Fill a Vector3 with the extracted translation from the Matrix.
  7925. */
  7926. getTranslationToRef(result: Vector3): Matrix;
  7927. /**
  7928. * Remove rotation and scaling part from the Matrix.
  7929. * Returns the updated Matrix.
  7930. */
  7931. removeRotationAndScaling(): Matrix;
  7932. /**
  7933. * Returns a new Matrix set with the multiplication result of the current Matrix and the passed one.
  7934. */
  7935. multiply(other: Matrix): Matrix;
  7936. /**
  7937. * Updates the current Matrix from the passed one values.
  7938. * Returns the updated Matrix.
  7939. */
  7940. copyFrom(other: Matrix): Matrix;
  7941. /**
  7942. * Populates the passed array from the starting index with the Matrix values.
  7943. * Returns the Matrix.
  7944. */
  7945. copyToArray(array: Float32Array, offset?: number): Matrix;
  7946. /**
  7947. * Sets the passed matrix "result" with the multiplication result of the current Matrix and the passed one.
  7948. */
  7949. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  7950. /**
  7951. * Sets the Float32Array "result" from the passed index "offset" with the multiplication result of the current Matrix and the passed one.
  7952. */
  7953. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  7954. /**
  7955. * Boolean : True is the current Matrix and the passed one values are strictly equal.
  7956. */
  7957. equals(value: Matrix): boolean;
  7958. /**
  7959. * Returns a new Matrix from the current Matrix.
  7960. */
  7961. clone(): Matrix;
  7962. /**
  7963. * Returns the string "Matrix"
  7964. */
  7965. getClassName(): string;
  7966. /**
  7967. * Returns the Matrix hash code.
  7968. */
  7969. getHashCode(): number;
  7970. /**
  7971. * Decomposes the current Matrix into :
  7972. * - a scale vector3 passed as a reference to update,
  7973. * - a rotation quaternion passed as a reference to update,
  7974. * - a translation vector3 passed as a reference to update.
  7975. * Returns the boolean `true`.
  7976. */
  7977. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  7978. /**
  7979. * Returns a new Matrix as the extracted rotation matrix from the current one.
  7980. */
  7981. getRotationMatrix(): Matrix;
  7982. /**
  7983. * Extracts the rotation matrix from the current one and sets it as the passed "result".
  7984. * Returns the current Matrix.
  7985. */
  7986. getRotationMatrixToRef(result: Matrix): Matrix;
  7987. /**
  7988. * Returns a new Matrix set from the starting index of the passed array.
  7989. */
  7990. static FromArray(array: ArrayLike<number>, offset?: number): Matrix;
  7991. /**
  7992. * Sets the passed "result" matrix from the starting index of the passed array.
  7993. */
  7994. static FromArrayToRef(array: ArrayLike<number>, offset: number, result: Matrix): void;
  7995. /**
  7996. * Sets the passed "result" matrix from the starting index of the passed Float32Array by multiplying each element by the float "scale".
  7997. */
  7998. static FromFloat32ArrayToRefScaled(array: Float32Array, offset: number, scale: number, result: Matrix): void;
  7999. /**
  8000. * Sets the passed matrix "result" with the 16 passed floats.
  8001. */
  8002. 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;
  8003. /**
  8004. * Returns the index-th row of the current matrix as a new Vector4.
  8005. */
  8006. getRow(index: number): Nullable<Vector4>;
  8007. /**
  8008. * Sets the index-th row of the current matrix with the passed Vector4 values.
  8009. * Returns the updated Matrix.
  8010. */
  8011. setRow(index: number, row: Vector4): Matrix;
  8012. /**
  8013. * Compute the transpose of the matrix.
  8014. * Returns a new Matrix.
  8015. */
  8016. transpose(): Matrix;
  8017. /**
  8018. * Compute the transpose of the matrix.
  8019. * Returns the current matrix.
  8020. */
  8021. transposeToRef(result: Matrix): Matrix;
  8022. /**
  8023. * Sets the index-th row of the current matrix with the passed 4 x float values.
  8024. * Returns the updated Matrix.
  8025. */
  8026. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  8027. /**
  8028. * Static identity matrix to be used as readonly matrix
  8029. * Must not be updated.
  8030. */
  8031. static readonly IdentityReadOnly: Matrix;
  8032. /**
  8033. * Returns a new Matrix set from the 16 passed floats.
  8034. */
  8035. 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;
  8036. /**
  8037. * Returns a new Matrix composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  8038. */
  8039. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  8040. /**
  8041. * Update a Matrix with values composed by the passed scale (vector3), rotation (quaternion) and translation (vector3).
  8042. */
  8043. static ComposeToRef(scale: Vector3, rotation: Quaternion, translation: Vector3, result: Matrix): void;
  8044. /**
  8045. * Returns a new indentity Matrix.
  8046. */
  8047. static Identity(): Matrix;
  8048. /**
  8049. * Sets the passed "result" as an identity matrix.
  8050. */
  8051. static IdentityToRef(result: Matrix): void;
  8052. /**
  8053. * Returns a new zero Matrix.
  8054. */
  8055. static Zero(): Matrix;
  8056. /**
  8057. * Returns a new rotation matrix for "angle" radians around the X axis.
  8058. */
  8059. static RotationX(angle: number): Matrix;
  8060. /**
  8061. * Returns a new Matrix as the passed inverted one.
  8062. */
  8063. static Invert(source: Matrix): Matrix;
  8064. /**
  8065. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the X axis.
  8066. */
  8067. static RotationXToRef(angle: number, result: Matrix): void;
  8068. /**
  8069. * Returns a new rotation matrix for "angle" radians around the Y axis.
  8070. */
  8071. static RotationY(angle: number): Matrix;
  8072. /**
  8073. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Y axis.
  8074. */
  8075. static RotationYToRef(angle: number, result: Matrix): void;
  8076. /**
  8077. * Returns a new rotation matrix for "angle" radians around the Z axis.
  8078. */
  8079. static RotationZ(angle: number): Matrix;
  8080. /**
  8081. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the Z axis.
  8082. */
  8083. static RotationZToRef(angle: number, result: Matrix): void;
  8084. /**
  8085. * Returns a new rotation matrix for "angle" radians around the passed axis.
  8086. */
  8087. static RotationAxis(axis: Vector3, angle: number): Matrix;
  8088. /**
  8089. * Sets the passed matrix "result" as a rotation matrix for "angle" radians around the passed axis.
  8090. */
  8091. static RotationAxisToRef(axis: Vector3, angle: number, result: Matrix): void;
  8092. /**
  8093. * Returns a new Matrix as a rotation matrix from the Euler angles (y, x, z).
  8094. */
  8095. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  8096. /**
  8097. * Sets the passed matrix "result" as a rotation matrix from the Euler angles (y, x, z).
  8098. */
  8099. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  8100. /**
  8101. * Returns a new Matrix as a scaling matrix from the passed floats (x, y, z).
  8102. */
  8103. static Scaling(x: number, y: number, z: number): Matrix;
  8104. /**
  8105. * Sets the passed matrix "result" as a scaling matrix from the passed floats (x, y, z).
  8106. */
  8107. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  8108. /**
  8109. * Returns a new Matrix as a translation matrix from the passed floats (x, y, z).
  8110. */
  8111. static Translation(x: number, y: number, z: number): Matrix;
  8112. /**
  8113. * Sets the passed matrix "result" as a translation matrix from the passed floats (x, y, z).
  8114. */
  8115. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  8116. /**
  8117. * Returns a new Matrix whose values are the interpolated values for "gradien" (float) between the ones of the matrices "startValue" and "endValue".
  8118. */
  8119. static Lerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  8120. /**
  8121. * Returns a new Matrix whose values are computed by :
  8122. * - decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices,
  8123. * - interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end,
  8124. * - recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices.
  8125. */
  8126. static DecomposeLerp(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  8127. /**
  8128. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  8129. * This methods works for a Left-Handed system.
  8130. */
  8131. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  8132. /**
  8133. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  8134. * This methods works for a Left-Handed system.
  8135. */
  8136. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  8137. /**
  8138. * Returns a new rotation Matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  8139. * This methods works for a Right-Handed system.
  8140. */
  8141. static LookAtRH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  8142. /**
  8143. * Sets the passed "result" Matrix as a rotation matrix used to rotate a mesh so as it looks at the target Vector3, from the eye Vector3, the UP vector3 being orientated like "up".
  8144. * This methods works for a Left-Handed system.
  8145. */
  8146. static LookAtRHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  8147. /**
  8148. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  8149. */
  8150. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  8151. /**
  8152. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  8153. */
  8154. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  8155. /**
  8156. * Returns a new Matrix as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  8157. */
  8158. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  8159. /**
  8160. * Sets the passed matrix "result" as a left-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  8161. */
  8162. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  8163. /**
  8164. * Returns a new Matrix as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  8165. */
  8166. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  8167. /**
  8168. * Sets the passed matrix "result" as a right-handed orthographic projection matrix computed from the passed floats : left, right, top and bottom being the coordinates of the projection plane, z near and far limits.
  8169. */
  8170. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  8171. /**
  8172. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : width and height of the projection plane, z near and far limits.
  8173. */
  8174. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  8175. /**
  8176. * Returns a new Matrix as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  8177. */
  8178. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  8179. /**
  8180. * Sets the passed matrix "result" as a left-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  8181. */
  8182. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  8183. /**
  8184. * Returns a new Matrix as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  8185. */
  8186. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  8187. /**
  8188. * Sets the passed matrix "result" as a right-handed perspective projection matrix computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  8189. */
  8190. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  8191. /**
  8192. * Sets the passed matrix "result" as a left-handed perspective projection matrix for WebVR computed from the passed floats : vertical angle of view (fov), width/height ratio (aspect), z near and far limits.
  8193. */
  8194. static PerspectiveFovWebVRToRef(fov: {
  8195. upDegrees: number;
  8196. downDegrees: number;
  8197. leftDegrees: number;
  8198. rightDegrees: number;
  8199. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  8200. /**
  8201. * Returns the final transformation matrix : world * view * projection * viewport
  8202. */
  8203. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  8204. /**
  8205. * Returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the passed Matrix.
  8206. */
  8207. static GetAsMatrix2x2(matrix: Matrix): Float32Array;
  8208. /**
  8209. * Returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the passed Matrix.
  8210. */
  8211. static GetAsMatrix3x3(matrix: Matrix): Float32Array;
  8212. /**
  8213. * Compute the transpose of the passed Matrix.
  8214. * Returns a new Matrix.
  8215. */
  8216. static Transpose(matrix: Matrix): Matrix;
  8217. /**
  8218. * Compute the transpose of the passed Matrix and store it in the result matrix.
  8219. */
  8220. static TransposeToRef(matrix: Matrix, result: Matrix): void;
  8221. /**
  8222. * Returns a new Matrix as the reflection matrix across the passed plane.
  8223. */
  8224. static Reflection(plane: Plane): Matrix;
  8225. /**
  8226. * Sets the passed matrix "result" as the reflection matrix across the passed plane.
  8227. */
  8228. static ReflectionToRef(plane: Plane, result: Matrix): void;
  8229. /**
  8230. * Sets the passed matrix "mat" as a rotation matrix composed from the 3 passed left handed axis.
  8231. */
  8232. static FromXYZAxesToRef(xaxis: Vector3, yaxis: Vector3, zaxis: Vector3, result: Matrix): void;
  8233. /**
  8234. * Sets the passed matrix "result" as a rotation matrix according to the passed quaternion.
  8235. */
  8236. static FromQuaternionToRef(quat: Quaternion, result: Matrix): void;
  8237. }
  8238. class Plane {
  8239. normal: Vector3;
  8240. d: number;
  8241. /**
  8242. * Creates a Plane object according to the passed floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  8243. */
  8244. constructor(a: number, b: number, c: number, d: number);
  8245. /**
  8246. * Returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  8247. */
  8248. asArray(): number[];
  8249. /**
  8250. * Returns a new plane copied from the current Plane.
  8251. */
  8252. clone(): Plane;
  8253. /**
  8254. * Returns the string "Plane".
  8255. */
  8256. getClassName(): string;
  8257. /**
  8258. * Returns the Plane hash code.
  8259. */
  8260. getHashCode(): number;
  8261. /**
  8262. * Normalize the current Plane in place.
  8263. * Returns the updated Plane.
  8264. */
  8265. normalize(): Plane;
  8266. /**
  8267. * Returns a new Plane as the result of the transformation of the current Plane by the passed matrix.
  8268. */
  8269. transform(transformation: Matrix): Plane;
  8270. /**
  8271. * Returns the dot product (float) of the point coordinates and the plane normal.
  8272. */
  8273. dotCoordinate(point: Vector3): number;
  8274. /**
  8275. * Updates the current Plane from the plane defined by the three passed points.
  8276. * Returns the updated Plane.
  8277. */
  8278. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  8279. /**
  8280. * Boolean : True is the vector "direction" is the same side than the plane normal.
  8281. */
  8282. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  8283. /**
  8284. * Returns the signed distance (float) from the passed point to the Plane.
  8285. */
  8286. signedDistanceTo(point: Vector3): number;
  8287. /**
  8288. * Returns a new Plane from the passed array.
  8289. */
  8290. static FromArray(array: ArrayLike<number>): Plane;
  8291. /**
  8292. * Returns a new Plane defined by the three passed points.
  8293. */
  8294. static FromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  8295. /**
  8296. * Returns a new Plane the normal vector to this plane at the passed origin point.
  8297. * Note : the vector "normal" is updated because normalized.
  8298. */
  8299. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  8300. /**
  8301. * Returns the signed distance between the plane defined by the normal vector at the "origin"" point and the passed other point.
  8302. */
  8303. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  8304. }
  8305. class Viewport {
  8306. x: number;
  8307. y: number;
  8308. width: number;
  8309. height: number;
  8310. /**
  8311. * Creates a Viewport object located at (x, y) and sized (width, height).
  8312. */
  8313. constructor(x: number, y: number, width: number, height: number);
  8314. toGlobal(renderWidthOrEngine: number | Engine, renderHeight: number): Viewport;
  8315. /**
  8316. * Returns a new Viewport copied from the current one.
  8317. */
  8318. clone(): Viewport;
  8319. }
  8320. class Frustum {
  8321. /**
  8322. * Returns a new array of 6 Frustum planes computed by the passed transformation matrix.
  8323. */
  8324. static GetPlanes(transform: Matrix): Plane[];
  8325. static GetNearPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  8326. static GetFarPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  8327. static GetLeftPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  8328. static GetRightPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  8329. static GetTopPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  8330. static GetBottomPlaneToRef(transform: Matrix, frustumPlane: Plane): void;
  8331. /**
  8332. * Sets the passed array "frustumPlanes" with the 6 Frustum planes computed by the passed transformation matrix.
  8333. */
  8334. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  8335. }
  8336. enum Space {
  8337. LOCAL = 0,
  8338. WORLD = 1,
  8339. BONE = 2,
  8340. }
  8341. class Axis {
  8342. static X: Vector3;
  8343. static Y: Vector3;
  8344. static Z: Vector3;
  8345. }
  8346. class BezierCurve {
  8347. /**
  8348. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the passed x1, y1, x2, y2 floats.
  8349. */
  8350. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  8351. }
  8352. enum Orientation {
  8353. CW = 0,
  8354. CCW = 1,
  8355. }
  8356. class Angle {
  8357. private _radians;
  8358. /**
  8359. * Creates an Angle object of "radians" radians (float).
  8360. */
  8361. constructor(radians: number);
  8362. /**
  8363. * Returns the Angle value in degrees (float).
  8364. */
  8365. degrees: () => number;
  8366. /**
  8367. * Returns the Angle value in radians (float).
  8368. */
  8369. radians: () => number;
  8370. /**
  8371. * Returns a new Angle object valued with the angle value in radians between the two passed vectors.
  8372. */
  8373. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  8374. /**
  8375. * Returns a new Angle object from the passed float in radians.
  8376. */
  8377. static FromRadians(radians: number): Angle;
  8378. /**
  8379. * Returns a new Angle object from the passed float in degrees.
  8380. */
  8381. static FromDegrees(degrees: number): Angle;
  8382. }
  8383. class Arc2 {
  8384. startPoint: Vector2;
  8385. midPoint: Vector2;
  8386. endPoint: Vector2;
  8387. centerPoint: Vector2;
  8388. radius: number;
  8389. angle: Angle;
  8390. startAngle: Angle;
  8391. orientation: Orientation;
  8392. /**
  8393. * Creates an Arc object from the three passed points : start, middle and end.
  8394. */
  8395. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  8396. }
  8397. class Path2 {
  8398. private _points;
  8399. private _length;
  8400. closed: boolean;
  8401. /**
  8402. * Creates a Path2 object from the starting 2D coordinates x and y.
  8403. */
  8404. constructor(x: number, y: number);
  8405. /**
  8406. * Adds a new segment until the passed coordinates (x, y) to the current Path2.
  8407. * Returns the updated Path2.
  8408. */
  8409. addLineTo(x: number, y: number): Path2;
  8410. /**
  8411. * 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.
  8412. * Returns the updated Path2.
  8413. */
  8414. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  8415. /**
  8416. * Closes the Path2.
  8417. * Returns the Path2.
  8418. */
  8419. close(): Path2;
  8420. /**
  8421. * Returns the Path2 total length (float).
  8422. */
  8423. length(): number;
  8424. /**
  8425. * Returns the Path2 internal array of points.
  8426. */
  8427. getPoints(): Vector2[];
  8428. /**
  8429. * Returns a new Vector2 located at a percentage of the Path2 total length on this path.
  8430. */
  8431. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  8432. /**
  8433. * Returns a new Path2 starting at the coordinates (x, y).
  8434. */
  8435. static StartingAt(x: number, y: number): Path2;
  8436. }
  8437. class Path3D {
  8438. path: Vector3[];
  8439. private _curve;
  8440. private _distances;
  8441. private _tangents;
  8442. private _normals;
  8443. private _binormals;
  8444. private _raw;
  8445. /**
  8446. * new Path3D(path, normal, raw)
  8447. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  8448. * please read the description in the tutorial : http://doc.babylonjs.com/tutorials/How_to_use_Path3D
  8449. * path : an array of Vector3, the curve axis of the Path3D
  8450. * normal (optional) : Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  8451. * raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  8452. */
  8453. constructor(path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  8454. /**
  8455. * Returns the Path3D array of successive Vector3 designing its curve.
  8456. */
  8457. getCurve(): Vector3[];
  8458. /**
  8459. * Returns an array populated with tangent vectors on each Path3D curve point.
  8460. */
  8461. getTangents(): Vector3[];
  8462. /**
  8463. * Returns an array populated with normal vectors on each Path3D curve point.
  8464. */
  8465. getNormals(): Vector3[];
  8466. /**
  8467. * Returns an array populated with binormal vectors on each Path3D curve point.
  8468. */
  8469. getBinormals(): Vector3[];
  8470. /**
  8471. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  8472. */
  8473. getDistances(): number[];
  8474. /**
  8475. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  8476. * Returns the same object updated.
  8477. */
  8478. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  8479. private _compute(firstNormal);
  8480. private _getFirstNonNullVector(index);
  8481. private _getLastNonNullVector(index);
  8482. private _normalVector(v0, vt, va);
  8483. }
  8484. class Curve3 {
  8485. private _points;
  8486. private _length;
  8487. /**
  8488. * Returns a Curve3 object along a Quadratic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#quadratic-bezier-curve
  8489. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  8490. * @param v1 (Vector3) the control point
  8491. * @param v2 (Vector3) the end point of the Quadratic Bezier
  8492. * @param nbPoints (integer) the wanted number of points in the curve
  8493. */
  8494. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  8495. /**
  8496. * Returns a Curve3 object along a Cubic Bezier curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#cubic-bezier-curve
  8497. * @param v0 (Vector3) the origin point of the Cubic Bezier
  8498. * @param v1 (Vector3) the first control point
  8499. * @param v2 (Vector3) the second control point
  8500. * @param v3 (Vector3) the end point of the Cubic Bezier
  8501. * @param nbPoints (integer) the wanted number of points in the curve
  8502. */
  8503. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  8504. /**
  8505. * Returns a Curve3 object along a Hermite Spline curve : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#hermite-spline
  8506. * @param p1 (Vector3) the origin point of the Hermite Spline
  8507. * @param t1 (Vector3) the tangent vector at the origin point
  8508. * @param p2 (Vector3) the end point of the Hermite Spline
  8509. * @param t2 (Vector3) the tangent vector at the end point
  8510. * @param nbPoints (integer) the wanted number of points in the curve
  8511. */
  8512. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  8513. /**
  8514. * Returns a Curve3 object along a CatmullRom Spline curve :
  8515. * @param points (array of Vector3) the points the spline must pass through. At least, four points required.
  8516. * @param nbPoints (integer) the wanted number of points between each curve control points.
  8517. */
  8518. static CreateCatmullRomSpline(points: Vector3[], nbPoints: number): Curve3;
  8519. /**
  8520. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  8521. * A Curve3 is designed from a series of successive Vector3.
  8522. * Tuto : http://doc.babylonjs.com/tutorials/How_to_use_Curve3#curve3-object
  8523. */
  8524. constructor(points: Vector3[]);
  8525. /**
  8526. * Returns the Curve3 stored array of successive Vector3
  8527. */
  8528. getPoints(): Vector3[];
  8529. /**
  8530. * Returns the computed length (float) of the curve.
  8531. */
  8532. length(): number;
  8533. /**
  8534. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  8535. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  8536. * curveA and curveB keep unchanged.
  8537. */
  8538. continue(curve: Curve3): Curve3;
  8539. private _computeLength(path);
  8540. }
  8541. class PositionNormalVertex {
  8542. position: Vector3;
  8543. normal: Vector3;
  8544. constructor(position?: Vector3, normal?: Vector3);
  8545. clone(): PositionNormalVertex;
  8546. }
  8547. class PositionNormalTextureVertex {
  8548. position: Vector3;
  8549. normal: Vector3;
  8550. uv: Vector2;
  8551. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  8552. clone(): PositionNormalTextureVertex;
  8553. }
  8554. class Tmp {
  8555. static Color3: Color3[];
  8556. static Vector2: Vector2[];
  8557. static Vector3: Vector3[];
  8558. static Vector4: Vector4[];
  8559. static Quaternion: Quaternion[];
  8560. static Matrix: Matrix[];
  8561. }
  8562. }
  8563. declare module BABYLON {
  8564. class SphericalPolynomial {
  8565. x: Vector3;
  8566. y: Vector3;
  8567. z: Vector3;
  8568. xx: Vector3;
  8569. yy: Vector3;
  8570. zz: Vector3;
  8571. xy: Vector3;
  8572. yz: Vector3;
  8573. zx: Vector3;
  8574. addAmbient(color: Color3): void;
  8575. static getSphericalPolynomialFromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  8576. scale(scale: number): void;
  8577. }
  8578. class SphericalHarmonics {
  8579. L00: Vector3;
  8580. L1_1: Vector3;
  8581. L10: Vector3;
  8582. L11: Vector3;
  8583. L2_2: Vector3;
  8584. L2_1: Vector3;
  8585. L20: Vector3;
  8586. L21: Vector3;
  8587. L22: Vector3;
  8588. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  8589. scale(scale: number): void;
  8590. convertIncidentRadianceToIrradiance(): void;
  8591. convertIrradianceToLambertianRadiance(): void;
  8592. static getsphericalHarmonicsFromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  8593. }
  8594. }
  8595. declare module BABYLON {
  8596. /**
  8597. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8598. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8599. * 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;
  8600. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8601. */
  8602. class ColorCurves {
  8603. private _dirty;
  8604. private _tempColor;
  8605. private _globalCurve;
  8606. private _highlightsCurve;
  8607. private _midtonesCurve;
  8608. private _shadowsCurve;
  8609. private _positiveCurve;
  8610. private _negativeCurve;
  8611. private _globalHue;
  8612. private _globalDensity;
  8613. private _globalSaturation;
  8614. private _globalExposure;
  8615. /**
  8616. * Gets the global Hue value.
  8617. * 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).
  8618. */
  8619. /**
  8620. * Sets the global Hue value.
  8621. * 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).
  8622. */
  8623. globalHue: number;
  8624. /**
  8625. * Gets the global Density value.
  8626. * 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.
  8627. * Values less than zero provide a filter of opposite hue.
  8628. */
  8629. /**
  8630. * Sets the global Density value.
  8631. * 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.
  8632. * Values less than zero provide a filter of opposite hue.
  8633. */
  8634. globalDensity: number;
  8635. /**
  8636. * Gets the global Saturation value.
  8637. * 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.
  8638. */
  8639. /**
  8640. * Sets the global Saturation value.
  8641. * 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.
  8642. */
  8643. globalSaturation: number;
  8644. private _highlightsHue;
  8645. private _highlightsDensity;
  8646. private _highlightsSaturation;
  8647. private _highlightsExposure;
  8648. /**
  8649. * Gets the highlights Hue value.
  8650. * 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).
  8651. */
  8652. /**
  8653. * Sets the highlights Hue value.
  8654. * 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).
  8655. */
  8656. highlightsHue: number;
  8657. /**
  8658. * Gets the highlights Density value.
  8659. * 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.
  8660. * Values less than zero provide a filter of opposite hue.
  8661. */
  8662. /**
  8663. * Sets the highlights Density value.
  8664. * 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.
  8665. * Values less than zero provide a filter of opposite hue.
  8666. */
  8667. highlightsDensity: number;
  8668. /**
  8669. * Gets the highlights Saturation value.
  8670. * 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.
  8671. */
  8672. /**
  8673. * Sets the highlights Saturation value.
  8674. * 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.
  8675. */
  8676. highlightsSaturation: number;
  8677. /**
  8678. * Gets the highlights Exposure value.
  8679. * 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.
  8680. */
  8681. /**
  8682. * Sets the highlights Exposure value.
  8683. * 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.
  8684. */
  8685. highlightsExposure: number;
  8686. private _midtonesHue;
  8687. private _midtonesDensity;
  8688. private _midtonesSaturation;
  8689. private _midtonesExposure;
  8690. /**
  8691. * Gets the midtones Hue value.
  8692. * 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).
  8693. */
  8694. /**
  8695. * Sets the midtones Hue value.
  8696. * 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).
  8697. */
  8698. midtonesHue: number;
  8699. /**
  8700. * Gets the midtones Density value.
  8701. * 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.
  8702. * Values less than zero provide a filter of opposite hue.
  8703. */
  8704. /**
  8705. * Sets the midtones Density value.
  8706. * 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.
  8707. * Values less than zero provide a filter of opposite hue.
  8708. */
  8709. midtonesDensity: number;
  8710. /**
  8711. * Gets the midtones Saturation value.
  8712. * 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.
  8713. */
  8714. /**
  8715. * Sets the midtones Saturation value.
  8716. * 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.
  8717. */
  8718. midtonesSaturation: number;
  8719. /**
  8720. * Gets the midtones Exposure value.
  8721. * 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.
  8722. */
  8723. /**
  8724. * Sets the midtones Exposure value.
  8725. * 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.
  8726. */
  8727. midtonesExposure: number;
  8728. private _shadowsHue;
  8729. private _shadowsDensity;
  8730. private _shadowsSaturation;
  8731. private _shadowsExposure;
  8732. /**
  8733. * Gets the shadows Hue value.
  8734. * 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).
  8735. */
  8736. /**
  8737. * Sets the shadows Hue value.
  8738. * 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).
  8739. */
  8740. shadowsHue: number;
  8741. /**
  8742. * Gets the shadows Density value.
  8743. * 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.
  8744. * Values less than zero provide a filter of opposite hue.
  8745. */
  8746. /**
  8747. * Sets the shadows Density value.
  8748. * 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.
  8749. * Values less than zero provide a filter of opposite hue.
  8750. */
  8751. shadowsDensity: number;
  8752. /**
  8753. * Gets the shadows Saturation value.
  8754. * 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.
  8755. */
  8756. /**
  8757. * Sets the shadows Saturation value.
  8758. * 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.
  8759. */
  8760. shadowsSaturation: number;
  8761. /**
  8762. * Gets the shadows Exposure value.
  8763. * 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.
  8764. */
  8765. /**
  8766. * Sets the shadows Exposure value.
  8767. * 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.
  8768. */
  8769. shadowsExposure: number;
  8770. getClassName(): string;
  8771. /**
  8772. * Binds the color curves to the shader.
  8773. * @param colorCurves The color curve to bind
  8774. * @param effect The effect to bind to
  8775. */
  8776. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8777. /**
  8778. * Prepare the list of uniforms associated with the ColorCurves effects.
  8779. * @param uniformsList The list of uniforms used in the effect
  8780. */
  8781. static PrepareUniforms(uniformsList: string[]): void;
  8782. /**
  8783. * Returns color grading data based on a hue, density, saturation and exposure value.
  8784. * @param filterHue The hue of the color filter.
  8785. * @param filterDensity The density of the color filter.
  8786. * @param saturation The saturation.
  8787. * @param exposure The exposure.
  8788. * @param result The result data container.
  8789. */
  8790. private getColorGradingDataToRef(hue, density, saturation, exposure, result);
  8791. /**
  8792. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8793. * @param value The input slider value in range [-100,100].
  8794. * @returns Adjusted value.
  8795. */
  8796. private static applyColorGradingSliderNonlinear(value);
  8797. /**
  8798. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8799. * @param hue The hue (H) input.
  8800. * @param saturation The saturation (S) input.
  8801. * @param brightness The brightness (B) input.
  8802. * @result An RGBA color represented as Vector4.
  8803. */
  8804. private static fromHSBToRef(hue, saturation, brightness, result);
  8805. /**
  8806. * Returns a value clamped between min and max
  8807. * @param value The value to clamp
  8808. * @param min The minimum of value
  8809. * @param max The maximum of value
  8810. * @returns The clamped value.
  8811. */
  8812. private static clamp(value, min, max);
  8813. /**
  8814. * Clones the current color curve instance.
  8815. * @return The cloned curves
  8816. */
  8817. clone(): ColorCurves;
  8818. /**
  8819. * Serializes the current color curve instance to a json representation.
  8820. * @return a JSON representation
  8821. */
  8822. serialize(): any;
  8823. /**
  8824. * Parses the color curve from a json representation.
  8825. * @param source the JSON source to parse
  8826. * @return The parsed curves
  8827. */
  8828. static Parse(source: any): ColorCurves;
  8829. }
  8830. }
  8831. declare module BABYLON {
  8832. class EffectFallbacks {
  8833. private _defines;
  8834. private _currentRank;
  8835. private _maxRank;
  8836. private _mesh;
  8837. unBindMesh(): void;
  8838. addFallback(rank: number, define: string): void;
  8839. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  8840. readonly isMoreFallbacks: boolean;
  8841. reduce(currentDefines: string): string;
  8842. }
  8843. class EffectCreationOptions {
  8844. attributes: string[];
  8845. uniformsNames: string[];
  8846. uniformBuffersNames: string[];
  8847. samplers: string[];
  8848. defines: any;
  8849. fallbacks: Nullable<EffectFallbacks>;
  8850. onCompiled: Nullable<(effect: Effect) => void>;
  8851. onError: Nullable<(effect: Effect, errors: string) => void>;
  8852. indexParameters: any;
  8853. maxSimultaneousLights: number;
  8854. transformFeedbackVaryings: Nullable<string[]>;
  8855. }
  8856. class Effect {
  8857. name: any;
  8858. defines: string;
  8859. onCompiled: Nullable<(effect: Effect) => void>;
  8860. onError: Nullable<(effect: Effect, errors: string) => void>;
  8861. onBind: Nullable<(effect: Effect) => void>;
  8862. uniqueId: number;
  8863. onCompileObservable: Observable<Effect>;
  8864. onErrorObservable: Observable<Effect>;
  8865. onBindObservable: Observable<Effect>;
  8866. private static _uniqueIdSeed;
  8867. private _engine;
  8868. private _uniformBuffersNames;
  8869. private _uniformsNames;
  8870. private _samplers;
  8871. private _isReady;
  8872. private _compilationError;
  8873. private _attributesNames;
  8874. private _attributes;
  8875. private _uniforms;
  8876. _key: string;
  8877. private _indexParameters;
  8878. private _fallbacks;
  8879. private _vertexSourceCode;
  8880. private _fragmentSourceCode;
  8881. private _vertexSourceCodeOverride;
  8882. private _fragmentSourceCodeOverride;
  8883. private _transformFeedbackVaryings;
  8884. _program: WebGLProgram;
  8885. private _valueCache;
  8886. private static _baseCache;
  8887. 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);
  8888. readonly key: string;
  8889. isReady(): boolean;
  8890. getEngine(): Engine;
  8891. getProgram(): WebGLProgram;
  8892. getAttributesNames(): string[];
  8893. getAttributeLocation(index: number): number;
  8894. getAttributeLocationByName(name: string): number;
  8895. getAttributesCount(): number;
  8896. getUniformIndex(uniformName: string): number;
  8897. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  8898. getSamplers(): string[];
  8899. getCompilationError(): string;
  8900. executeWhenCompiled(func: (effect: Effect) => void): void;
  8901. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  8902. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  8903. private _dumpShadersSource(vertexCode, fragmentCode, defines);
  8904. private _processShaderConversion(sourceCode, isFragment, callback);
  8905. private _processIncludes(sourceCode, callback);
  8906. private _processPrecision(source);
  8907. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  8908. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  8909. _prepareEffect(): void;
  8910. readonly isSupported: boolean;
  8911. _bindTexture(channel: string, texture: InternalTexture): void;
  8912. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  8913. setTextureArray(channel: string, textures: BaseTexture[]): void;
  8914. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  8915. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  8916. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  8917. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  8918. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  8919. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  8920. bindUniformBlock(blockName: string, index: number): void;
  8921. setInt(uniformName: string, value: number): Effect;
  8922. setIntArray(uniformName: string, array: Int32Array): Effect;
  8923. setIntArray2(uniformName: string, array: Int32Array): Effect;
  8924. setIntArray3(uniformName: string, array: Int32Array): Effect;
  8925. setIntArray4(uniformName: string, array: Int32Array): Effect;
  8926. setFloatArray(uniformName: string, array: Float32Array): Effect;
  8927. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  8928. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  8929. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  8930. setArray(uniformName: string, array: number[]): Effect;
  8931. setArray2(uniformName: string, array: number[]): Effect;
  8932. setArray3(uniformName: string, array: number[]): Effect;
  8933. setArray4(uniformName: string, array: number[]): Effect;
  8934. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  8935. setMatrix(uniformName: string, matrix: Matrix): Effect;
  8936. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  8937. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  8938. setFloat(uniformName: string, value: number): Effect;
  8939. setBool(uniformName: string, bool: boolean): Effect;
  8940. setVector2(uniformName: string, vector2: Vector2): Effect;
  8941. setFloat2(uniformName: string, x: number, y: number): Effect;
  8942. setVector3(uniformName: string, vector3: Vector3): Effect;
  8943. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  8944. setVector4(uniformName: string, vector4: Vector4): Effect;
  8945. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  8946. setColor3(uniformName: string, color3: Color3): Effect;
  8947. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  8948. static ShadersStore: {
  8949. [key: string]: string;
  8950. };
  8951. static IncludesShadersStore: {
  8952. [key: string]: string;
  8953. };
  8954. static ResetCache(): void;
  8955. }
  8956. }
  8957. declare module BABYLON {
  8958. class FresnelParameters {
  8959. private _isEnabled;
  8960. isEnabled: boolean;
  8961. leftColor: Color3;
  8962. rightColor: Color3;
  8963. bias: number;
  8964. power: number;
  8965. clone(): FresnelParameters;
  8966. serialize(): any;
  8967. static Parse(parsedFresnelParameters: any): FresnelParameters;
  8968. }
  8969. }
  8970. declare module BABYLON {
  8971. /**
  8972. * Interface to follow in your material defines to integrate easily the
  8973. * Image proccessing functions.
  8974. */
  8975. interface IImageProcessingConfigurationDefines {
  8976. IMAGEPROCESSING: boolean;
  8977. VIGNETTE: boolean;
  8978. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8979. VIGNETTEBLENDMODEOPAQUE: boolean;
  8980. TONEMAPPING: boolean;
  8981. CONTRAST: boolean;
  8982. EXPOSURE: boolean;
  8983. COLORCURVES: boolean;
  8984. COLORGRADING: boolean;
  8985. COLORGRADING3D: boolean;
  8986. SAMPLER3DGREENDEPTH: boolean;
  8987. SAMPLER3DBGRMAP: boolean;
  8988. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8989. }
  8990. /**
  8991. * This groups together the common properties used for image processing either in direct forward pass
  8992. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8993. * or not.
  8994. */
  8995. class ImageProcessingConfiguration {
  8996. /**
  8997. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8998. */
  8999. colorCurves: Nullable<ColorCurves>;
  9000. private _colorCurvesEnabled;
  9001. /**
  9002. * Gets wether the color curves effect is enabled.
  9003. */
  9004. /**
  9005. * Sets wether the color curves effect is enabled.
  9006. */
  9007. colorCurvesEnabled: boolean;
  9008. /**
  9009. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  9010. */
  9011. colorGradingTexture: Nullable<BaseTexture>;
  9012. private _colorGradingEnabled;
  9013. /**
  9014. * Gets wether the color grading effect is enabled.
  9015. */
  9016. /**
  9017. * Sets wether the color grading effect is enabled.
  9018. */
  9019. colorGradingEnabled: boolean;
  9020. private _colorGradingWithGreenDepth;
  9021. /**
  9022. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  9023. */
  9024. /**
  9025. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  9026. */
  9027. colorGradingWithGreenDepth: boolean;
  9028. private _colorGradingBGR;
  9029. /**
  9030. * Gets wether the color grading texture contains BGR values.
  9031. */
  9032. /**
  9033. * Sets wether the color grading texture contains BGR values.
  9034. */
  9035. colorGradingBGR: boolean;
  9036. _exposure: number;
  9037. /**
  9038. * Gets the Exposure used in the effect.
  9039. */
  9040. /**
  9041. * Sets the Exposure used in the effect.
  9042. */
  9043. exposure: number;
  9044. private _toneMappingEnabled;
  9045. /**
  9046. * Gets wether the tone mapping effect is enabled.
  9047. */
  9048. /**
  9049. * Sets wether the tone mapping effect is enabled.
  9050. */
  9051. toneMappingEnabled: boolean;
  9052. protected _contrast: number;
  9053. /**
  9054. * Gets the contrast used in the effect.
  9055. */
  9056. /**
  9057. * Sets the contrast used in the effect.
  9058. */
  9059. contrast: number;
  9060. /**
  9061. * Vignette stretch size.
  9062. */
  9063. vignetteStretch: number;
  9064. /**
  9065. * Vignette centre X Offset.
  9066. */
  9067. vignetteCentreX: number;
  9068. /**
  9069. * Vignette centre Y Offset.
  9070. */
  9071. vignetteCentreY: number;
  9072. /**
  9073. * Vignette weight or intensity of the vignette effect.
  9074. */
  9075. vignetteWeight: number;
  9076. /**
  9077. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  9078. * if vignetteEnabled is set to true.
  9079. */
  9080. vignetteColor: Color4;
  9081. /**
  9082. * Camera field of view used by the Vignette effect.
  9083. */
  9084. vignetteCameraFov: number;
  9085. private _vignetteBlendMode;
  9086. /**
  9087. * Gets the vignette blend mode allowing different kind of effect.
  9088. */
  9089. /**
  9090. * Sets the vignette blend mode allowing different kind of effect.
  9091. */
  9092. vignetteBlendMode: number;
  9093. private _vignetteEnabled;
  9094. /**
  9095. * Gets wether the vignette effect is enabled.
  9096. */
  9097. /**
  9098. * Sets wether the vignette effect is enabled.
  9099. */
  9100. vignetteEnabled: boolean;
  9101. private _applyByPostProcess;
  9102. /**
  9103. * Gets wether the image processing is applied through a post process or not.
  9104. */
  9105. /**
  9106. * Sets wether the image processing is applied through a post process or not.
  9107. */
  9108. applyByPostProcess: boolean;
  9109. private _isEnabled;
  9110. /**
  9111. * Gets wether the image processing is enabled or not.
  9112. */
  9113. /**
  9114. * Sets wether the image processing is enabled or not.
  9115. */
  9116. isEnabled: boolean;
  9117. /**
  9118. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  9119. * @type {BABYLON.Observable}
  9120. */
  9121. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  9122. /**
  9123. * Method called each time the image processing information changes requires to recompile the effect.
  9124. */
  9125. protected _updateParameters(): void;
  9126. getClassName(): string;
  9127. /**
  9128. * Prepare the list of uniforms associated with the Image Processing effects.
  9129. * @param uniformsList The list of uniforms used in the effect
  9130. * @param defines the list of defines currently in use
  9131. */
  9132. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  9133. /**
  9134. * Prepare the list of samplers associated with the Image Processing effects.
  9135. * @param uniformsList The list of uniforms used in the effect
  9136. * @param defines the list of defines currently in use
  9137. */
  9138. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  9139. /**
  9140. * Prepare the list of defines associated to the shader.
  9141. * @param defines the list of defines to complete
  9142. */
  9143. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  9144. /**
  9145. * Returns true if all the image processing information are ready.
  9146. */
  9147. isReady(): boolean;
  9148. /**
  9149. * Binds the image processing to the shader.
  9150. * @param effect The effect to bind to
  9151. */
  9152. bind(effect: Effect, aspectRatio?: number): void;
  9153. /**
  9154. * Clones the current image processing instance.
  9155. * @return The cloned image processing
  9156. */
  9157. clone(): ImageProcessingConfiguration;
  9158. /**
  9159. * Serializes the current image processing instance to a json representation.
  9160. * @return a JSON representation
  9161. */
  9162. serialize(): any;
  9163. /**
  9164. * Parses the image processing from a json representation.
  9165. * @param source the JSON source to parse
  9166. * @return The parsed image processing
  9167. */
  9168. static Parse(source: any): ImageProcessingConfiguration;
  9169. private static _VIGNETTEMODE_MULTIPLY;
  9170. private static _VIGNETTEMODE_OPAQUE;
  9171. /**
  9172. * Used to apply the vignette as a mix with the pixel color.
  9173. */
  9174. static readonly VIGNETTEMODE_MULTIPLY: number;
  9175. /**
  9176. * Used to apply the vignette as a replacement of the pixel color.
  9177. */
  9178. static readonly VIGNETTEMODE_OPAQUE: number;
  9179. }
  9180. }
  9181. declare module BABYLON {
  9182. class MaterialDefines {
  9183. private _keys;
  9184. private _isDirty;
  9185. _renderId: number;
  9186. _areLightsDirty: boolean;
  9187. _areAttributesDirty: boolean;
  9188. _areTexturesDirty: boolean;
  9189. _areFresnelDirty: boolean;
  9190. _areMiscDirty: boolean;
  9191. _areImageProcessingDirty: boolean;
  9192. _normals: boolean;
  9193. _uvs: boolean;
  9194. _needNormals: boolean;
  9195. _needUVs: boolean;
  9196. readonly isDirty: boolean;
  9197. markAsProcessed(): void;
  9198. markAsUnprocessed(): void;
  9199. markAllAsDirty(): void;
  9200. markAsImageProcessingDirty(): void;
  9201. markAsLightDirty(): void;
  9202. markAsAttributesDirty(): void;
  9203. markAsTexturesDirty(): void;
  9204. markAsFresnelDirty(): void;
  9205. markAsMiscDirty(): void;
  9206. rebuild(): void;
  9207. isEqual(other: MaterialDefines): boolean;
  9208. cloneTo(other: MaterialDefines): void;
  9209. reset(): void;
  9210. toString(): string;
  9211. }
  9212. class Material implements IAnimatable {
  9213. private static _TriangleFillMode;
  9214. private static _WireFrameFillMode;
  9215. private static _PointFillMode;
  9216. private static _PointListDrawMode;
  9217. private static _LineListDrawMode;
  9218. private static _LineLoopDrawMode;
  9219. private static _LineStripDrawMode;
  9220. private static _TriangleStripDrawMode;
  9221. private static _TriangleFanDrawMode;
  9222. static readonly TriangleFillMode: number;
  9223. static readonly WireFrameFillMode: number;
  9224. static readonly PointFillMode: number;
  9225. static readonly PointListDrawMode: number;
  9226. static readonly LineListDrawMode: number;
  9227. static readonly LineLoopDrawMode: number;
  9228. static readonly LineStripDrawMode: number;
  9229. static readonly TriangleStripDrawMode: number;
  9230. static readonly TriangleFanDrawMode: number;
  9231. private static _ClockWiseSideOrientation;
  9232. private static _CounterClockWiseSideOrientation;
  9233. static readonly ClockWiseSideOrientation: number;
  9234. static readonly CounterClockWiseSideOrientation: number;
  9235. private static _TextureDirtyFlag;
  9236. private static _LightDirtyFlag;
  9237. private static _FresnelDirtyFlag;
  9238. private static _AttributesDirtyFlag;
  9239. private static _MiscDirtyFlag;
  9240. static readonly TextureDirtyFlag: number;
  9241. static readonly LightDirtyFlag: number;
  9242. static readonly FresnelDirtyFlag: number;
  9243. static readonly AttributesDirtyFlag: number;
  9244. static readonly MiscDirtyFlag: number;
  9245. id: string;
  9246. name: string;
  9247. checkReadyOnEveryCall: boolean;
  9248. checkReadyOnlyOnce: boolean;
  9249. state: string;
  9250. alpha: number;
  9251. protected _backFaceCulling: boolean;
  9252. backFaceCulling: boolean;
  9253. sideOrientation: number;
  9254. onCompiled: (effect: Effect) => void;
  9255. onError: (effect: Effect, errors: string) => void;
  9256. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  9257. doNotSerialize: boolean;
  9258. storeEffectOnSubMeshes: boolean;
  9259. animations: Array<Animation>;
  9260. /**
  9261. * An event triggered when the material is disposed.
  9262. * @type {BABYLON.Observable}
  9263. */
  9264. onDisposeObservable: Observable<Material>;
  9265. private _onDisposeObserver;
  9266. onDispose: () => void;
  9267. /**
  9268. * An event triggered when the material is bound.
  9269. * @type {BABYLON.Observable}
  9270. */
  9271. onBindObservable: Observable<AbstractMesh>;
  9272. private _onBindObserver;
  9273. onBind: (Mesh: AbstractMesh) => void;
  9274. /**
  9275. * An event triggered when the material is unbound.
  9276. * @type {BABYLON.Observable}
  9277. */
  9278. onUnBindObservable: Observable<Material>;
  9279. private _alphaMode;
  9280. alphaMode: number;
  9281. private _needDepthPrePass;
  9282. needDepthPrePass: boolean;
  9283. disableDepthWrite: boolean;
  9284. forceDepthWrite: boolean;
  9285. separateCullingPass: boolean;
  9286. private _fogEnabled;
  9287. fogEnabled: boolean;
  9288. pointSize: number;
  9289. zOffset: number;
  9290. wireframe: boolean;
  9291. pointsCloud: boolean;
  9292. fillMode: number;
  9293. _effect: Nullable<Effect>;
  9294. _wasPreviouslyReady: boolean;
  9295. private _useUBO;
  9296. private _scene;
  9297. private _fillMode;
  9298. private _cachedDepthWriteState;
  9299. protected _uniformBuffer: UniformBuffer;
  9300. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  9301. /**
  9302. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  9303. * subclasses should override adding information pertainent to themselves
  9304. */
  9305. toString(fullDetails?: boolean): string;
  9306. /**
  9307. * Child classes can use it to update shaders
  9308. */
  9309. getClassName(): string;
  9310. readonly isFrozen: boolean;
  9311. freeze(): void;
  9312. unfreeze(): void;
  9313. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9314. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9315. getEffect(): Nullable<Effect>;
  9316. getScene(): Scene;
  9317. needAlphaBlending(): boolean;
  9318. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  9319. needAlphaTesting(): boolean;
  9320. getAlphaTestTexture(): Nullable<BaseTexture>;
  9321. markDirty(): void;
  9322. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  9323. bind(world: Matrix, mesh?: Mesh): void;
  9324. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9325. bindOnlyWorldMatrix(world: Matrix): void;
  9326. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  9327. bindView(effect: Effect): void;
  9328. bindViewProjection(effect: Effect): void;
  9329. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  9330. protected _afterBind(mesh?: Mesh): void;
  9331. unbind(): void;
  9332. getActiveTextures(): BaseTexture[];
  9333. hasTexture(texture: BaseTexture): boolean;
  9334. clone(name: string): Nullable<Material>;
  9335. getBindedMeshes(): AbstractMesh[];
  9336. /**
  9337. * Force shader compilation including textures ready check
  9338. */
  9339. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  9340. clipPlane: boolean;
  9341. }>): void;
  9342. markAsDirty(flag: number): void;
  9343. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  9344. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  9345. protected _markAllSubMeshesAsTexturesDirty(): void;
  9346. protected _markAllSubMeshesAsFresnelDirty(): void;
  9347. protected _markAllSubMeshesAsLightsDirty(): void;
  9348. protected _markAllSubMeshesAsAttributesDirty(): void;
  9349. protected _markAllSubMeshesAsMiscDirty(): void;
  9350. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9351. serialize(): any;
  9352. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  9353. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): any;
  9354. }
  9355. }
  9356. declare module BABYLON {
  9357. class MaterialHelper {
  9358. static BindEyePosition(effect: Effect, scene: Scene): void;
  9359. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9360. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9361. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, defines: any): void;
  9362. /**
  9363. * Helper used to prepare the list of defines for shader compilation
  9364. * @param scene defines the current scene
  9365. * @param engine defines the current engine
  9366. * @param defines specifies the list of active defines
  9367. * @param useInstances defines if instances have to be turned on
  9368. * @param alphaTest defines if alpha testing has to be turned on
  9369. */
  9370. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, alphaTest: boolean): void;
  9371. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9372. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9373. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9374. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9375. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9376. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9377. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9378. static BindLightShadow(light: Light, scene: Scene, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9379. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9380. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9381. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect): void;
  9382. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9383. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9384. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9385. static BindClipPlane(effect: Effect, scene: Scene): void;
  9386. }
  9387. }
  9388. declare module BABYLON {
  9389. class MultiMaterial extends Material {
  9390. private _subMaterials;
  9391. subMaterials: Nullable<Material>[];
  9392. constructor(name: string, scene: Scene);
  9393. private _hookArray(array);
  9394. getSubMaterial(index: number): Nullable<Material>;
  9395. getActiveTextures(): BaseTexture[];
  9396. getClassName(): string;
  9397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  9398. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  9399. serialize(): any;
  9400. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9401. }
  9402. }
  9403. declare module BABYLON {
  9404. class PushMaterial extends Material {
  9405. protected _activeEffect: Effect;
  9406. constructor(name: string, scene: Scene);
  9407. getEffect(): Effect;
  9408. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9409. bindOnlyWorldMatrix(world: Matrix): void;
  9410. bind(world: Matrix, mesh?: Mesh): void;
  9411. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  9412. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  9413. }
  9414. }
  9415. declare module BABYLON {
  9416. class ShaderMaterial extends Material {
  9417. private _shaderPath;
  9418. private _options;
  9419. private _textures;
  9420. private _textureArrays;
  9421. private _floats;
  9422. private _ints;
  9423. private _floatsArrays;
  9424. private _colors3;
  9425. private _colors3Arrays;
  9426. private _colors4;
  9427. private _vectors2;
  9428. private _vectors3;
  9429. private _vectors4;
  9430. private _matrices;
  9431. private _matrices3x3;
  9432. private _matrices2x2;
  9433. private _vectors2Arrays;
  9434. private _vectors3Arrays;
  9435. private _cachedWorldViewMatrix;
  9436. private _renderId;
  9437. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  9438. getClassName(): string;
  9439. needAlphaBlending(): boolean;
  9440. needAlphaTesting(): boolean;
  9441. private _checkUniform(uniformName);
  9442. setTexture(name: string, texture: Texture): ShaderMaterial;
  9443. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  9444. setFloat(name: string, value: number): ShaderMaterial;
  9445. setInt(name: string, value: number): ShaderMaterial;
  9446. setFloats(name: string, value: number[]): ShaderMaterial;
  9447. setColor3(name: string, value: Color3): ShaderMaterial;
  9448. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  9449. setColor4(name: string, value: Color4): ShaderMaterial;
  9450. setVector2(name: string, value: Vector2): ShaderMaterial;
  9451. setVector3(name: string, value: Vector3): ShaderMaterial;
  9452. setVector4(name: string, value: Vector4): ShaderMaterial;
  9453. setMatrix(name: string, value: Matrix): ShaderMaterial;
  9454. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  9455. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  9456. setArray2(name: string, value: number[]): ShaderMaterial;
  9457. setArray3(name: string, value: number[]): ShaderMaterial;
  9458. private _checkCache(scene, mesh?, useInstances?);
  9459. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  9460. bindOnlyWorldMatrix(world: Matrix): void;
  9461. bind(world: Matrix, mesh?: Mesh): void;
  9462. getActiveTextures(): BaseTexture[];
  9463. hasTexture(texture: BaseTexture): boolean;
  9464. clone(name: string): ShaderMaterial;
  9465. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9466. serialize(): any;
  9467. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  9468. }
  9469. }
  9470. declare module BABYLON {
  9471. class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  9472. MAINUV1: boolean;
  9473. MAINUV2: boolean;
  9474. DIFFUSE: boolean;
  9475. DIFFUSEDIRECTUV: number;
  9476. AMBIENT: boolean;
  9477. AMBIENTDIRECTUV: number;
  9478. OPACITY: boolean;
  9479. OPACITYDIRECTUV: number;
  9480. OPACITYRGB: boolean;
  9481. REFLECTION: boolean;
  9482. EMISSIVE: boolean;
  9483. EMISSIVEDIRECTUV: number;
  9484. SPECULAR: boolean;
  9485. SPECULARDIRECTUV: number;
  9486. BUMP: boolean;
  9487. BUMPDIRECTUV: number;
  9488. PARALLAX: boolean;
  9489. PARALLAXOCCLUSION: boolean;
  9490. SPECULAROVERALPHA: boolean;
  9491. CLIPPLANE: boolean;
  9492. ALPHATEST: boolean;
  9493. DEPTHPREPASS: boolean;
  9494. ALPHAFROMDIFFUSE: boolean;
  9495. POINTSIZE: boolean;
  9496. FOG: boolean;
  9497. SPECULARTERM: boolean;
  9498. DIFFUSEFRESNEL: boolean;
  9499. OPACITYFRESNEL: boolean;
  9500. REFLECTIONFRESNEL: boolean;
  9501. REFRACTIONFRESNEL: boolean;
  9502. EMISSIVEFRESNEL: boolean;
  9503. FRESNEL: boolean;
  9504. NORMAL: boolean;
  9505. UV1: boolean;
  9506. UV2: boolean;
  9507. VERTEXCOLOR: boolean;
  9508. VERTEXALPHA: boolean;
  9509. NUM_BONE_INFLUENCERS: number;
  9510. BonesPerMesh: number;
  9511. INSTANCES: boolean;
  9512. GLOSSINESS: boolean;
  9513. ROUGHNESS: boolean;
  9514. EMISSIVEASILLUMINATION: boolean;
  9515. LINKEMISSIVEWITHDIFFUSE: boolean;
  9516. REFLECTIONFRESNELFROMSPECULAR: boolean;
  9517. LIGHTMAP: boolean;
  9518. LIGHTMAPDIRECTUV: number;
  9519. USELIGHTMAPASSHADOWMAP: boolean;
  9520. REFLECTIONMAP_3D: boolean;
  9521. REFLECTIONMAP_SPHERICAL: boolean;
  9522. REFLECTIONMAP_PLANAR: boolean;
  9523. REFLECTIONMAP_CUBIC: boolean;
  9524. REFLECTIONMAP_PROJECTION: boolean;
  9525. REFLECTIONMAP_SKYBOX: boolean;
  9526. REFLECTIONMAP_EXPLICIT: boolean;
  9527. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  9528. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  9529. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  9530. INVERTCUBICMAP: boolean;
  9531. LOGARITHMICDEPTH: boolean;
  9532. REFRACTION: boolean;
  9533. REFRACTIONMAP_3D: boolean;
  9534. REFLECTIONOVERALPHA: boolean;
  9535. TWOSIDEDLIGHTING: boolean;
  9536. SHADOWFLOAT: boolean;
  9537. MORPHTARGETS: boolean;
  9538. MORPHTARGETS_NORMAL: boolean;
  9539. MORPHTARGETS_TANGENT: boolean;
  9540. NUM_MORPH_INFLUENCERS: number;
  9541. NONUNIFORMSCALING: boolean;
  9542. PREMULTIPLYALPHA: boolean;
  9543. IMAGEPROCESSING: boolean;
  9544. VIGNETTE: boolean;
  9545. VIGNETTEBLENDMODEMULTIPLY: boolean;
  9546. VIGNETTEBLENDMODEOPAQUE: boolean;
  9547. TONEMAPPING: boolean;
  9548. CONTRAST: boolean;
  9549. COLORCURVES: boolean;
  9550. COLORGRADING: boolean;
  9551. COLORGRADING3D: boolean;
  9552. SAMPLER3DGREENDEPTH: boolean;
  9553. SAMPLER3DBGRMAP: boolean;
  9554. IMAGEPROCESSINGPOSTPROCESS: boolean;
  9555. EXPOSURE: boolean;
  9556. constructor();
  9557. setReflectionMode(modeToEnable: string): void;
  9558. }
  9559. class StandardMaterial extends PushMaterial {
  9560. private _diffuseTexture;
  9561. diffuseTexture: Nullable<BaseTexture>;
  9562. private _ambientTexture;
  9563. ambientTexture: Nullable<BaseTexture>;
  9564. private _opacityTexture;
  9565. opacityTexture: Nullable<BaseTexture>;
  9566. private _reflectionTexture;
  9567. reflectionTexture: Nullable<BaseTexture>;
  9568. private _emissiveTexture;
  9569. emissiveTexture: Nullable<BaseTexture>;
  9570. private _specularTexture;
  9571. specularTexture: Nullable<BaseTexture>;
  9572. private _bumpTexture;
  9573. bumpTexture: Nullable<BaseTexture>;
  9574. private _lightmapTexture;
  9575. lightmapTexture: Nullable<BaseTexture>;
  9576. private _refractionTexture;
  9577. refractionTexture: Nullable<BaseTexture>;
  9578. ambientColor: Color3;
  9579. diffuseColor: Color3;
  9580. specularColor: Color3;
  9581. emissiveColor: Color3;
  9582. specularPower: number;
  9583. private _useAlphaFromDiffuseTexture;
  9584. useAlphaFromDiffuseTexture: boolean;
  9585. private _useEmissiveAsIllumination;
  9586. useEmissiveAsIllumination: boolean;
  9587. private _linkEmissiveWithDiffuse;
  9588. linkEmissiveWithDiffuse: boolean;
  9589. private _useSpecularOverAlpha;
  9590. useSpecularOverAlpha: boolean;
  9591. private _useReflectionOverAlpha;
  9592. useReflectionOverAlpha: boolean;
  9593. private _disableLighting;
  9594. disableLighting: boolean;
  9595. private _useParallax;
  9596. useParallax: boolean;
  9597. private _useParallaxOcclusion;
  9598. useParallaxOcclusion: boolean;
  9599. parallaxScaleBias: number;
  9600. private _roughness;
  9601. roughness: number;
  9602. indexOfRefraction: number;
  9603. invertRefractionY: boolean;
  9604. private _useLightmapAsShadowmap;
  9605. useLightmapAsShadowmap: boolean;
  9606. private _diffuseFresnelParameters;
  9607. diffuseFresnelParameters: FresnelParameters;
  9608. private _opacityFresnelParameters;
  9609. opacityFresnelParameters: FresnelParameters;
  9610. private _reflectionFresnelParameters;
  9611. reflectionFresnelParameters: FresnelParameters;
  9612. private _refractionFresnelParameters;
  9613. refractionFresnelParameters: FresnelParameters;
  9614. private _emissiveFresnelParameters;
  9615. emissiveFresnelParameters: FresnelParameters;
  9616. private _useReflectionFresnelFromSpecular;
  9617. useReflectionFresnelFromSpecular: boolean;
  9618. private _useGlossinessFromSpecularMapAlpha;
  9619. useGlossinessFromSpecularMapAlpha: boolean;
  9620. private _maxSimultaneousLights;
  9621. maxSimultaneousLights: number;
  9622. /**
  9623. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  9624. */
  9625. private _invertNormalMapX;
  9626. invertNormalMapX: boolean;
  9627. /**
  9628. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  9629. */
  9630. private _invertNormalMapY;
  9631. invertNormalMapY: boolean;
  9632. /**
  9633. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  9634. */
  9635. private _twoSidedLighting;
  9636. twoSidedLighting: boolean;
  9637. /**
  9638. * Default configuration related to image processing available in the standard Material.
  9639. */
  9640. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  9641. /**
  9642. * Gets the image processing configuration used either in this material.
  9643. */
  9644. /**
  9645. * Sets the Default image processing configuration used either in the this material.
  9646. *
  9647. * If sets to null, the scene one is in use.
  9648. */
  9649. imageProcessingConfiguration: ImageProcessingConfiguration;
  9650. /**
  9651. * Keep track of the image processing observer to allow dispose and replace.
  9652. */
  9653. private _imageProcessingObserver;
  9654. /**
  9655. * Attaches a new image processing configuration to the Standard Material.
  9656. * @param configuration
  9657. */
  9658. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  9659. /**
  9660. * Gets wether the color curves effect is enabled.
  9661. */
  9662. /**
  9663. * Sets wether the color curves effect is enabled.
  9664. */
  9665. cameraColorCurvesEnabled: boolean;
  9666. /**
  9667. * Gets wether the color grading effect is enabled.
  9668. */
  9669. /**
  9670. * Gets wether the color grading effect is enabled.
  9671. */
  9672. cameraColorGradingEnabled: boolean;
  9673. /**
  9674. * Gets wether tonemapping is enabled or not.
  9675. */
  9676. /**
  9677. * Sets wether tonemapping is enabled or not
  9678. */
  9679. cameraToneMappingEnabled: boolean;
  9680. /**
  9681. * The camera exposure used on this material.
  9682. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  9683. * This corresponds to a photographic exposure.
  9684. */
  9685. /**
  9686. * The camera exposure used on this material.
  9687. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  9688. * This corresponds to a photographic exposure.
  9689. */
  9690. cameraExposure: number;
  9691. /**
  9692. * Gets The camera contrast used on this material.
  9693. */
  9694. /**
  9695. * Sets The camera contrast used on this material.
  9696. */
  9697. cameraContrast: number;
  9698. /**
  9699. * Gets the Color Grading 2D Lookup Texture.
  9700. */
  9701. /**
  9702. * Sets the Color Grading 2D Lookup Texture.
  9703. */
  9704. cameraColorGradingTexture: Nullable<BaseTexture>;
  9705. /**
  9706. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9707. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9708. * 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;
  9709. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9710. */
  9711. /**
  9712. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  9713. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  9714. * 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;
  9715. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  9716. */
  9717. cameraColorCurves: Nullable<ColorCurves>;
  9718. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  9719. protected _renderTargets: SmartArray<RenderTargetTexture>;
  9720. protected _worldViewProjectionMatrix: Matrix;
  9721. protected _globalAmbientColor: Color3;
  9722. protected _useLogarithmicDepth: boolean;
  9723. constructor(name: string, scene: Scene);
  9724. getClassName(): string;
  9725. useLogarithmicDepth: boolean;
  9726. needAlphaBlending(): boolean;
  9727. needAlphaTesting(): boolean;
  9728. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  9729. getAlphaTestTexture(): Nullable<BaseTexture>;
  9730. /**
  9731. * Child classes can use it to update shaders
  9732. */
  9733. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  9734. buildUniformLayout(): void;
  9735. unbind(): void;
  9736. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  9737. getAnimatables(): IAnimatable[];
  9738. getActiveTextures(): BaseTexture[];
  9739. hasTexture(texture: BaseTexture): boolean;
  9740. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  9741. clone(name: string): StandardMaterial;
  9742. serialize(): any;
  9743. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  9744. static _DiffuseTextureEnabled: boolean;
  9745. static DiffuseTextureEnabled: boolean;
  9746. static _AmbientTextureEnabled: boolean;
  9747. static AmbientTextureEnabled: boolean;
  9748. static _OpacityTextureEnabled: boolean;
  9749. static OpacityTextureEnabled: boolean;
  9750. static _ReflectionTextureEnabled: boolean;
  9751. static ReflectionTextureEnabled: boolean;
  9752. static _EmissiveTextureEnabled: boolean;
  9753. static EmissiveTextureEnabled: boolean;
  9754. static _SpecularTextureEnabled: boolean;
  9755. static SpecularTextureEnabled: boolean;
  9756. static _BumpTextureEnabled: boolean;
  9757. static BumpTextureEnabled: boolean;
  9758. static _LightmapTextureEnabled: boolean;
  9759. static LightmapTextureEnabled: boolean;
  9760. static _RefractionTextureEnabled: boolean;
  9761. static RefractionTextureEnabled: boolean;
  9762. static _ColorGradingTextureEnabled: boolean;
  9763. static ColorGradingTextureEnabled: boolean;
  9764. static _FresnelEnabled: boolean;
  9765. static FresnelEnabled: boolean;
  9766. }
  9767. }
  9768. declare module BABYLON {
  9769. class UniformBuffer {
  9770. private _engine;
  9771. private _buffer;
  9772. private _data;
  9773. private _bufferData;
  9774. private _dynamic?;
  9775. private _uniformLocations;
  9776. private _uniformSizes;
  9777. private _uniformLocationPointer;
  9778. private _needSync;
  9779. private _noUBO;
  9780. private _currentEffect;
  9781. private static _MAX_UNIFORM_SIZE;
  9782. private static _tempBuffer;
  9783. /**
  9784. * Wrapper for updateUniform.
  9785. * @method updateMatrix3x3
  9786. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9787. * @param {Float32Array} matrix
  9788. */
  9789. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  9790. /**
  9791. * Wrapper for updateUniform.
  9792. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9793. * @param {Float32Array} matrix
  9794. */
  9795. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  9796. /**
  9797. * Wrapper for updateUniform.
  9798. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9799. * @param {number} x
  9800. */
  9801. updateFloat: (name: string, x: number) => void;
  9802. /**
  9803. * Wrapper for updateUniform.
  9804. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9805. * @param {number} x
  9806. * @param {number} y
  9807. * @param {string} [suffix] Suffix to add to the uniform name.
  9808. */
  9809. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  9810. /**
  9811. * Wrapper for updateUniform.
  9812. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9813. * @param {number} x
  9814. * @param {number} y
  9815. * @param {number} z
  9816. * @param {string} [suffix] Suffix to add to the uniform name.
  9817. */
  9818. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  9819. /**
  9820. * Wrapper for updateUniform.
  9821. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9822. * @param {number} x
  9823. * @param {number} y
  9824. * @param {number} z
  9825. * @param {number} w
  9826. * @param {string} [suffix] Suffix to add to the uniform name.
  9827. */
  9828. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  9829. /**
  9830. * Wrapper for updateUniform.
  9831. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9832. * @param {Matrix} A 4x4 matrix.
  9833. */
  9834. updateMatrix: (name: string, mat: Matrix) => void;
  9835. /**
  9836. * Wrapper for updateUniform.
  9837. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9838. * @param {Vector3} vector
  9839. */
  9840. updateVector3: (name: string, vector: Vector3) => void;
  9841. /**
  9842. * Wrapper for updateUniform.
  9843. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9844. * @param {Vector4} vector
  9845. */
  9846. updateVector4: (name: string, vector: Vector4) => void;
  9847. /**
  9848. * Wrapper for updateUniform.
  9849. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9850. * @param {Color3} color
  9851. * @param {string} [suffix] Suffix to add to the uniform name.
  9852. */
  9853. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  9854. /**
  9855. * Wrapper for updateUniform.
  9856. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9857. * @param {Color3} color
  9858. * @param {number} alpha
  9859. * @param {string} [suffix] Suffix to add to the uniform name.
  9860. */
  9861. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  9862. /**
  9863. * Uniform buffer objects.
  9864. *
  9865. * Handles blocks of uniform on the GPU.
  9866. *
  9867. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  9868. *
  9869. * For more information, please refer to :
  9870. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  9871. */
  9872. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  9873. /**
  9874. * Indicates if the buffer is using the WebGL2 UBO implementation,
  9875. * or just falling back on setUniformXXX calls.
  9876. */
  9877. readonly useUbo: boolean;
  9878. /**
  9879. * Indicates if the WebGL underlying uniform buffer is in sync
  9880. * with the javascript cache data.
  9881. */
  9882. readonly isSync: boolean;
  9883. /**
  9884. * Indicates if the WebGL underlying uniform buffer is dynamic.
  9885. * Also, a dynamic UniformBuffer will disable cache verification and always
  9886. * update the underlying WebGL uniform buffer to the GPU.
  9887. */
  9888. isDynamic(): boolean;
  9889. /**
  9890. * The data cache on JS side.
  9891. */
  9892. getData(): Float32Array;
  9893. /**
  9894. * The underlying WebGL Uniform buffer.
  9895. */
  9896. getBuffer(): Nullable<WebGLBuffer>;
  9897. /**
  9898. * std140 layout specifies how to align data within an UBO structure.
  9899. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  9900. * for specs.
  9901. */
  9902. private _fillAlignment(size);
  9903. /**
  9904. * Adds an uniform in the buffer.
  9905. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  9906. * for the layout to be correct !
  9907. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9908. * @param {number|number[]} size Data size, or data directly.
  9909. */
  9910. addUniform(name: string, size: number | number[]): void;
  9911. /**
  9912. * Wrapper for addUniform.
  9913. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9914. * @param {Matrix} mat A 4x4 matrix.
  9915. */
  9916. addMatrix(name: string, mat: Matrix): void;
  9917. /**
  9918. * Wrapper for addUniform.
  9919. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9920. * @param {number} x
  9921. * @param {number} y
  9922. */
  9923. addFloat2(name: string, x: number, y: number): void;
  9924. /**
  9925. * Wrapper for addUniform.
  9926. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9927. * @param {number} x
  9928. * @param {number} y
  9929. * @param {number} z
  9930. */
  9931. addFloat3(name: string, x: number, y: number, z: number): void;
  9932. /**
  9933. * Wrapper for addUniform.
  9934. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9935. * @param {Color3} color
  9936. */
  9937. addColor3(name: string, color: Color3): void;
  9938. /**
  9939. * Wrapper for addUniform.
  9940. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9941. * @param {Color3} color
  9942. * @param {number} alpha
  9943. */
  9944. addColor4(name: string, color: Color3, alpha: number): void;
  9945. /**
  9946. * Wrapper for addUniform.
  9947. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9948. * @param {Vector3} vector
  9949. */
  9950. addVector3(name: string, vector: Vector3): void;
  9951. /**
  9952. * Wrapper for addUniform.
  9953. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9954. */
  9955. addMatrix3x3(name: string): void;
  9956. /**
  9957. * Wrapper for addUniform.
  9958. * @param {string} name Name of the uniform, as used in the uniform block in the shader.
  9959. */
  9960. addMatrix2x2(name: string): void;
  9961. /**
  9962. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  9963. */
  9964. create(): void;
  9965. _rebuild(): void;
  9966. /**
  9967. * Updates the WebGL Uniform Buffer on the GPU.
  9968. * If the `dynamic` flag is set to true, no cache comparison is done.
  9969. * Otherwise, the buffer will be updated only if the cache differs.
  9970. */
  9971. update(): void;
  9972. /**
  9973. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  9974. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  9975. * @param {number[]|Float32Array} data Flattened data
  9976. * @param {number} size Size of the data.
  9977. */
  9978. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  9979. private _updateMatrix3x3ForUniform(name, matrix);
  9980. private _updateMatrix3x3ForEffect(name, matrix);
  9981. private _updateMatrix2x2ForEffect(name, matrix);
  9982. private _updateMatrix2x2ForUniform(name, matrix);
  9983. private _updateFloatForEffect(name, x);
  9984. private _updateFloatForUniform(name, x);
  9985. private _updateFloat2ForEffect(name, x, y, suffix?);
  9986. private _updateFloat2ForUniform(name, x, y, suffix?);
  9987. private _updateFloat3ForEffect(name, x, y, z, suffix?);
  9988. private _updateFloat3ForUniform(name, x, y, z, suffix?);
  9989. private _updateFloat4ForEffect(name, x, y, z, w, suffix?);
  9990. private _updateFloat4ForUniform(name, x, y, z, w, suffix?);
  9991. private _updateMatrixForEffect(name, mat);
  9992. private _updateMatrixForUniform(name, mat);
  9993. private _updateVector3ForEffect(name, vector);
  9994. private _updateVector3ForUniform(name, vector);
  9995. private _updateVector4ForEffect(name, vector);
  9996. private _updateVector4ForUniform(name, vector);
  9997. private _updateColor3ForEffect(name, color, suffix?);
  9998. private _updateColor3ForUniform(name, color, suffix?);
  9999. private _updateColor4ForEffect(name, color, alpha, suffix?);
  10000. private _updateColor4ForUniform(name, color, alpha, suffix?);
  10001. /**
  10002. * Sets a sampler uniform on the effect.
  10003. * @param {string} name Name of the sampler.
  10004. * @param {Texture} texture
  10005. */
  10006. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  10007. /**
  10008. * Directly updates the value of the uniform in the cache AND on the GPU.
  10009. * @param {string} uniformName Name of the uniform, as used in the uniform block in the shader.
  10010. * @param {number[]|Float32Array} data Flattened data
  10011. */
  10012. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  10013. /**
  10014. * Binds this uniform buffer to an effect.
  10015. * @param {Effect} effect
  10016. * @param {string} name Name of the uniform block in the shader.
  10017. */
  10018. bindToEffect(effect: Effect, name: string): void;
  10019. /**
  10020. * Disposes the uniform buffer.
  10021. */
  10022. dispose(): void;
  10023. }
  10024. }
  10025. declare module BABYLON {
  10026. class MorphTarget {
  10027. name: string;
  10028. animations: Animation[];
  10029. private _positions;
  10030. private _normals;
  10031. private _tangents;
  10032. private _influence;
  10033. onInfluenceChanged: Observable<boolean>;
  10034. influence: number;
  10035. constructor(name: string, influence?: number);
  10036. readonly hasPositions: boolean;
  10037. readonly hasNormals: boolean;
  10038. readonly hasTangents: boolean;
  10039. setPositions(data: Nullable<FloatArray>): void;
  10040. getPositions(): Nullable<FloatArray>;
  10041. setNormals(data: Nullable<FloatArray>): void;
  10042. getNormals(): Nullable<FloatArray>;
  10043. setTangents(data: Nullable<FloatArray>): void;
  10044. getTangents(): Nullable<FloatArray>;
  10045. /**
  10046. * Serializes the current target into a Serialization object.
  10047. * Returns the serialized object.
  10048. */
  10049. serialize(): any;
  10050. static Parse(serializationObject: any): MorphTarget;
  10051. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  10052. }
  10053. }
  10054. declare module BABYLON {
  10055. class MorphTargetManager {
  10056. private _targets;
  10057. private _targetObservable;
  10058. private _activeTargets;
  10059. private _scene;
  10060. private _influences;
  10061. private _supportsNormals;
  10062. private _supportsTangents;
  10063. private _vertexCount;
  10064. private _uniqueId;
  10065. private _tempInfluences;
  10066. constructor(scene?: Nullable<Scene>);
  10067. readonly uniqueId: number;
  10068. readonly vertexCount: number;
  10069. readonly supportsNormals: boolean;
  10070. readonly supportsTangents: boolean;
  10071. readonly numTargets: number;
  10072. readonly numInfluencers: number;
  10073. readonly influences: Float32Array;
  10074. getActiveTarget(index: number): MorphTarget;
  10075. getTarget(index: number): MorphTarget;
  10076. addTarget(target: MorphTarget): void;
  10077. removeTarget(target: MorphTarget): void;
  10078. /**
  10079. * Serializes the current manager into a Serialization object.
  10080. * Returns the serialized object.
  10081. */
  10082. serialize(): any;
  10083. private _syncActiveTargets(needUpdate);
  10084. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  10085. }
  10086. }
  10087. declare module BABYLON {
  10088. class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  10089. static OCCLUSION_TYPE_NONE: number;
  10090. static OCCLUSION_TYPE_OPTIMISTIC: number;
  10091. static OCCLUSION_TYPE_STRICT: number;
  10092. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  10093. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  10094. static readonly BILLBOARDMODE_NONE: number;
  10095. static readonly BILLBOARDMODE_X: number;
  10096. static readonly BILLBOARDMODE_Y: number;
  10097. static readonly BILLBOARDMODE_Z: number;
  10098. static readonly BILLBOARDMODE_ALL: number;
  10099. private _facetPositions;
  10100. private _facetNormals;
  10101. private _facetPartitioning;
  10102. private _facetNb;
  10103. private _partitioningSubdivisions;
  10104. private _partitioningBBoxRatio;
  10105. private _facetDataEnabled;
  10106. private _facetParameters;
  10107. private _bbSize;
  10108. private _subDiv;
  10109. private _facetDepthSort;
  10110. private _facetDepthSortEnabled;
  10111. private _depthSortedIndices;
  10112. private _depthSortedFacets;
  10113. private _facetDepthSortFunction;
  10114. private _facetDepthSortFrom;
  10115. private _facetDepthSortOrigin;
  10116. private _invertedMatrix;
  10117. /**
  10118. * Read-only : the number of facets in the mesh
  10119. */
  10120. readonly facetNb: number;
  10121. /**
  10122. * The number (integer) of subdivisions per axis in the partioning space
  10123. */
  10124. partitioningSubdivisions: number;
  10125. /**
  10126. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  10127. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box.
  10128. */
  10129. partitioningBBoxRatio: number;
  10130. /**
  10131. * Boolean : must the facet be depth sorted on next call to `updateFacetData()` ?
  10132. * Works only for updatable meshes.
  10133. * Doesn't work with multi-materials.
  10134. */
  10135. mustDepthSortFacets: boolean;
  10136. /**
  10137. * The location (Vector3) where the facet depth sort must be computed from.
  10138. * By default, the active camera position.
  10139. * Used only when facet depth sort is enabled.
  10140. */
  10141. facetDepthSortFrom: Vector3;
  10142. /**
  10143. * Read-only boolean : is the feature facetData enabled ?
  10144. */
  10145. readonly isFacetDataEnabled: boolean;
  10146. _updateNonUniformScalingState(value: boolean): boolean;
  10147. /**
  10148. * An event triggered when this mesh collides with another one
  10149. * @type {BABYLON.Observable}
  10150. */
  10151. onCollideObservable: Observable<AbstractMesh>;
  10152. private _onCollideObserver;
  10153. onCollide: () => void;
  10154. /**
  10155. * An event triggered when the collision's position changes
  10156. * @type {BABYLON.Observable}
  10157. */
  10158. onCollisionPositionChangeObservable: Observable<Vector3>;
  10159. private _onCollisionPositionChangeObserver;
  10160. onCollisionPositionChange: () => void;
  10161. /**
  10162. * An event triggered when material is changed
  10163. * @type {BABYLON.Observable}
  10164. */
  10165. onMaterialChangedObservable: Observable<AbstractMesh>;
  10166. definedFacingForward: boolean;
  10167. /**
  10168. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  10169. * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  10170. * or
  10171. * 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.
  10172. * for more info check WebGl documentations
  10173. */
  10174. occlusionQueryAlgorithmType: number;
  10175. /**
  10176. * 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:
  10177. * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  10178. * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  10179. * 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.
  10180. */
  10181. occlusionType: number;
  10182. /**
  10183. * 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.
  10184. * The default value is -1 which means don't break the query and wait till the result.
  10185. */
  10186. occlusionRetryCount: number;
  10187. private _occlusionInternalRetryCounter;
  10188. protected _isOccluded: boolean;
  10189. /**
  10190. * Property isOccluded : 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.
  10191. */
  10192. isOccluded: boolean;
  10193. private _isOcclusionQueryInProgress;
  10194. /**
  10195. * Flag to check the progress status of the query
  10196. */
  10197. readonly isOcclusionQueryInProgress: boolean;
  10198. private _occlusionQuery;
  10199. visibility: number;
  10200. alphaIndex: number;
  10201. isVisible: boolean;
  10202. isPickable: boolean;
  10203. showBoundingBox: boolean;
  10204. showSubMeshesBoundingBox: boolean;
  10205. isBlocker: boolean;
  10206. enablePointerMoveEvents: boolean;
  10207. renderingGroupId: number;
  10208. private _material;
  10209. material: Nullable<Material>;
  10210. private _receiveShadows;
  10211. receiveShadows: boolean;
  10212. renderOutline: boolean;
  10213. outlineColor: Color3;
  10214. outlineWidth: number;
  10215. renderOverlay: boolean;
  10216. overlayColor: Color3;
  10217. overlayAlpha: number;
  10218. private _hasVertexAlpha;
  10219. hasVertexAlpha: boolean;
  10220. private _useVertexColors;
  10221. useVertexColors: boolean;
  10222. private _computeBonesUsingShaders;
  10223. computeBonesUsingShaders: boolean;
  10224. private _numBoneInfluencers;
  10225. numBoneInfluencers: number;
  10226. private _applyFog;
  10227. applyFog: boolean;
  10228. useOctreeForRenderingSelection: boolean;
  10229. useOctreeForPicking: boolean;
  10230. useOctreeForCollisions: boolean;
  10231. private _layerMask;
  10232. layerMask: number;
  10233. /**
  10234. * True if the mesh must be rendered in any case.
  10235. */
  10236. alwaysSelectAsActiveMesh: boolean;
  10237. /**
  10238. * This scene's action manager
  10239. * @type {BABYLON.ActionManager}
  10240. */
  10241. actionManager: Nullable<ActionManager>;
  10242. physicsImpostor: Nullable<PhysicsImpostor>;
  10243. private _checkCollisions;
  10244. private _collisionMask;
  10245. private _collisionGroup;
  10246. ellipsoid: Vector3;
  10247. ellipsoidOffset: Vector3;
  10248. private _collider;
  10249. private _oldPositionForCollisions;
  10250. private _diffPositionForCollisions;
  10251. collisionMask: number;
  10252. collisionGroup: number;
  10253. edgesWidth: number;
  10254. edgesColor: Color4;
  10255. _edgesRenderer: Nullable<EdgesRenderer>;
  10256. private _collisionsTransformMatrix;
  10257. private _collisionsScalingMatrix;
  10258. _masterMesh: Nullable<AbstractMesh>;
  10259. _boundingInfo: Nullable<BoundingInfo>;
  10260. _isDisposed: boolean;
  10261. _renderId: number;
  10262. subMeshes: SubMesh[];
  10263. _submeshesOctree: Octree<SubMesh>;
  10264. _intersectionsInProgress: AbstractMesh[];
  10265. _unIndexed: boolean;
  10266. _lightSources: Light[];
  10267. readonly _positions: Nullable<Vector3[]>;
  10268. _waitingActions: any;
  10269. _waitingFreezeWorldMatrix: Nullable<boolean>;
  10270. private _skeleton;
  10271. _bonesTransformMatrices: Nullable<Float32Array>;
  10272. skeleton: Nullable<Skeleton>;
  10273. constructor(name: string, scene?: Nullable<Scene>);
  10274. /**
  10275. * Boolean : true if the mesh has been disposed.
  10276. */
  10277. isDisposed(): boolean;
  10278. /**
  10279. * Returns the string "AbstractMesh"
  10280. */
  10281. getClassName(): string;
  10282. /**
  10283. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  10284. */
  10285. toString(fullDetails?: boolean): string;
  10286. _rebuild(): void;
  10287. _resyncLightSources(): void;
  10288. _resyncLighSource(light: Light): void;
  10289. _removeLightSource(light: Light): void;
  10290. private _markSubMeshesAsDirty(func);
  10291. _markSubMeshesAsLightDirty(): void;
  10292. _markSubMeshesAsAttributesDirty(): void;
  10293. _markSubMeshesAsMiscDirty(): void;
  10294. /**
  10295. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  10296. * Default : (1.0, 1.0, 1.0)
  10297. */
  10298. /**
  10299. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  10300. * Default : (1.0, 1.0, 1.0)
  10301. */
  10302. scaling: Vector3;
  10303. /**
  10304. * Disables the mesh edger rendering mode.
  10305. * Returns the AbstractMesh.
  10306. */
  10307. disableEdgesRendering(): AbstractMesh;
  10308. /**
  10309. * Enables the edge rendering mode on the mesh.
  10310. * This mode makes the mesh edges visible.
  10311. * Returns the AbstractMesh.
  10312. */
  10313. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  10314. /**
  10315. * Returns true if the mesh is blocked. Used by the class Mesh.
  10316. * Returns the boolean `false` by default.
  10317. */
  10318. readonly isBlocked: boolean;
  10319. /**
  10320. * Returns the mesh itself by default, used by the class Mesh.
  10321. * Returned type : AbstractMesh
  10322. */
  10323. getLOD(camera: Camera): AbstractMesh;
  10324. /**
  10325. * Returns 0 by default, used by the class Mesh.
  10326. * Returns an integer.
  10327. */
  10328. getTotalVertices(): number;
  10329. /**
  10330. * Returns null by default, used by the class Mesh.
  10331. * Returned type : integer array
  10332. */
  10333. getIndices(): Nullable<IndicesArray>;
  10334. /**
  10335. * Returns the array of the requested vertex data kind. Used by the class Mesh. Returns null here.
  10336. * Returned type : float array or Float32Array
  10337. */
  10338. getVerticesData(kind: string): Nullable<FloatArray>;
  10339. /**
  10340. * Sets the vertex data of the mesh geometry for the requested `kind`.
  10341. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  10342. * The `data` are either a numeric array either a Float32Array.
  10343. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  10344. * 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).
  10345. * Note that a new underlying VertexBuffer object is created each call.
  10346. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  10347. *
  10348. * Possible `kind` values :
  10349. * - BABYLON.VertexBuffer.PositionKind
  10350. * - BABYLON.VertexBuffer.UVKind
  10351. * - BABYLON.VertexBuffer.UV2Kind
  10352. * - BABYLON.VertexBuffer.UV3Kind
  10353. * - BABYLON.VertexBuffer.UV4Kind
  10354. * - BABYLON.VertexBuffer.UV5Kind
  10355. * - BABYLON.VertexBuffer.UV6Kind
  10356. * - BABYLON.VertexBuffer.ColorKind
  10357. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10358. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10359. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10360. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10361. *
  10362. * Returns the Mesh.
  10363. */
  10364. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  10365. /**
  10366. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  10367. * If the mesh has no geometry, it is simply returned as it is.
  10368. * The `data` are either a numeric array either a Float32Array.
  10369. * No new underlying VertexBuffer object is created.
  10370. * 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.
  10371. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  10372. *
  10373. * Possible `kind` values :
  10374. * - BABYLON.VertexBuffer.PositionKind
  10375. * - BABYLON.VertexBuffer.UVKind
  10376. * - BABYLON.VertexBuffer.UV2Kind
  10377. * - BABYLON.VertexBuffer.UV3Kind
  10378. * - BABYLON.VertexBuffer.UV4Kind
  10379. * - BABYLON.VertexBuffer.UV5Kind
  10380. * - BABYLON.VertexBuffer.UV6Kind
  10381. * - BABYLON.VertexBuffer.ColorKind
  10382. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10383. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10384. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10385. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10386. *
  10387. * Returns the Mesh.
  10388. */
  10389. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  10390. /**
  10391. * Sets the mesh indices.
  10392. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  10393. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  10394. * This method creates a new index buffer each call.
  10395. * Returns the Mesh.
  10396. */
  10397. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  10398. /** Returns false by default, used by the class Mesh.
  10399. * Returns a boolean
  10400. */
  10401. isVerticesDataPresent(kind: string): boolean;
  10402. /**
  10403. * Returns the mesh BoundingInfo object or creates a new one and returns it if undefined.
  10404. * Returns a BoundingInfo
  10405. */
  10406. getBoundingInfo(): BoundingInfo;
  10407. /**
  10408. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units).
  10409. * @param includeDescendants Take the hierarchy's bounding box instead of the mesh's bounding box.
  10410. */
  10411. normalizeToUnitCube(includeDescendants?: boolean): AbstractMesh;
  10412. /**
  10413. * Sets a mesh new object BoundingInfo.
  10414. * Returns the AbstractMesh.
  10415. */
  10416. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  10417. readonly useBones: boolean;
  10418. _preActivate(): void;
  10419. _preActivateForIntermediateRendering(renderId: number): void;
  10420. _activate(renderId: number): void;
  10421. /**
  10422. * Returns the latest update of the World matrix
  10423. * Returns a Matrix.
  10424. */
  10425. getWorldMatrix(): Matrix;
  10426. /**
  10427. * Returns the latest update of the World matrix determinant.
  10428. */
  10429. protected _getWorldMatrixDeterminant(): number;
  10430. /**
  10431. * Perform relative position change from the point of view of behind the front of the mesh.
  10432. * This is performed taking into account the meshes current rotation, so you do not have to care.
  10433. * Supports definition of mesh facing forward or backward.
  10434. * @param {number} amountRight
  10435. * @param {number} amountUp
  10436. * @param {number} amountForward
  10437. *
  10438. * Returns the AbstractMesh.
  10439. */
  10440. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  10441. /**
  10442. * Calculate relative position change from the point of view of behind the front of the mesh.
  10443. * This is performed taking into account the meshes current rotation, so you do not have to care.
  10444. * Supports definition of mesh facing forward or backward.
  10445. * @param {number} amountRight
  10446. * @param {number} amountUp
  10447. * @param {number} amountForward
  10448. *
  10449. * Returns a new Vector3.
  10450. */
  10451. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  10452. /**
  10453. * Perform relative rotation change from the point of view of behind the front of the mesh.
  10454. * Supports definition of mesh facing forward or backward.
  10455. * @param {number} flipBack
  10456. * @param {number} twirlClockwise
  10457. * @param {number} tiltRight
  10458. *
  10459. * Returns the AbstractMesh.
  10460. */
  10461. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  10462. /**
  10463. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  10464. * Supports definition of mesh facing forward or backward.
  10465. * @param {number} flipBack
  10466. * @param {number} twirlClockwise
  10467. * @param {number} tiltRight
  10468. *
  10469. * Returns a new Vector3.
  10470. */
  10471. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  10472. /**
  10473. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  10474. * @param includeDescendants Include bounding info from descendants as well (true by default).
  10475. */
  10476. getHierarchyBoundingVectors(includeDescendants?: boolean): {
  10477. min: Vector3;
  10478. max: Vector3;
  10479. };
  10480. /**
  10481. * Updates the mesh BoundingInfo object and all its children BoundingInfo objects also.
  10482. * Returns the AbstractMesh.
  10483. */
  10484. _updateBoundingInfo(): AbstractMesh;
  10485. /**
  10486. * Update a mesh's children BoundingInfo objects only.
  10487. * Returns the AbstractMesh.
  10488. */
  10489. _updateSubMeshesBoundingInfo(matrix: Matrix): AbstractMesh;
  10490. protected _afterComputeWorldMatrix(): void;
  10491. /**
  10492. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  10493. * A mesh is in the frustum if its bounding box intersects the frustum.
  10494. * Boolean returned.
  10495. */
  10496. isInFrustum(frustumPlanes: Plane[]): boolean;
  10497. /**
  10498. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  10499. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  10500. * Boolean returned.
  10501. */
  10502. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  10503. /**
  10504. * True if the mesh intersects another mesh or a SolidParticle object.
  10505. * 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)
  10506. * includeDescendants can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  10507. * Returns a boolean.
  10508. */
  10509. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  10510. /**
  10511. * Returns true if the passed point (Vector3) is inside the mesh bounding box.
  10512. * Returns a boolean.
  10513. */
  10514. intersectsPoint(point: Vector3): boolean;
  10515. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  10516. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  10517. /**
  10518. * Returns the distance from the mesh to the active camera.
  10519. * Returns a float.
  10520. */
  10521. getDistanceToCamera(camera?: Nullable<Camera>): number;
  10522. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  10523. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  10524. /**
  10525. * Property checkCollisions : Boolean, whether the camera should check the collisions against the mesh.
  10526. * Default `false`.
  10527. */
  10528. checkCollisions: boolean;
  10529. /**
  10530. * Gets Collider object used to compute collisions (not physics)
  10531. */
  10532. readonly collider: Collider;
  10533. moveWithCollisions(displacement: Vector3): AbstractMesh;
  10534. private _onCollisionPositionChange;
  10535. /**
  10536. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  10537. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree.
  10538. * Returns an Octree of submeshes.
  10539. */
  10540. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  10541. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  10542. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  10543. _checkCollision(collider: Collider): AbstractMesh;
  10544. _generatePointsArray(): boolean;
  10545. /**
  10546. * Checks if the passed Ray intersects with the mesh.
  10547. * Returns an object PickingInfo.
  10548. */
  10549. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  10550. /**
  10551. * Clones the mesh, used by the class Mesh.
  10552. * Just returns `null` for an AbstractMesh.
  10553. */
  10554. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  10555. /**
  10556. * Disposes all the mesh submeshes.
  10557. * Returns the AbstractMesh.
  10558. */
  10559. releaseSubMeshes(): AbstractMesh;
  10560. /**
  10561. * Disposes the AbstractMesh.
  10562. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  10563. * Returns nothing.
  10564. */
  10565. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10566. /**
  10567. * Adds the passed mesh as a child to the current mesh.
  10568. * Returns the AbstractMesh.
  10569. */
  10570. addChild(mesh: AbstractMesh): AbstractMesh;
  10571. /**
  10572. * Removes the passed mesh from the current mesh children list.
  10573. * Returns the AbstractMesh.
  10574. */
  10575. removeChild(mesh: AbstractMesh): AbstractMesh;
  10576. /**
  10577. * Initialize the facet data arrays : facetNormals, facetPositions and facetPartitioning.
  10578. * Returns the AbstractMesh.
  10579. */
  10580. private _initFacetData();
  10581. /**
  10582. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  10583. * This method can be called within the render loop.
  10584. * 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.
  10585. * Returns the AbstractMesh.
  10586. */
  10587. updateFacetData(): AbstractMesh;
  10588. /**
  10589. * Returns the facetLocalNormals array.
  10590. * The normals are expressed in the mesh local space.
  10591. */
  10592. getFacetLocalNormals(): Vector3[];
  10593. /**
  10594. * Returns the facetLocalPositions array.
  10595. * The facet positions are expressed in the mesh local space.
  10596. */
  10597. getFacetLocalPositions(): Vector3[];
  10598. /**
  10599. * Returns the facetLocalPartioning array.
  10600. */
  10601. getFacetLocalPartitioning(): number[][];
  10602. /**
  10603. * Returns the i-th facet position in the world system.
  10604. * This method allocates a new Vector3 per call.
  10605. */
  10606. getFacetPosition(i: number): Vector3;
  10607. /**
  10608. * Sets the reference Vector3 with the i-th facet position in the world system.
  10609. * Returns the AbstractMesh.
  10610. */
  10611. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  10612. /**
  10613. * Returns the i-th facet normal in the world system.
  10614. * This method allocates a new Vector3 per call.
  10615. */
  10616. getFacetNormal(i: number): Vector3;
  10617. /**
  10618. * Sets the reference Vector3 with the i-th facet normal in the world system.
  10619. * Returns the AbstractMesh.
  10620. */
  10621. getFacetNormalToRef(i: number, ref: Vector3): this;
  10622. /**
  10623. * 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).
  10624. */
  10625. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  10626. /**
  10627. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found.
  10628. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) World projection on the facet.
  10629. * If checkFace is 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.
  10630. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  10631. * 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.
  10632. */
  10633. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  10634. /**
  10635. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found.
  10636. * If the parameter projected (vector3) is passed, it is set as the (x,y,z) local projection on the facet.
  10637. * If checkFace is 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.
  10638. * If facing and checkFace are true, only the facet "facing" to (x, y, z) are returned : positive dot (x, y, z) * facet position.
  10639. * 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.
  10640. */
  10641. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  10642. /**
  10643. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  10644. */
  10645. getFacetDataParameters(): any;
  10646. /**
  10647. * Disables the feature FacetData and frees the related memory.
  10648. * Returns the AbstractMesh.
  10649. */
  10650. disableFacetData(): AbstractMesh;
  10651. /**
  10652. * Updates the AbstractMesh indices array. Actually, used by the Mesh object.
  10653. * Returns the mesh.
  10654. */
  10655. updateIndices(indices: IndicesArray): AbstractMesh;
  10656. /**
  10657. * The mesh Geometry. Actually used by the Mesh object.
  10658. * Returns a blank geometry object.
  10659. */
  10660. /**
  10661. * Creates new normals data for the mesh.
  10662. * @param updatable.
  10663. */
  10664. createNormals(updatable: boolean): void;
  10665. /**
  10666. * Align the mesh with a normal.
  10667. * Returns the mesh.
  10668. */
  10669. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  10670. protected checkOcclusionQuery(): void;
  10671. }
  10672. }
  10673. declare module BABYLON {
  10674. class Buffer {
  10675. private _engine;
  10676. private _buffer;
  10677. private _data;
  10678. private _updatable;
  10679. private _strideSize;
  10680. private _instanced;
  10681. private _instanceDivisor;
  10682. constructor(engine: any, data: FloatArray, updatable: boolean, stride: number, postponeInternalCreation?: boolean, instanced?: boolean);
  10683. createVertexBuffer(kind: string, offset: number, size: number, stride?: number): VertexBuffer;
  10684. isUpdatable(): boolean;
  10685. getData(): Nullable<FloatArray>;
  10686. getBuffer(): Nullable<WebGLBuffer>;
  10687. getStrideSize(): number;
  10688. getIsInstanced(): boolean;
  10689. instanceDivisor: number;
  10690. create(data?: Nullable<FloatArray>): void;
  10691. _rebuild(): void;
  10692. update(data: FloatArray): void;
  10693. updateDirectly(data: Float32Array, offset: number, vertexCount?: number): void;
  10694. dispose(): void;
  10695. }
  10696. }
  10697. declare module BABYLON {
  10698. class CSG {
  10699. private polygons;
  10700. matrix: Matrix;
  10701. position: Vector3;
  10702. rotation: Vector3;
  10703. rotationQuaternion: Nullable<Quaternion>;
  10704. scaling: Vector3;
  10705. static FromMesh(mesh: Mesh): CSG;
  10706. private static FromPolygons(polygons);
  10707. clone(): CSG;
  10708. union(csg: CSG): CSG;
  10709. unionInPlace(csg: CSG): void;
  10710. subtract(csg: CSG): CSG;
  10711. subtractInPlace(csg: CSG): void;
  10712. intersect(csg: CSG): CSG;
  10713. intersectInPlace(csg: CSG): void;
  10714. inverse(): CSG;
  10715. inverseInPlace(): void;
  10716. copyTransformAttributes(csg: CSG): CSG;
  10717. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  10718. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  10719. }
  10720. }
  10721. declare module BABYLON {
  10722. class Geometry implements IGetSetVerticesData {
  10723. id: string;
  10724. delayLoadState: number;
  10725. delayLoadingFile: Nullable<string>;
  10726. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  10727. private _scene;
  10728. private _engine;
  10729. private _meshes;
  10730. private _totalVertices;
  10731. private _indices;
  10732. private _vertexBuffers;
  10733. private _isDisposed;
  10734. private _extend;
  10735. private _boundingBias;
  10736. _delayInfo: Array<string>;
  10737. private _indexBuffer;
  10738. private _indexBufferIsUpdatable;
  10739. _boundingInfo: Nullable<BoundingInfo>;
  10740. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  10741. _softwareSkinningRenderId: number;
  10742. private _vertexArrayObjects;
  10743. private _updatable;
  10744. _positions: Nullable<Vector3[]>;
  10745. /**
  10746. * 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
  10747. * @returns The Bias Vector
  10748. */
  10749. boundingBias: Vector2;
  10750. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  10751. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  10752. readonly extend: {
  10753. minimum: Vector3;
  10754. maximum: Vector3;
  10755. };
  10756. getScene(): Scene;
  10757. getEngine(): Engine;
  10758. isReady(): boolean;
  10759. readonly doNotSerialize: boolean;
  10760. _rebuild(): void;
  10761. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  10762. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  10763. removeVerticesData(kind: string): void;
  10764. setVerticesBuffer(buffer: VertexBuffer): void;
  10765. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  10766. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  10767. private updateBoundingInfo(updateExtends, data);
  10768. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  10769. getTotalVertices(): number;
  10770. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  10771. /**
  10772. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  10773. * Possible `kind` values :
  10774. * - BABYLON.VertexBuffer.PositionKind
  10775. * - BABYLON.VertexBuffer.UVKind
  10776. * - BABYLON.VertexBuffer.UV2Kind
  10777. * - BABYLON.VertexBuffer.UV3Kind
  10778. * - BABYLON.VertexBuffer.UV4Kind
  10779. * - BABYLON.VertexBuffer.UV5Kind
  10780. * - BABYLON.VertexBuffer.UV6Kind
  10781. * - BABYLON.VertexBuffer.ColorKind
  10782. * - BABYLON.VertexBuffer.MatricesIndicesKind
  10783. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  10784. * - BABYLON.VertexBuffer.MatricesWeightsKind
  10785. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  10786. */
  10787. isVertexBufferUpdatable(kind: string): boolean;
  10788. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  10789. getVertexBuffers(): Nullable<{
  10790. [key: string]: VertexBuffer;
  10791. }>;
  10792. isVerticesDataPresent(kind: string): boolean;
  10793. getVerticesDataKinds(): string[];
  10794. updateIndices(indices: IndicesArray, offset?: number): void;
  10795. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  10796. getTotalIndices(): number;
  10797. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  10798. getIndexBuffer(): Nullable<WebGLBuffer>;
  10799. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  10800. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  10801. applyToMesh(mesh: Mesh): void;
  10802. private updateExtend(data?, stride?);
  10803. private _applyToMesh(mesh);
  10804. private notifyUpdate(kind?);
  10805. load(scene: Scene, onLoaded?: () => void): void;
  10806. private _queueLoad(scene, onLoaded?);
  10807. /**
  10808. * Invert the geometry to move from a right handed system to a left handed one.
  10809. */
  10810. toLeftHanded(): void;
  10811. _resetPointsArrayCache(): void;
  10812. _generatePointsArray(): boolean;
  10813. isDisposed(): boolean;
  10814. private _disposeVertexArrayObjects();
  10815. dispose(): void;
  10816. copy(id: string): Geometry;
  10817. serialize(): any;
  10818. private toNumberArray(origin);
  10819. serializeVerticeData(): any;
  10820. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  10821. /**
  10822. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  10823. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  10824. * Be aware Math.random() could cause collisions, but:
  10825. * "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"
  10826. */
  10827. static RandomId(): string;
  10828. static ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  10829. private static _CleanMatricesWeights(parsedGeometry, mesh);
  10830. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  10831. }
  10832. class _PrimitiveGeometry extends Geometry {
  10833. private _canBeRegenerated;
  10834. private _beingRegenerated;
  10835. constructor(id: string, scene: Scene, _canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  10836. canBeRegenerated(): boolean;
  10837. regenerate(): void;
  10838. asNewGeometry(id: string): Geometry;
  10839. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  10840. setVerticesData(kind: string, data: FloatArray, updatable?: boolean): void;
  10841. _regenerateVertexData(): VertexData;
  10842. copy(id: string): Geometry;
  10843. serialize(): any;
  10844. }
  10845. class RibbonGeometry extends _PrimitiveGeometry {
  10846. pathArray: Vector3[][];
  10847. closeArray: boolean;
  10848. closePath: boolean;
  10849. offset: number;
  10850. side: number;
  10851. constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  10852. _regenerateVertexData(): VertexData;
  10853. copy(id: string): Geometry;
  10854. }
  10855. class BoxGeometry extends _PrimitiveGeometry {
  10856. size: number;
  10857. side: number;
  10858. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10859. _regenerateVertexData(): VertexData;
  10860. copy(id: string): Geometry;
  10861. serialize(): any;
  10862. static Parse(parsedBox: any, scene: Scene): Nullable<BoxGeometry>;
  10863. }
  10864. class SphereGeometry extends _PrimitiveGeometry {
  10865. segments: number;
  10866. diameter: number;
  10867. side: number;
  10868. constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10869. _regenerateVertexData(): VertexData;
  10870. copy(id: string): Geometry;
  10871. serialize(): any;
  10872. static Parse(parsedSphere: any, scene: Scene): Nullable<SphereGeometry>;
  10873. }
  10874. class DiscGeometry extends _PrimitiveGeometry {
  10875. radius: number;
  10876. tessellation: number;
  10877. side: number;
  10878. constructor(id: string, scene: Scene, radius: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10879. _regenerateVertexData(): VertexData;
  10880. copy(id: string): Geometry;
  10881. }
  10882. class CylinderGeometry extends _PrimitiveGeometry {
  10883. height: number;
  10884. diameterTop: number;
  10885. diameterBottom: number;
  10886. tessellation: number;
  10887. subdivisions: number;
  10888. side: number;
  10889. constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10890. _regenerateVertexData(): VertexData;
  10891. copy(id: string): Geometry;
  10892. serialize(): any;
  10893. static Parse(parsedCylinder: any, scene: Scene): Nullable<CylinderGeometry>;
  10894. }
  10895. class TorusGeometry extends _PrimitiveGeometry {
  10896. diameter: number;
  10897. thickness: number;
  10898. tessellation: number;
  10899. side: number;
  10900. constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10901. _regenerateVertexData(): VertexData;
  10902. copy(id: string): Geometry;
  10903. serialize(): any;
  10904. static Parse(parsedTorus: any, scene: Scene): Nullable<TorusGeometry>;
  10905. }
  10906. class GroundGeometry extends _PrimitiveGeometry {
  10907. width: number;
  10908. height: number;
  10909. subdivisions: number;
  10910. constructor(id: string, scene: Scene, width: number, height: number, subdivisions: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  10911. _regenerateVertexData(): VertexData;
  10912. copy(id: string): Geometry;
  10913. serialize(): any;
  10914. static Parse(parsedGround: any, scene: Scene): Nullable<GroundGeometry>;
  10915. }
  10916. class TiledGroundGeometry extends _PrimitiveGeometry {
  10917. xmin: number;
  10918. zmin: number;
  10919. xmax: number;
  10920. zmax: number;
  10921. subdivisions: {
  10922. w: number;
  10923. h: number;
  10924. };
  10925. precision: {
  10926. w: number;
  10927. h: number;
  10928. };
  10929. constructor(id: string, scene: Scene, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  10930. w: number;
  10931. h: number;
  10932. }, precision: {
  10933. w: number;
  10934. h: number;
  10935. }, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>);
  10936. _regenerateVertexData(): VertexData;
  10937. copy(id: string): Geometry;
  10938. }
  10939. class PlaneGeometry extends _PrimitiveGeometry {
  10940. size: number;
  10941. side: number;
  10942. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10943. _regenerateVertexData(): VertexData;
  10944. copy(id: string): Geometry;
  10945. serialize(): any;
  10946. static Parse(parsedPlane: any, scene: Scene): Nullable<PlaneGeometry>;
  10947. }
  10948. class TorusKnotGeometry extends _PrimitiveGeometry {
  10949. radius: number;
  10950. tube: number;
  10951. radialSegments: number;
  10952. tubularSegments: number;
  10953. p: number;
  10954. q: number;
  10955. side: number;
  10956. constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Nullable<Mesh>, side?: number);
  10957. _regenerateVertexData(): VertexData;
  10958. copy(id: string): Geometry;
  10959. serialize(): any;
  10960. static Parse(parsedTorusKnot: any, scene: Scene): Nullable<TorusKnotGeometry>;
  10961. }
  10962. }
  10963. declare module BABYLON {
  10964. class GroundMesh extends Mesh {
  10965. generateOctree: boolean;
  10966. private _heightQuads;
  10967. _subdivisionsX: number;
  10968. _subdivisionsY: number;
  10969. _width: number;
  10970. _height: number;
  10971. _minX: number;
  10972. _maxX: number;
  10973. _minZ: number;
  10974. _maxZ: number;
  10975. constructor(name: string, scene: Scene);
  10976. getClassName(): string;
  10977. readonly subdivisions: number;
  10978. readonly subdivisionsX: number;
  10979. readonly subdivisionsY: number;
  10980. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  10981. /**
  10982. * Returns a height (y) value in the Worl system :
  10983. * the ground altitude at the coordinates (x, z) expressed in the World system.
  10984. * Returns the ground y position if (x, z) are outside the ground surface.
  10985. */
  10986. getHeightAtCoordinates(x: number, z: number): number;
  10987. /**
  10988. * Returns a normalized vector (Vector3) orthogonal to the ground
  10989. * at the ground coordinates (x, z) expressed in the World system.
  10990. * Returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  10991. */
  10992. getNormalAtCoordinates(x: number, z: number): Vector3;
  10993. /**
  10994. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  10995. * at the ground coordinates (x, z) expressed in the World system.
  10996. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  10997. * Returns the GroundMesh.
  10998. */
  10999. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  11000. /**
  11001. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  11002. * if the ground has been updated.
  11003. * This can be used in the render loop.
  11004. * Returns the GroundMesh.
  11005. */
  11006. updateCoordinateHeights(): GroundMesh;
  11007. private _getFacetAt(x, z);
  11008. private _initHeightQuads();
  11009. private _computeHeightQuads();
  11010. serialize(serializationObject: any): void;
  11011. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  11012. }
  11013. }
  11014. declare module BABYLON {
  11015. /**
  11016. * Creates an instance based on a source mesh.
  11017. */
  11018. class InstancedMesh extends AbstractMesh {
  11019. private _sourceMesh;
  11020. private _currentLOD;
  11021. constructor(name: string, source: Mesh);
  11022. /**
  11023. * Returns the string "InstancedMesh".
  11024. */
  11025. getClassName(): string;
  11026. readonly receiveShadows: boolean;
  11027. readonly material: Nullable<Material>;
  11028. readonly visibility: number;
  11029. readonly skeleton: Nullable<Skeleton>;
  11030. readonly renderingGroupId: number;
  11031. /**
  11032. * Returns the total number of vertices (integer).
  11033. */
  11034. getTotalVertices(): number;
  11035. readonly sourceMesh: Mesh;
  11036. /**
  11037. * Is this node ready to be used/rendered
  11038. * @return {boolean} is it ready
  11039. */
  11040. isReady(): boolean;
  11041. /**
  11042. * Returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  11043. */
  11044. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  11045. /**
  11046. * Sets the vertex data of the mesh geometry for the requested `kind`.
  11047. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  11048. * The `data` are either a numeric array either a Float32Array.
  11049. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  11050. * 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).
  11051. * Note that a new underlying VertexBuffer object is created each call.
  11052. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  11053. *
  11054. * Possible `kind` values :
  11055. * - BABYLON.VertexBuffer.PositionKind
  11056. * - BABYLON.VertexBuffer.UVKind
  11057. * - BABYLON.VertexBuffer.UV2Kind
  11058. * - BABYLON.VertexBuffer.UV3Kind
  11059. * - BABYLON.VertexBuffer.UV4Kind
  11060. * - BABYLON.VertexBuffer.UV5Kind
  11061. * - BABYLON.VertexBuffer.UV6Kind
  11062. * - BABYLON.VertexBuffer.ColorKind
  11063. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11064. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11065. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11066. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11067. *
  11068. * Returns the Mesh.
  11069. */
  11070. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  11071. /**
  11072. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  11073. * If the mesh has no geometry, it is simply returned as it is.
  11074. * The `data` are either a numeric array either a Float32Array.
  11075. * No new underlying VertexBuffer object is created.
  11076. * 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.
  11077. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  11078. *
  11079. * Possible `kind` values :
  11080. * - BABYLON.VertexBuffer.PositionKind
  11081. * - BABYLON.VertexBuffer.UVKind
  11082. * - BABYLON.VertexBuffer.UV2Kind
  11083. * - BABYLON.VertexBuffer.UV3Kind
  11084. * - BABYLON.VertexBuffer.UV4Kind
  11085. * - BABYLON.VertexBuffer.UV5Kind
  11086. * - BABYLON.VertexBuffer.UV6Kind
  11087. * - BABYLON.VertexBuffer.ColorKind
  11088. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11089. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11090. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11091. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11092. *
  11093. * Returns the Mesh.
  11094. */
  11095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  11096. /**
  11097. * Sets the mesh indices.
  11098. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  11099. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  11100. * This method creates a new index buffer each call.
  11101. * Returns the Mesh.
  11102. */
  11103. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  11104. /**
  11105. * Boolean : True if the mesh owns the requested kind of data.
  11106. */
  11107. isVerticesDataPresent(kind: string): boolean;
  11108. /**
  11109. * Returns an array of indices (IndicesArray).
  11110. */
  11111. getIndices(): Nullable<IndicesArray>;
  11112. readonly _positions: Nullable<Vector3[]>;
  11113. /**
  11114. * Sets a new updated BoundingInfo to the mesh.
  11115. * Returns the mesh.
  11116. */
  11117. refreshBoundingInfo(): InstancedMesh;
  11118. _preActivate(): InstancedMesh;
  11119. _activate(renderId: number): InstancedMesh;
  11120. /**
  11121. * Returns the current associated LOD AbstractMesh.
  11122. */
  11123. getLOD(camera: Camera): AbstractMesh;
  11124. _syncSubMeshes(): InstancedMesh;
  11125. _generatePointsArray(): boolean;
  11126. /**
  11127. * Creates a new InstancedMesh from the current mesh.
  11128. * - name (string) : the cloned mesh name
  11129. * - newParent (optional Node) : the optional Node to parent the clone to.
  11130. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  11131. *
  11132. * Returns the clone.
  11133. */
  11134. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  11135. /**
  11136. * Disposes the InstancedMesh.
  11137. * Returns nothing.
  11138. */
  11139. dispose(doNotRecurse?: boolean): void;
  11140. }
  11141. }
  11142. declare module BABYLON {
  11143. class LinesMesh extends Mesh {
  11144. useVertexColor: boolean | undefined;
  11145. useVertexAlpha: boolean | undefined;
  11146. color: Color3;
  11147. alpha: number;
  11148. /**
  11149. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  11150. * This margin is expressed in world space coordinates, so its value may vary.
  11151. * Default value is 0.1
  11152. * @returns the intersection Threshold value.
  11153. */
  11154. /**
  11155. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  11156. * This margin is expressed in world space coordinates, so its value may vary.
  11157. * @param value the new threshold to apply
  11158. */
  11159. intersectionThreshold: number;
  11160. private _intersectionThreshold;
  11161. private _colorShader;
  11162. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean, useVertexColor?: boolean | undefined, useVertexAlpha?: boolean | undefined);
  11163. /**
  11164. * Returns the string "LineMesh"
  11165. */
  11166. getClassName(): string;
  11167. material: Material;
  11168. readonly checkCollisions: boolean;
  11169. createInstance(name: string): InstancedMesh;
  11170. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  11171. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  11172. dispose(doNotRecurse?: boolean): void;
  11173. /**
  11174. * Returns a new LineMesh object cloned from the current one.
  11175. */
  11176. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  11177. }
  11178. }
  11179. declare module BABYLON {
  11180. class _InstancesBatch {
  11181. mustReturn: boolean;
  11182. visibleInstances: Nullable<InstancedMesh[]>[];
  11183. renderSelf: boolean[];
  11184. }
  11185. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  11186. static _FRONTSIDE: number;
  11187. static _BACKSIDE: number;
  11188. static _DOUBLESIDE: number;
  11189. static _DEFAULTSIDE: number;
  11190. static _NO_CAP: number;
  11191. static _CAP_START: number;
  11192. static _CAP_END: number;
  11193. static _CAP_ALL: number;
  11194. /**
  11195. * Mesh side orientation : usually the external or front surface
  11196. */
  11197. static readonly FRONTSIDE: number;
  11198. /**
  11199. * Mesh side orientation : usually the internal or back surface
  11200. */
  11201. static readonly BACKSIDE: number;
  11202. /**
  11203. * Mesh side orientation : both internal and external or front and back surfaces
  11204. */
  11205. static readonly DOUBLESIDE: number;
  11206. /**
  11207. * Mesh side orientation : by default, `FRONTSIDE`
  11208. */
  11209. static readonly DEFAULTSIDE: number;
  11210. /**
  11211. * Mesh cap setting : no cap
  11212. */
  11213. static readonly NO_CAP: number;
  11214. /**
  11215. * Mesh cap setting : one cap at the beginning of the mesh
  11216. */
  11217. static readonly CAP_START: number;
  11218. /**
  11219. * Mesh cap setting : one cap at the end of the mesh
  11220. */
  11221. static readonly CAP_END: number;
  11222. /**
  11223. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  11224. */
  11225. static readonly CAP_ALL: number;
  11226. /**
  11227. * An event triggered before rendering the mesh
  11228. * @type {BABYLON.Observable}
  11229. */
  11230. onBeforeRenderObservable: Observable<Mesh>;
  11231. /**
  11232. * An event triggered after rendering the mesh
  11233. * @type {BABYLON.Observable}
  11234. */
  11235. onAfterRenderObservable: Observable<Mesh>;
  11236. /**
  11237. * An event triggered before drawing the mesh
  11238. * @type {BABYLON.Observable}
  11239. */
  11240. onBeforeDrawObservable: Observable<Mesh>;
  11241. private _onBeforeDrawObserver;
  11242. onBeforeDraw: () => void;
  11243. delayLoadState: number;
  11244. instances: InstancedMesh[];
  11245. delayLoadingFile: string;
  11246. _binaryInfo: any;
  11247. private _LODLevels;
  11248. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  11249. private _morphTargetManager;
  11250. morphTargetManager: Nullable<MorphTargetManager>;
  11251. _geometry: Nullable<Geometry>;
  11252. _delayInfo: Array<string>;
  11253. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  11254. _visibleInstances: any;
  11255. private _renderIdForInstances;
  11256. private _batchCache;
  11257. private _instancesBufferSize;
  11258. private _instancesBuffer;
  11259. private _instancesData;
  11260. private _overridenInstanceCount;
  11261. private _effectiveMaterial;
  11262. _shouldGenerateFlatShading: boolean;
  11263. private _preActivateId;
  11264. _originalBuilderSideOrientation: number;
  11265. overrideMaterialSideOrientation: Nullable<number>;
  11266. private _areNormalsFrozen;
  11267. private _sourcePositions;
  11268. private _sourceNormals;
  11269. private _source;
  11270. readonly source: Nullable<Mesh>;
  11271. isUnIndexed: boolean;
  11272. /**
  11273. * @constructor
  11274. * @param {string} name The value used by scene.getMeshByName() to do a lookup.
  11275. * @param {Scene} scene The scene to add this mesh to.
  11276. * @param {Node} parent The parent of this mesh, if it has one
  11277. * @param {Mesh} source An optional Mesh from which geometry is shared, cloned.
  11278. * @param {boolean} doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  11279. * When false, achieved by calling a clone(), also passing False.
  11280. * This will make creation of children, recursive.
  11281. * @param {boolean} clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  11282. */
  11283. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  11284. /**
  11285. * Returns the string "Mesh".
  11286. */
  11287. getClassName(): string;
  11288. /**
  11289. * Returns a string.
  11290. * @param {boolean} fullDetails - support for multiple levels of logging within scene loading
  11291. */
  11292. toString(fullDetails?: boolean): string;
  11293. /**
  11294. * True if the mesh has some Levels Of Details (LOD).
  11295. * Returns a boolean.
  11296. */
  11297. readonly hasLODLevels: boolean;
  11298. private _sortLODLevels();
  11299. /**
  11300. * Add a mesh as LOD level triggered at the given distance.
  11301. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  11302. * @param {number} distance The distance from the center of the object to show this level
  11303. * @param {Mesh} mesh The mesh to be added as LOD level
  11304. * @return {Mesh} This mesh (for chaining)
  11305. */
  11306. addLODLevel(distance: number, mesh: Mesh): Mesh;
  11307. /**
  11308. * Returns the LOD level mesh at the passed distance or null if not found.
  11309. * It is related to the method `addLODLevel(distance, mesh)`.
  11310. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  11311. * Returns an object Mesh or `null`.
  11312. */
  11313. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  11314. /**
  11315. * Remove a mesh from the LOD array
  11316. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  11317. * @param {Mesh} mesh The mesh to be removed.
  11318. * @return {Mesh} This mesh (for chaining)
  11319. */
  11320. removeLODLevel(mesh: Mesh): Mesh;
  11321. /**
  11322. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  11323. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_LOD
  11324. */
  11325. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  11326. /**
  11327. * Returns the mesh internal Geometry object.
  11328. */
  11329. readonly geometry: Nullable<Geometry>;
  11330. /**
  11331. * Returns a positive integer : the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  11332. */
  11333. getTotalVertices(): number;
  11334. /**
  11335. * Returns an array of integers or floats, or a Float32Array, depending on the requested `kind` (positions, indices, normals, etc).
  11336. * If `copywhenShared` is true (default false) and if the mesh geometry is shared among some other meshes, the returned array is a copy of the internal one.
  11337. * You can force the copy with forceCopy === true
  11338. * Returns null if the mesh has no geometry or no vertex buffer.
  11339. * Possible `kind` values :
  11340. * - BABYLON.VertexBuffer.PositionKind
  11341. * - BABYLON.VertexBuffer.UVKind
  11342. * - BABYLON.VertexBuffer.UV2Kind
  11343. * - BABYLON.VertexBuffer.UV3Kind
  11344. * - BABYLON.VertexBuffer.UV4Kind
  11345. * - BABYLON.VertexBuffer.UV5Kind
  11346. * - BABYLON.VertexBuffer.UV6Kind
  11347. * - BABYLON.VertexBuffer.ColorKind
  11348. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11349. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11350. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11351. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11352. */
  11353. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  11354. /**
  11355. * Returns the mesh VertexBuffer object from the requested `kind` : positions, indices, normals, etc.
  11356. * Returns `null` if the mesh has no geometry.
  11357. * Possible `kind` values :
  11358. * - BABYLON.VertexBuffer.PositionKind
  11359. * - BABYLON.VertexBuffer.UVKind
  11360. * - BABYLON.VertexBuffer.UV2Kind
  11361. * - BABYLON.VertexBuffer.UV3Kind
  11362. * - BABYLON.VertexBuffer.UV4Kind
  11363. * - BABYLON.VertexBuffer.UV5Kind
  11364. * - BABYLON.VertexBuffer.UV6Kind
  11365. * - BABYLON.VertexBuffer.ColorKind
  11366. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11367. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11368. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11369. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11370. */
  11371. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  11372. /**
  11373. * Returns a boolean depending on the existence of the Vertex Data for the requested `kind`.
  11374. * Possible `kind` values :
  11375. * - BABYLON.VertexBuffer.PositionKind
  11376. * - BABYLON.VertexBuffer.UVKind
  11377. * - BABYLON.VertexBuffer.UV2Kind
  11378. * - BABYLON.VertexBuffer.UV3Kind
  11379. * - BABYLON.VertexBuffer.UV4Kind
  11380. * - BABYLON.VertexBuffer.UV5Kind
  11381. * - BABYLON.VertexBuffer.UV6Kind
  11382. * - BABYLON.VertexBuffer.ColorKind
  11383. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11384. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11385. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11386. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11387. */
  11388. isVerticesDataPresent(kind: string): boolean;
  11389. /**
  11390. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  11391. * Possible `kind` values :
  11392. * - BABYLON.VertexBuffer.PositionKind
  11393. * - BABYLON.VertexBuffer.UVKind
  11394. * - BABYLON.VertexBuffer.UV2Kind
  11395. * - BABYLON.VertexBuffer.UV3Kind
  11396. * - BABYLON.VertexBuffer.UV4Kind
  11397. * - BABYLON.VertexBuffer.UV5Kind
  11398. * - BABYLON.VertexBuffer.UV6Kind
  11399. * - BABYLON.VertexBuffer.ColorKind
  11400. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11401. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11402. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11403. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11404. */
  11405. isVertexBufferUpdatable(kind: string): boolean;
  11406. /**
  11407. * Returns a string : the list of existing `kinds` of Vertex Data for this mesh.
  11408. * Possible `kind` values :
  11409. * - BABYLON.VertexBuffer.PositionKind
  11410. * - BABYLON.VertexBuffer.UVKind
  11411. * - BABYLON.VertexBuffer.UV2Kind
  11412. * - BABYLON.VertexBuffer.UV3Kind
  11413. * - BABYLON.VertexBuffer.UV4Kind
  11414. * - BABYLON.VertexBuffer.UV5Kind
  11415. * - BABYLON.VertexBuffer.UV6Kind
  11416. * - BABYLON.VertexBuffer.ColorKind
  11417. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11418. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11419. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11420. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11421. */
  11422. getVerticesDataKinds(): string[];
  11423. /**
  11424. * Returns a positive integer : the total number of indices in this mesh geometry.
  11425. * Returns zero if the mesh has no geometry.
  11426. */
  11427. getTotalIndices(): number;
  11428. /**
  11429. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  11430. * If the parameter `copyWhenShared` is 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.
  11431. * Returns an empty array if the mesh has no geometry.
  11432. */
  11433. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  11434. readonly isBlocked: boolean;
  11435. /**
  11436. * Determine if the current mesh is ready to be rendered
  11437. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  11438. * @returns true if all associated assets are ready (material, textures, shaders)
  11439. */
  11440. isReady(forceInstanceSupport?: boolean): boolean;
  11441. /**
  11442. * Boolean : true if the normals aren't to be recomputed on next mesh `positions` array update.
  11443. * This property is pertinent only for updatable parametric shapes.
  11444. */
  11445. readonly areNormalsFrozen: boolean;
  11446. /**
  11447. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  11448. * It has no effect at all on other shapes.
  11449. * It prevents the mesh normals from being recomputed on next `positions` array update.
  11450. * Returns the Mesh.
  11451. */
  11452. freezeNormals(): Mesh;
  11453. /**
  11454. * This function affects parametric shapes on vertex position update only : ribbons, tubes, etc.
  11455. * It has no effect at all on other shapes.
  11456. * It reactivates the mesh normals computation if it was previously frozen.
  11457. * Returns the Mesh.
  11458. */
  11459. unfreezeNormals(): Mesh;
  11460. /**
  11461. * Overrides instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  11462. */
  11463. overridenInstanceCount: number;
  11464. _preActivate(): Mesh;
  11465. _preActivateForIntermediateRendering(renderId: number): Mesh;
  11466. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  11467. /**
  11468. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  11469. * This means the mesh underlying bounding box and sphere are recomputed.
  11470. * Returns the Mesh.
  11471. */
  11472. refreshBoundingInfo(): Mesh;
  11473. _refreshBoundingInfo(applySkeleton: boolean): Mesh;
  11474. private _getPositionData(applySkeleton);
  11475. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  11476. subdivide(count: number): void;
  11477. /**
  11478. * Sets the vertex data of the mesh geometry for the requested `kind`.
  11479. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  11480. * The `data` are either a numeric array either a Float32Array.
  11481. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  11482. * 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).
  11483. * Note that a new underlying VertexBuffer object is created each call.
  11484. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  11485. *
  11486. * Possible `kind` values :
  11487. * - BABYLON.VertexBuffer.PositionKind
  11488. * - BABYLON.VertexBuffer.UVKind
  11489. * - BABYLON.VertexBuffer.UV2Kind
  11490. * - BABYLON.VertexBuffer.UV3Kind
  11491. * - BABYLON.VertexBuffer.UV4Kind
  11492. * - BABYLON.VertexBuffer.UV5Kind
  11493. * - BABYLON.VertexBuffer.UV6Kind
  11494. * - BABYLON.VertexBuffer.ColorKind
  11495. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11496. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11497. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11498. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11499. *
  11500. * Returns the Mesh.
  11501. */
  11502. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  11503. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  11504. /**
  11505. * Sets the mesh VertexBuffer.
  11506. * Returns the Mesh.
  11507. */
  11508. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  11509. /**
  11510. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  11511. * If the mesh has no geometry, it is simply returned as it is.
  11512. * The `data` are either a numeric array either a Float32Array.
  11513. * No new underlying VertexBuffer object is created.
  11514. * 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.
  11515. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  11516. *
  11517. * Possible `kind` values :
  11518. * - BABYLON.VertexBuffer.PositionKind
  11519. * - BABYLON.VertexBuffer.UVKind
  11520. * - BABYLON.VertexBuffer.UV2Kind
  11521. * - BABYLON.VertexBuffer.UV3Kind
  11522. * - BABYLON.VertexBuffer.UV4Kind
  11523. * - BABYLON.VertexBuffer.UV5Kind
  11524. * - BABYLON.VertexBuffer.UV6Kind
  11525. * - BABYLON.VertexBuffer.ColorKind
  11526. * - BABYLON.VertexBuffer.MatricesIndicesKind
  11527. * - BABYLON.VertexBuffer.MatricesIndicesExtraKind
  11528. * - BABYLON.VertexBuffer.MatricesWeightsKind
  11529. * - BABYLON.VertexBuffer.MatricesWeightsExtraKind
  11530. *
  11531. * Returns the Mesh.
  11532. */
  11533. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  11534. /**
  11535. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  11536. * tuto : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  11537. * The parameter `positionFunction` is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything.
  11538. * The parameter `computeNormals` is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update.
  11539. * Returns the Mesh.
  11540. */
  11541. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  11542. /**
  11543. * Creates a un-shared specific occurence of the geometry for the mesh.
  11544. * Returns the Mesh.
  11545. */
  11546. makeGeometryUnique(): Mesh;
  11547. /**
  11548. * Sets the mesh indices.
  11549. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  11550. * Type is Uint16Array by default unless the mesh has more than 65536 vertices.
  11551. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  11552. * This method creates a new index buffer each call.
  11553. * Returns the Mesh.
  11554. */
  11555. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  11556. /**
  11557. * Update the current index buffer
  11558. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  11559. * Returns the Mesh.
  11560. */
  11561. updateIndices(indices: IndicesArray, offset?: number): Mesh;
  11562. /**
  11563. * Invert the geometry to move from a right handed system to a left handed one.
  11564. * Returns the Mesh.
  11565. */
  11566. toLeftHanded(): Mesh;
  11567. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  11568. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number, alternate?: boolean): Mesh;
  11569. /**
  11570. * Registers for this mesh a javascript function called just before the rendering process.
  11571. * This function is passed the current mesh.
  11572. * Return the Mesh.
  11573. */
  11574. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  11575. /**
  11576. * Disposes a previously registered javascript function called before the rendering.
  11577. * This function is passed the current mesh.
  11578. * Returns the Mesh.
  11579. */
  11580. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  11581. /**
  11582. * Registers for this mesh a javascript function called just after the rendering is complete.
  11583. * This function is passed the current mesh.
  11584. * Returns the Mesh.
  11585. */
  11586. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  11587. /**
  11588. * Disposes a previously registered javascript function called after the rendering.
  11589. * This function is passed the current mesh.
  11590. * Return the Mesh.
  11591. */
  11592. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  11593. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  11594. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  11595. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  11596. /**
  11597. * Triggers the draw call for the mesh.
  11598. * Usually, you don't need to call this method by your own because the mesh rendering is handled by the scene rendering manager.
  11599. * Returns the Mesh.
  11600. */
  11601. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  11602. private _onBeforeDraw(isInstance, world, effectiveMaterial?);
  11603. /**
  11604. * Returns an array populated with ParticleSystem objects whose the mesh is the emitter.
  11605. */
  11606. getEmittedParticleSystems(): IParticleSystem[];
  11607. /**
  11608. * Returns an array populated with ParticleSystem objects whose the mesh or its children are the emitter.
  11609. */
  11610. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  11611. _checkDelayState(): Mesh;
  11612. private _queueLoad(scene);
  11613. /**
  11614. * Boolean, true is the mesh in the frustum defined by the Plane objects from the `frustumPlanes` array parameter.
  11615. */
  11616. isInFrustum(frustumPlanes: Plane[]): boolean;
  11617. /**
  11618. * Sets the mesh material by the material or multiMaterial `id` property.
  11619. * The material `id` is a string identifying the material or the multiMaterial.
  11620. * This method returns the Mesh.
  11621. */
  11622. setMaterialByID(id: string): Mesh;
  11623. /**
  11624. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  11625. */
  11626. getAnimatables(): IAnimatable[];
  11627. /**
  11628. * Modifies the mesh geometry according to the passed transformation matrix.
  11629. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  11630. * The mesh normals are modified accordingly the same transformation.
  11631. * tuto : http://doc.babylonjs.com/tutorials/How_Rotations_and_Translations_Work#baking-transform
  11632. * Note that, under the hood, this method sets a new VertexBuffer each call.
  11633. * Returns the Mesh.
  11634. */
  11635. bakeTransformIntoVertices(transform: Matrix): Mesh;
  11636. /**
  11637. * Modifies the mesh geometry according to its own current World Matrix.
  11638. * The mesh World Matrix is then reset.
  11639. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  11640. * tuto : tuto : http://doc.babylonjs.com/resources/baking_transformations
  11641. * Note that, under the hood, this method sets a new VertexBuffer each call.
  11642. * Returns the Mesh.
  11643. */
  11644. bakeCurrentTransformIntoVertices(): Mesh;
  11645. readonly _positions: Nullable<Vector3[]>;
  11646. _resetPointsArrayCache(): Mesh;
  11647. _generatePointsArray(): boolean;
  11648. /**
  11649. * Returns a new Mesh object generated from the current mesh properties.
  11650. * This method must not get confused with createInstance().
  11651. * The parameter `name` is a string, the name given to the new mesh.
  11652. * The optional parameter `newParent` can be any Node object (default `null`).
  11653. * The optional parameter `doNotCloneChildren` (default `false`) allows/denies the recursive cloning of the original mesh children if any.
  11654. * The parameter `clonePhysicsImpostor` (default `true`) allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any.
  11655. */
  11656. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  11657. /**
  11658. * Disposes the Mesh.
  11659. * By default, all the mesh children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  11660. * Returns nothing.
  11661. */
  11662. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  11663. /**
  11664. * Modifies the mesh geometry according to a displacement map.
  11665. * 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.
  11666. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  11667. * This method returns nothing.
  11668. * The parameter `url` is a string, the URL from the image file is to be downloaded.
  11669. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  11670. * The parameter `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.
  11671. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  11672. * The parameter `uvScale` is an optional vector2 used to scale UV.
  11673. *
  11674. * Returns the Mesh.
  11675. */
  11676. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  11677. /**
  11678. * Modifies the mesh geometry according to a displacementMap buffer.
  11679. * 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.
  11680. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  11681. * This method returns nothing.
  11682. * The parameter `buffer` is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  11683. * The parameters `heightMapWidth` and `heightMapHeight` are positive integers to set the width and height of the buffer image.
  11684. * The parameters `minHeight` and `maxHeight` are the lower and upper limits of the displacement.
  11685. * The parameter `uvOffset` is an optional vector2 used to offset UV.
  11686. * The parameter `uvScale` is an optional vector2 used to scale UV.
  11687. *
  11688. * Returns the Mesh.
  11689. */
  11690. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2): Mesh;
  11691. /**
  11692. * Modify the mesh to get a flat shading rendering.
  11693. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  11694. * This method returns the Mesh.
  11695. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  11696. */
  11697. convertToFlatShadedMesh(): Mesh;
  11698. /**
  11699. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  11700. * In other words, more vertices, no more indices and a single bigger VBO.
  11701. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  11702. * Returns the Mesh.
  11703. */
  11704. convertToUnIndexedMesh(): Mesh;
  11705. /**
  11706. * Inverses facet orientations and inverts also the normals with `flipNormals` (default `false`) if true.
  11707. * This method returns the Mesh.
  11708. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  11709. */
  11710. flipFaces(flipNormals?: boolean): Mesh;
  11711. /**
  11712. * Creates a new InstancedMesh object from the mesh model.
  11713. * An instance shares the same properties and the same material than its model.
  11714. * Only these properties of each instance can then be set individually :
  11715. * - position
  11716. * - rotation
  11717. * - rotationQuaternion
  11718. * - setPivotMatrix
  11719. * - scaling
  11720. * tuto : http://doc.babylonjs.com/tutorials/How_to_use_Instances
  11721. * Warning : this method is not supported for Line mesh and LineSystem
  11722. */
  11723. createInstance(name: string): InstancedMesh;
  11724. /**
  11725. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  11726. * After this call, all the mesh instances have the same submeshes than the current mesh.
  11727. * This method returns the Mesh.
  11728. */
  11729. synchronizeInstances(): Mesh;
  11730. /**
  11731. * Simplify the mesh according to the given array of settings.
  11732. * Function will return immediately and will simplify async. It returns the Mesh.
  11733. * @param settings a collection of simplification settings.
  11734. * @param parallelProcessing should all levels calculate parallel or one after the other.
  11735. * @param type the type of simplification to run.
  11736. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  11737. */
  11738. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  11739. /**
  11740. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  11741. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  11742. * This should be used together with the simplification to avoid disappearing triangles.
  11743. * Returns the Mesh.
  11744. * @param successCallback an optional success callback to be called after the optimization finished.
  11745. */
  11746. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  11747. serialize(serializationObject: any): void;
  11748. _syncGeometryWithMorphTargetManager(): void;
  11749. /**
  11750. * Returns a new Mesh object parsed from the source provided.
  11751. * The parameter `parsedMesh` is the source.
  11752. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  11753. */
  11754. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  11755. /**
  11756. * Creates a ribbon mesh.
  11757. * Please consider using the same method from the MeshBuilder class instead.
  11758. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  11759. *
  11760. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  11761. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  11762. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  11763. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  11764. * 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.
  11765. * It's the offset to join together the points from the same path. Ex : offset = 10 means the point 1 is joined to the point 11.
  11766. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  11767. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11768. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11769. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11770. */
  11771. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean | undefined, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  11772. /**
  11773. * Creates a plane polygonal mesh. By default, this is a disc.
  11774. * Please consider using the same method from the MeshBuilder class instead.
  11775. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  11776. * 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.
  11777. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11778. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11779. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11780. */
  11781. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  11782. /**
  11783. * Creates a box mesh.
  11784. * Please consider using the same method from the MeshBuilder class instead.
  11785. * The parameter `size` sets the size (float) of each box side (default 1).
  11786. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11787. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11788. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11789. */
  11790. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  11791. /**
  11792. * Creates a sphere mesh.
  11793. * Please consider using the same method from the MeshBuilder class instead.
  11794. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  11795. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  11796. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11797. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11798. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11799. */
  11800. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11801. /**
  11802. * Creates a cylinder or a cone mesh.
  11803. * Please consider using the same method from the MeshBuilder class instead.
  11804. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  11805. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  11806. * 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.
  11807. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  11808. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  11809. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11810. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11811. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11812. */
  11813. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  11814. /**
  11815. * Creates a torus mesh.
  11816. * Please consider using the same method from the MeshBuilder class instead.
  11817. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  11818. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  11819. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  11820. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11821. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11822. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11823. */
  11824. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11825. /**
  11826. * Creates a torus knot mesh.
  11827. * Please consider using the same method from the MeshBuilder class instead.
  11828. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  11829. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  11830. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  11831. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  11832. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11833. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11834. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11835. */
  11836. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11837. /**
  11838. * Creates a line mesh.
  11839. * Please consider using the same method from the MeshBuilder class instead.
  11840. * 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.
  11841. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  11842. * The parameter `points` is an array successive Vector3.
  11843. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  11844. * When updating an instance, remember that only point positions can change, not the number of points.
  11845. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11846. */
  11847. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  11848. /**
  11849. * Creates a dashed line mesh.
  11850. * Please consider using the same method from the MeshBuilder class instead.
  11851. * 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.
  11852. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  11853. * The parameter `points` is an array successive Vector3.
  11854. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  11855. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  11856. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  11857. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  11858. * When updating an instance, remember that only point positions can change, not the number of points.
  11859. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11860. */
  11861. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  11862. /**
  11863. * Creates a polygon mesh.
  11864. * Please consider using the same method from the MeshBuilder class instead.
  11865. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  11866. * 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.
  11867. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11868. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11869. * Remember you can only change the shape positions, not their number when updating a polygon.
  11870. */
  11871. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  11872. /**
  11873. * Creates an extruded polygon mesh, with depth in the Y direction.
  11874. * Please consider using the same method from the MeshBuilder class instead.
  11875. */
  11876. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number): Mesh;
  11877. /**
  11878. * Creates an extruded shape mesh.
  11879. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  11880. * Please consider using the same method from the MeshBuilder class instead.
  11881. *
  11882. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  11883. * 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
  11884. * extruded along the Z axis.
  11885. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  11886. * 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.
  11887. * The parameter `scale` (float, default 1) is the value to scale the shape.
  11888. * 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
  11889. * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  11890. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  11891. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11892. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11893. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11894. */
  11895. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  11896. /**
  11897. * Creates an custom extruded shape mesh.
  11898. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  11899. * Please consider using the same method from the MeshBuilder class instead.
  11900. *
  11901. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  11902. * 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
  11903. * extruded along the Z axis.
  11904. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  11905. * 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
  11906. * and the distance of this point from the begining of the path :
  11907. * ```javascript
  11908. * var rotationFunction = function(i, distance) {
  11909. * // do things
  11910. * return rotationValue; }
  11911. * ```
  11912. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  11913. * 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
  11914. * and the distance of this point from the begining of the path :
  11915. * ```javascript
  11916. * var scaleFunction = function(i, distance) {
  11917. * // do things
  11918. * return scaleValue;}
  11919. * ```
  11920. * It must returns a float value that will be the scale value applied to the shape on each path point.
  11921. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  11922. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  11923. * 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
  11924. * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  11925. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  11926. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11927. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11928. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11929. */
  11930. 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;
  11931. /**
  11932. * Creates lathe mesh.
  11933. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  11934. * Please consider using the same method from the MeshBuilder class instead.
  11935. * 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
  11936. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  11937. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  11938. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  11939. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11940. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11941. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11942. */
  11943. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11944. /**
  11945. * Creates a plane mesh.
  11946. * Please consider using the same method from the MeshBuilder class instead.
  11947. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  11948. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  11949. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  11950. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11951. */
  11952. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  11953. /**
  11954. * Creates a ground mesh.
  11955. * Please consider using the same method from the MeshBuilder class instead.
  11956. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  11957. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  11958. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11959. */
  11960. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  11961. /**
  11962. * Creates a tiled ground mesh.
  11963. * Please consider using the same method from the MeshBuilder class instead.
  11964. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  11965. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  11966. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  11967. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  11968. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  11969. * numbers of subdivisions on the ground width and height of each tile.
  11970. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11971. */
  11972. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  11973. w: number;
  11974. h: number;
  11975. }, precision: {
  11976. w: number;
  11977. h: number;
  11978. }, scene: Scene, updatable?: boolean): Mesh;
  11979. /**
  11980. * Creates a ground mesh from a height map.
  11981. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  11982. * Please consider using the same method from the MeshBuilder class instead.
  11983. * The parameter `url` sets the URL of the height map image resource.
  11984. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  11985. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  11986. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  11987. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  11988. * 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).
  11989. * This function is passed the newly built mesh :
  11990. * ```javascript
  11991. * function(mesh) { // do things
  11992. * return; }
  11993. * ```
  11994. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  11995. */
  11996. static CreateGroundFromHeightMap(name: string, url: string, width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, scene: Scene, updatable?: boolean, onReady?: (mesh: GroundMesh) => void): GroundMesh;
  11997. /**
  11998. * Creates a tube mesh.
  11999. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  12000. * Please consider using the same method from the MeshBuilder class instead.
  12001. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  12002. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  12003. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  12004. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  12005. * 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.
  12006. * It must return a radius value (positive float) :
  12007. * ```javascript
  12008. * var radiusFunction = function(i, distance) {
  12009. * // do things
  12010. * return radius; }
  12011. * ```
  12012. * 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
  12013. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  12014. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12015. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12016. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12017. */
  12018. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  12019. (i: number, distance: number): number;
  12020. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  12021. /**
  12022. * Creates a polyhedron mesh.
  12023. * Please consider using the same method from the MeshBuilder class instead.
  12024. * 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
  12025. * to choose the wanted type.
  12026. * The parameter `size` (positive float, default 1) sets the polygon size.
  12027. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  12028. * 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`.
  12029. * 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
  12030. * 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)`).
  12031. * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  12032. * 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.
  12033. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12034. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12035. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12036. */
  12037. static CreatePolyhedron(name: string, options: {
  12038. type?: number;
  12039. size?: number;
  12040. sizeX?: number;
  12041. sizeY?: number;
  12042. sizeZ?: number;
  12043. custom?: any;
  12044. faceUV?: Vector4[];
  12045. faceColors?: Color4[];
  12046. updatable?: boolean;
  12047. sideOrientation?: number;
  12048. }, scene: Scene): Mesh;
  12049. /**
  12050. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  12051. * Please consider using the same method from the MeshBuilder class instead.
  12052. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  12053. * 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`).
  12054. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  12055. * 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.
  12056. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12057. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12058. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12059. */
  12060. static CreateIcoSphere(name: string, options: {
  12061. radius?: number;
  12062. flat?: boolean;
  12063. subdivisions?: number;
  12064. sideOrientation?: number;
  12065. updatable?: boolean;
  12066. }, scene: Scene): Mesh;
  12067. /**
  12068. * Creates a decal mesh.
  12069. * Please consider using the same method from the MeshBuilder class instead.
  12070. * 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.
  12071. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  12072. * The parameter `normal` (Vector3, default Vector3.Up) sets the normal of the mesh where the decal is applied onto in World coordinates.
  12073. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  12074. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  12075. */
  12076. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  12077. /**
  12078. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  12079. */
  12080. setPositionsForCPUSkinning(): Float32Array;
  12081. /**
  12082. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  12083. */
  12084. setNormalsForCPUSkinning(): Float32Array;
  12085. /**
  12086. * Updates the vertex buffer by applying transformation from the bones.
  12087. * Returns the Mesh.
  12088. *
  12089. * @param {skeleton} skeleton to apply
  12090. */
  12091. applySkeleton(skeleton: Skeleton): Mesh;
  12092. /**
  12093. * Returns an object `{min:` Vector3`, max:` Vector3`}`
  12094. * This min and max Vector3 are the minimum and maximum vectors of each mesh bounding box from the passed array, in the World system
  12095. */
  12096. static MinMax(meshes: AbstractMesh[]): {
  12097. min: Vector3;
  12098. max: Vector3;
  12099. };
  12100. /**
  12101. * Returns a Vector3, the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array.
  12102. */
  12103. static Center(meshesOrMinMaxVector: {
  12104. min: Vector3;
  12105. max: Vector3;
  12106. } | AbstractMesh[]): Vector3;
  12107. /**
  12108. * Merge the array of meshes into a single mesh for performance reasons.
  12109. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  12110. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  12111. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  12112. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  12113. * @param {boolean} subdivideWithSubMeshes - When true (false default), subdivide mesh to his subMesh array with meshes source.
  12114. */
  12115. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean): Nullable<Mesh>;
  12116. }
  12117. }
  12118. declare module BABYLON {
  12119. interface IGetSetVerticesData {
  12120. isVerticesDataPresent(kind: string): boolean;
  12121. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  12122. getIndices(copyWhenShared?: boolean): Nullable<IndicesArray>;
  12123. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  12124. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  12125. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  12126. }
  12127. class VertexData {
  12128. positions: Nullable<FloatArray>;
  12129. normals: Nullable<FloatArray>;
  12130. tangents: Nullable<FloatArray>;
  12131. uvs: Nullable<FloatArray>;
  12132. uvs2: Nullable<FloatArray>;
  12133. uvs3: Nullable<FloatArray>;
  12134. uvs4: Nullable<FloatArray>;
  12135. uvs5: Nullable<FloatArray>;
  12136. uvs6: Nullable<FloatArray>;
  12137. colors: Nullable<FloatArray>;
  12138. matricesIndices: Nullable<FloatArray>;
  12139. matricesWeights: Nullable<FloatArray>;
  12140. matricesIndicesExtra: Nullable<FloatArray>;
  12141. matricesWeightsExtra: Nullable<FloatArray>;
  12142. indices: Nullable<IndicesArray>;
  12143. set(data: FloatArray, kind: string): void;
  12144. /**
  12145. * Associates the vertexData to the passed Mesh.
  12146. * Sets it as updatable or not (default `false`).
  12147. * Returns the VertexData.
  12148. */
  12149. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  12150. /**
  12151. * Associates the vertexData to the passed Geometry.
  12152. * Sets it as updatable or not (default `false`).
  12153. * Returns the VertexData.
  12154. */
  12155. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  12156. /**
  12157. * Updates the associated mesh.
  12158. * Returns the VertexData.
  12159. */
  12160. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  12161. /**
  12162. * Updates the associated geometry.
  12163. * Returns the VertexData.
  12164. */
  12165. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): VertexData;
  12166. private _applyTo(meshOrGeometry, updatable?);
  12167. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  12168. /**
  12169. * Transforms each position and each normal of the vertexData according to the passed Matrix.
  12170. * Returns the VertexData.
  12171. */
  12172. transform(matrix: Matrix): VertexData;
  12173. /**
  12174. * Merges the passed VertexData into the current one.
  12175. * Returns the modified VertexData.
  12176. */
  12177. merge(other: VertexData, options?: {
  12178. tangentLength?: number;
  12179. }): VertexData;
  12180. private _mergeElement(source, other, length?, defaultValue?);
  12181. /**
  12182. * Serializes the VertexData.
  12183. * Returns a serialized object.
  12184. */
  12185. serialize(): any;
  12186. /**
  12187. * Returns the object VertexData associated to the passed mesh.
  12188. */
  12189. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  12190. /**
  12191. * Returns the object VertexData associated to the passed geometry.
  12192. */
  12193. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  12194. private static _ExtractFrom(meshOrGeometry, copyWhenShared?, forceCopy?);
  12195. /**
  12196. * Creates the vertexData of the Ribbon.
  12197. */
  12198. static CreateRibbon(options: {
  12199. pathArray: Vector3[][];
  12200. closeArray?: boolean;
  12201. closePath?: boolean;
  12202. offset?: number;
  12203. sideOrientation?: number;
  12204. frontUVs?: Vector4;
  12205. backUVs?: Vector4;
  12206. invertUV?: boolean;
  12207. uvs?: Vector2[];
  12208. colors?: Color4[];
  12209. }): VertexData;
  12210. /**
  12211. * Creates the VertexData of the Box.
  12212. */
  12213. static CreateBox(options: {
  12214. size?: number;
  12215. width?: number;
  12216. height?: number;
  12217. depth?: number;
  12218. faceUV?: Vector4[];
  12219. faceColors?: Color4[];
  12220. sideOrientation?: number;
  12221. frontUVs?: Vector4;
  12222. backUVs?: Vector4;
  12223. }): VertexData;
  12224. /**
  12225. * Creates the VertexData of the Sphere.
  12226. */
  12227. static CreateSphere(options: {
  12228. segments?: number;
  12229. diameter?: number;
  12230. diameterX?: number;
  12231. diameterY?: number;
  12232. diameterZ?: number;
  12233. arc?: number;
  12234. slice?: number;
  12235. sideOrientation?: number;
  12236. frontUVs?: Vector4;
  12237. backUVs?: Vector4;
  12238. }): VertexData;
  12239. /**
  12240. * Creates the VertexData of the Cylinder or Cone.
  12241. */
  12242. static CreateCylinder(options: {
  12243. height?: number;
  12244. diameterTop?: number;
  12245. diameterBottom?: number;
  12246. diameter?: number;
  12247. tessellation?: number;
  12248. subdivisions?: number;
  12249. arc?: number;
  12250. faceColors?: Color4[];
  12251. faceUV?: Vector4[];
  12252. hasRings?: boolean;
  12253. enclose?: boolean;
  12254. sideOrientation?: number;
  12255. frontUVs?: Vector4;
  12256. backUVs?: Vector4;
  12257. }): VertexData;
  12258. /**
  12259. * Creates the VertexData of the Torus.
  12260. */
  12261. static CreateTorus(options: {
  12262. diameter?: number;
  12263. thickness?: number;
  12264. tessellation?: number;
  12265. sideOrientation?: number;
  12266. frontUVs?: Vector4;
  12267. backUVs?: Vector4;
  12268. }): VertexData;
  12269. /**
  12270. * Creates the VertexData of the LineSystem.
  12271. */
  12272. static CreateLineSystem(options: {
  12273. lines: Vector3[][];
  12274. colors?: Nullable<Color4[][]>;
  12275. }): VertexData;
  12276. /**
  12277. * Create the VertexData of the DashedLines.
  12278. */
  12279. static CreateDashedLines(options: {
  12280. points: Vector3[];
  12281. dashSize?: number;
  12282. gapSize?: number;
  12283. dashNb?: number;
  12284. }): VertexData;
  12285. /**
  12286. * Creates the VertexData of the Ground.
  12287. */
  12288. static CreateGround(options: {
  12289. width?: number;
  12290. height?: number;
  12291. subdivisions?: number;
  12292. subdivisionsX?: number;
  12293. subdivisionsY?: number;
  12294. }): VertexData;
  12295. /**
  12296. * Creates the VertexData of the TiledGround.
  12297. */
  12298. static CreateTiledGround(options: {
  12299. xmin: number;
  12300. zmin: number;
  12301. xmax: number;
  12302. zmax: number;
  12303. subdivisions?: {
  12304. w: number;
  12305. h: number;
  12306. };
  12307. precision?: {
  12308. w: number;
  12309. h: number;
  12310. };
  12311. }): VertexData;
  12312. /**
  12313. * Creates the VertexData of the Ground designed from a heightmap.
  12314. */
  12315. static CreateGroundFromHeightMap(options: {
  12316. width: number;
  12317. height: number;
  12318. subdivisions: number;
  12319. minHeight: number;
  12320. maxHeight: number;
  12321. colorFilter: Color3;
  12322. buffer: Uint8Array;
  12323. bufferWidth: number;
  12324. bufferHeight: number;
  12325. }): VertexData;
  12326. /**
  12327. * Creates the VertexData of the Plane.
  12328. */
  12329. static CreatePlane(options: {
  12330. size?: number;
  12331. width?: number;
  12332. height?: number;
  12333. sideOrientation?: number;
  12334. frontUVs?: Vector4;
  12335. backUVs?: Vector4;
  12336. }): VertexData;
  12337. /**
  12338. * Creates the VertexData of the Disc or regular Polygon.
  12339. */
  12340. static CreateDisc(options: {
  12341. radius?: number;
  12342. tessellation?: number;
  12343. arc?: number;
  12344. sideOrientation?: number;
  12345. frontUVs?: Vector4;
  12346. backUVs?: Vector4;
  12347. }): VertexData;
  12348. /**
  12349. * Re-creates the VertexData of the Polygon for sideOrientation.
  12350. */
  12351. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  12352. /**
  12353. * Creates the VertexData of the IcoSphere.
  12354. */
  12355. static CreateIcoSphere(options: {
  12356. radius?: number;
  12357. radiusX?: number;
  12358. radiusY?: number;
  12359. radiusZ?: number;
  12360. flat?: boolean;
  12361. subdivisions?: number;
  12362. sideOrientation?: number;
  12363. frontUVs?: Vector4;
  12364. backUVs?: Vector4;
  12365. }): VertexData;
  12366. /**
  12367. * Creates the VertexData of the Polyhedron.
  12368. */
  12369. static CreatePolyhedron(options: {
  12370. type?: number;
  12371. size?: number;
  12372. sizeX?: number;
  12373. sizeY?: number;
  12374. sizeZ?: number;
  12375. custom?: any;
  12376. faceUV?: Vector4[];
  12377. faceColors?: Color4[];
  12378. flat?: boolean;
  12379. sideOrientation?: number;
  12380. frontUVs?: Vector4;
  12381. backUVs?: Vector4;
  12382. }): VertexData;
  12383. /**
  12384. * Creates the VertexData of the Torus Knot.
  12385. */
  12386. static CreateTorusKnot(options: {
  12387. radius?: number;
  12388. tube?: number;
  12389. radialSegments?: number;
  12390. tubularSegments?: number;
  12391. p?: number;
  12392. q?: number;
  12393. sideOrientation?: number;
  12394. frontUVs?: Vector4;
  12395. backUVs?: Vector4;
  12396. }): VertexData;
  12397. /**
  12398. * @param {any} - positions (number[] or Float32Array)
  12399. * @param {any} - indices (number[] or Uint16Array)
  12400. * @param {any} - normals (number[] or Float32Array)
  12401. * options (optional) :
  12402. * facetPositions : optional array of facet positions (vector3)
  12403. * facetNormals : optional array of facet normals (vector3)
  12404. * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  12405. * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  12406. * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  12407. * bbSize : optional bounding box size data, required for facetPartitioning computation
  12408. * bInfo : optional bounding info, required for facetPartitioning computation
  12409. * useRightHandedSystem: optional boolean to for right handed system computation
  12410. * depthSort : optional boolean to enable the facet depth sort computation
  12411. * distanceTo : optional Vector3 to compute the facet depth from this location
  12412. * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  12413. */
  12414. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  12415. facetNormals?: any;
  12416. facetPositions?: any;
  12417. facetPartitioning?: any;
  12418. ratio?: number;
  12419. bInfo?: any;
  12420. bbSize?: Vector3;
  12421. subDiv?: any;
  12422. useRightHandedSystem?: boolean;
  12423. depthSort?: boolean;
  12424. distanceTo?: Vector3;
  12425. depthSortedFacets?: any;
  12426. }): void;
  12427. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs?, backUVs?);
  12428. /**
  12429. * Creates a new VertexData from the imported parameters.
  12430. */
  12431. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  12432. }
  12433. }
  12434. declare module BABYLON {
  12435. class MeshBuilder {
  12436. private static updateSideOrientation(orientation?);
  12437. /**
  12438. * Creates a box mesh.
  12439. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#box
  12440. * The parameter `size` sets the size (float) of each box side (default 1).
  12441. * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value than `size`).
  12442. * 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).
  12443. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  12444. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12445. * 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).
  12446. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12447. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12448. */
  12449. static CreateBox(name: string, options: {
  12450. size?: number;
  12451. width?: number;
  12452. height?: number;
  12453. depth?: number;
  12454. faceUV?: Vector4[];
  12455. faceColors?: Color4[];
  12456. sideOrientation?: number;
  12457. frontUVs?: Vector4;
  12458. backUVs?: Vector4;
  12459. updatable?: boolean;
  12460. }, scene?: Nullable<Scene>): Mesh;
  12461. /**
  12462. * Creates a sphere mesh.
  12463. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#sphere
  12464. * The parameter `diameter` sets the diameter size (float) of the sphere (default 1).
  12465. * 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 than `diameter`).
  12466. * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32).
  12467. * 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
  12468. * 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).
  12469. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12470. * 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).
  12471. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12472. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12473. */
  12474. static CreateSphere(name: string, options: {
  12475. segments?: number;
  12476. diameter?: number;
  12477. diameterX?: number;
  12478. diameterY?: number;
  12479. diameterZ?: number;
  12480. arc?: number;
  12481. slice?: number;
  12482. sideOrientation?: number;
  12483. frontUVs?: Vector4;
  12484. backUVs?: Vector4;
  12485. updatable?: boolean;
  12486. }, scene: any): Mesh;
  12487. /**
  12488. * Creates a plane polygonal mesh. By default, this is a disc.
  12489. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#disc
  12490. * The parameter `radius` sets the radius size (float) of the polygon (default 0.5).
  12491. * 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.
  12492. * 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
  12493. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12494. * 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).
  12495. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12496. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12497. */
  12498. static CreateDisc(name: string, options: {
  12499. radius?: number;
  12500. tessellation?: number;
  12501. arc?: number;
  12502. updatable?: boolean;
  12503. sideOrientation?: number;
  12504. frontUVs?: Vector4;
  12505. backUVs?: Vector4;
  12506. }, scene?: Nullable<Scene>): Mesh;
  12507. /**
  12508. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided.
  12509. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#icosphere
  12510. * The parameter `radius` sets the radius size (float) of the icosphere (default 1).
  12511. * 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`).
  12512. * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size.
  12513. * 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.
  12514. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12515. * 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).
  12516. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12517. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12518. */
  12519. static CreateIcoSphere(name: string, options: {
  12520. radius?: number;
  12521. radiusX?: number;
  12522. radiusY?: number;
  12523. radiusZ?: number;
  12524. flat?: boolean;
  12525. subdivisions?: number;
  12526. sideOrientation?: number;
  12527. frontUVs?: Vector4;
  12528. backUVs?: Vector4;
  12529. updatable?: boolean;
  12530. }, scene: Scene): Mesh;
  12531. /**
  12532. * Creates a ribbon mesh.
  12533. * The ribbon is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  12534. *
  12535. * Please read this full tutorial to understand how to design a ribbon : http://doc.babylonjs.com/tutorials/Ribbon_Tutorial
  12536. * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  12537. * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array.
  12538. * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array.
  12539. * 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.
  12540. * 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.
  12541. * The optional parameter `instance` is an instance of an existing Ribbon object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#ribbon
  12542. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12543. * 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).
  12544. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12545. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  12546. * 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.
  12547. * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values.
  12548. * 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
  12549. * if you set `closePath` to `true`, there's one extra vertex per path in the geometry.
  12550. * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time.
  12551. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12552. */
  12553. static CreateRibbon(name: string, options: {
  12554. pathArray: Vector3[][];
  12555. closeArray?: boolean;
  12556. closePath?: boolean;
  12557. offset?: number;
  12558. updatable?: boolean;
  12559. sideOrientation?: number;
  12560. frontUVs?: Vector4;
  12561. backUVs?: Vector4;
  12562. instance?: Mesh;
  12563. invertUV?: boolean;
  12564. uvs?: Vector2[];
  12565. colors?: Color4[];
  12566. }, scene?: Nullable<Scene>): Mesh;
  12567. /**
  12568. * Creates a cylinder or a cone mesh.
  12569. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#cylinder-or-cone
  12570. * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  12571. * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  12572. * 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.
  12573. * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  12574. * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  12575. * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  12576. * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  12577. * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  12578. * 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).
  12579. * 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
  12580. * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  12581. * 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
  12582. * 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.
  12583. * If `enclose` is false, a ring surface is one element.
  12584. * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  12585. * Example how to set colors and textures on a sliced cylinder : http://www.html5gamedevs.com/topic/17945-creating-a-closed-slice-of-a-cylinder/#comment-106379
  12586. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12587. * 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).
  12588. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12589. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12590. */
  12591. static CreateCylinder(name: string, options: {
  12592. height?: number;
  12593. diameterTop?: number;
  12594. diameterBottom?: number;
  12595. diameter?: number;
  12596. tessellation?: number;
  12597. subdivisions?: number;
  12598. arc?: number;
  12599. faceColors?: Color4[];
  12600. faceUV?: Vector4[];
  12601. updatable?: boolean;
  12602. hasRings?: boolean;
  12603. enclose?: boolean;
  12604. sideOrientation?: number;
  12605. frontUVs?: Vector4;
  12606. backUVs?: Vector4;
  12607. }, scene: any): Mesh;
  12608. /**
  12609. * Creates a torus mesh.
  12610. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus
  12611. * The parameter `diameter` sets the diameter size (float) of the torus (default 1).
  12612. * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5).
  12613. * The parameter `tessellation` sets the number of torus sides (postive integer, default 16).
  12614. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12615. * 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).
  12616. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12617. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12618. */
  12619. static CreateTorus(name: string, options: {
  12620. diameter?: number;
  12621. thickness?: number;
  12622. tessellation?: number;
  12623. updatable?: boolean;
  12624. sideOrientation?: number;
  12625. frontUVs?: Vector4;
  12626. backUVs?: Vector4;
  12627. }, scene: any): Mesh;
  12628. /**
  12629. * Creates a torus knot mesh.
  12630. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#torus-knot
  12631. * The parameter `radius` sets the global radius size (float) of the torus knot (default 2).
  12632. * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32).
  12633. * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32).
  12634. * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3).
  12635. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12636. * 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).
  12637. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12638. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12639. */
  12640. static CreateTorusKnot(name: string, options: {
  12641. radius?: number;
  12642. tube?: number;
  12643. radialSegments?: number;
  12644. tubularSegments?: number;
  12645. p?: number;
  12646. q?: number;
  12647. updatable?: boolean;
  12648. sideOrientation?: number;
  12649. frontUVs?: Vector4;
  12650. backUVs?: Vector4;
  12651. }, scene: any): Mesh;
  12652. /**
  12653. * Creates a line system mesh.
  12654. * A line system is a pool of many lines gathered in a single mesh.
  12655. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#linesystem
  12656. * 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.
  12657. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function.
  12658. * The parameter `lines` is an array of lines, each line being an array of successive Vector3.
  12659. * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter. The way to update it is the same than for
  12660. * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point.
  12661. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need the alpha blending (faster).
  12662. * updating a simple Line mesh, you just need to update every line in the `lines` array : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  12663. * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines.
  12664. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12665. */
  12666. static CreateLineSystem(name: string, options: {
  12667. lines: Vector3[][];
  12668. updatable: boolean;
  12669. instance: Nullable<LinesMesh>;
  12670. colors?: Nullable<Color4[][]>;
  12671. useVertexAlpha?: boolean;
  12672. }, scene: Nullable<Scene>): LinesMesh;
  12673. /**
  12674. * Creates a line mesh.
  12675. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lines
  12676. * 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.
  12677. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  12678. * The parameter `points` is an array successive Vector3.
  12679. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  12680. * The optional parameter `colors` is an array of successive Color4, one per line point.
  12681. * The optional parameter `useVertexAlpha' is to be set to `false` (default `true`) when you don't need alpha blending (faster).
  12682. * When updating an instance, remember that only point positions can change, not the number of points.
  12683. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12684. */
  12685. static CreateLines(name: string, options: {
  12686. points: Vector3[];
  12687. updatable: boolean;
  12688. instance: Nullable<LinesMesh>;
  12689. colors?: Color4[];
  12690. useVertexAlpha?: boolean;
  12691. }, scene?: Nullable<Scene>): LinesMesh;
  12692. /**
  12693. * Creates a dashed line mesh.
  12694. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#dashed-lines
  12695. * 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.
  12696. * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function.
  12697. * The parameter `points` is an array successive Vector3.
  12698. * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200).
  12699. * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3).
  12700. * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1).
  12701. * The optional parameter `instance` is an instance of an existing LineMesh object to be updated with the passed `points` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#lines-and-dashedlines
  12702. * When updating an instance, remember that only point positions can change, not the number of points.
  12703. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12704. */
  12705. static CreateDashedLines(name: string, options: {
  12706. points: Vector3[];
  12707. dashSize?: number;
  12708. gapSize?: number;
  12709. dashNb?: number;
  12710. updatable?: boolean;
  12711. instance?: LinesMesh;
  12712. }, scene?: Nullable<Scene>): LinesMesh;
  12713. /**
  12714. * Creates an extruded shape mesh.
  12715. * The extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  12716. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#extruded-shapes
  12717. *
  12718. * Please read this full tutorial to understand how to design an extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  12719. * 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
  12720. * extruded along the Z axis.
  12721. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  12722. * 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.
  12723. * The parameter `scale` (float, default 1) is the value to scale the shape.
  12724. * 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
  12725. * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  12726. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  12727. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12728. * 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).
  12729. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12730. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  12731. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12732. */
  12733. static ExtrudeShape(name: string, options: {
  12734. shape: Vector3[];
  12735. path: Vector3[];
  12736. scale?: number;
  12737. rotation?: number;
  12738. cap?: number;
  12739. updatable?: boolean;
  12740. sideOrientation?: number;
  12741. frontUVs?: Vector4;
  12742. backUVs?: Vector4;
  12743. instance?: Mesh;
  12744. invertUV?: boolean;
  12745. }, scene?: Nullable<Scene>): Mesh;
  12746. /**
  12747. * Creates an custom extruded shape mesh.
  12748. * The custom extrusion is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  12749. * tuto :http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#custom-extruded-shapes
  12750. *
  12751. * Please read this full tutorial to understand how to design a custom extruded shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes#extrusion
  12752. * 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
  12753. * extruded along the Z axis.
  12754. * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  12755. * 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
  12756. * and the distance of this point from the begining of the path :
  12757. * ```javascript
  12758. * var rotationFunction = function(i, distance) {
  12759. * // do things
  12760. * return rotationValue; }
  12761. * ```
  12762. * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  12763. * 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
  12764. * and the distance of this point from the begining of the path :
  12765. * ```javascript
  12766. * var scaleFunction = function(i, distance) {
  12767. * // do things
  12768. * return scaleValue;}
  12769. * ```
  12770. * It must returns a float value that will be the scale value applied to the shape on each path point.
  12771. * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`.
  12772. * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`.
  12773. * 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
  12774. * The optional parameter `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/tutorials/How_to_dynamically_morph_a_mesh#extruded-shape
  12775. * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  12776. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12777. * 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).
  12778. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12779. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  12780. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12781. */
  12782. static ExtrudeShapeCustom(name: string, options: {
  12783. shape: Vector3[];
  12784. path: Vector3[];
  12785. scaleFunction?: any;
  12786. rotationFunction?: any;
  12787. ribbonCloseArray?: boolean;
  12788. ribbonClosePath?: boolean;
  12789. cap?: number;
  12790. updatable?: boolean;
  12791. sideOrientation?: number;
  12792. frontUVs?: Vector4;
  12793. backUVs?: Vector4;
  12794. instance?: Mesh;
  12795. invertUV?: boolean;
  12796. }, scene: Scene): Mesh;
  12797. /**
  12798. * Creates lathe mesh.
  12799. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  12800. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#lathe
  12801. *
  12802. * 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
  12803. * rotated around the Y axis. It's usually a 2D shape, so the Vector3 z coordinates are often set to zero.
  12804. * The parameter `radius` (positive float, default 1) is the radius value of the lathe.
  12805. * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe.
  12806. * 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.
  12807. * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc".
  12808. * 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
  12809. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12810. * 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).
  12811. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12812. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  12813. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12814. */
  12815. static CreateLathe(name: string, options: {
  12816. shape: Vector3[];
  12817. radius?: number;
  12818. tessellation?: number;
  12819. arc?: number;
  12820. closed?: boolean;
  12821. updatable?: boolean;
  12822. sideOrientation?: number;
  12823. frontUVs?: Vector4;
  12824. backUVs?: Vector4;
  12825. cap?: number;
  12826. invertUV?: boolean;
  12827. }, scene: Scene): Mesh;
  12828. /**
  12829. * Creates a plane mesh.
  12830. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  12831. * The parameter `size` sets the size (float) of both sides of the plane at once (default 1).
  12832. * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value than `size`).
  12833. * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane.
  12834. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12835. * 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).
  12836. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12837. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12838. */
  12839. static CreatePlane(name: string, options: {
  12840. size?: number;
  12841. width?: number;
  12842. height?: number;
  12843. sideOrientation?: number;
  12844. frontUVs?: Vector4;
  12845. backUVs?: Vector4;
  12846. updatable?: boolean;
  12847. sourcePlane?: Plane;
  12848. }, scene: Scene): Mesh;
  12849. /**
  12850. * Creates a ground mesh.
  12851. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#plane
  12852. * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground.
  12853. * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side.
  12854. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12855. */
  12856. static CreateGround(name: string, options: {
  12857. width?: number;
  12858. height?: number;
  12859. subdivisions?: number;
  12860. subdivisionsX?: number;
  12861. subdivisionsY?: number;
  12862. updatable?: boolean;
  12863. }, scene: any): Mesh;
  12864. /**
  12865. * Creates a tiled ground mesh.
  12866. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tiled-ground
  12867. * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates.
  12868. * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates.
  12869. * The parameter `subdivisions` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 6, h: 6}`). `w` and `h` are the
  12870. * numbers of subdivisions on the ground width and height. Each subdivision is called a tile.
  12871. * The parameter `precision` is a javascript object `{w: positive integer, h: positive integer}` (default `{w: 2, h: 2}`). `w` and `h` are the
  12872. * numbers of subdivisions on the ground width and height of each tile.
  12873. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12874. */
  12875. static CreateTiledGround(name: string, options: {
  12876. xmin: number;
  12877. zmin: number;
  12878. xmax: number;
  12879. zmax: number;
  12880. subdivisions?: {
  12881. w: number;
  12882. h: number;
  12883. };
  12884. precision?: {
  12885. w: number;
  12886. h: number;
  12887. };
  12888. updatable?: boolean;
  12889. }, scene: Scene): Mesh;
  12890. /**
  12891. * Creates a ground mesh from a height map.
  12892. * tuto : http://doc.babylonjs.com/tutorials/14._Height_Map
  12893. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#ground-from-a-height-map
  12894. * The parameter `url` sets the URL of the height map image resource.
  12895. * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  12896. * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  12897. * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  12898. * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  12899. * 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.
  12900. * 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).
  12901. * This function is passed the newly built mesh :
  12902. * ```javascript
  12903. * function(mesh) { // do things
  12904. * return; }
  12905. * ```
  12906. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12907. */
  12908. static CreateGroundFromHeightMap(name: string, url: string, options: {
  12909. width?: number;
  12910. height?: number;
  12911. subdivisions?: number;
  12912. minHeight?: number;
  12913. maxHeight?: number;
  12914. colorFilter?: Color3;
  12915. updatable?: boolean;
  12916. onReady?: (mesh: GroundMesh) => void;
  12917. }, scene: Scene): GroundMesh;
  12918. /**
  12919. * Creates a polygon mesh.
  12920. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  12921. * 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.
  12922. * You can set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12923. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12924. * 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).
  12925. * Remember you can only change the shape positions, not their number when updating a polygon.
  12926. */
  12927. static CreatePolygon(name: string, options: {
  12928. shape: Vector3[];
  12929. holes?: Vector3[][];
  12930. depth?: number;
  12931. faceUV?: Vector4[];
  12932. faceColors?: Color4[];
  12933. updatable?: boolean;
  12934. sideOrientation?: number;
  12935. frontUVs?: Vector4;
  12936. backUVs?: Vector4;
  12937. }, scene: Scene): Mesh;
  12938. /**
  12939. * Creates an extruded polygon mesh, with depth in the Y direction.
  12940. * 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).
  12941. * Please read this tutorial : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  12942. */
  12943. static ExtrudePolygon(name: string, options: {
  12944. shape: Vector3[];
  12945. holes?: Vector3[][];
  12946. depth?: number;
  12947. faceUV?: Vector4[];
  12948. faceColors?: Color4[];
  12949. updatable?: boolean;
  12950. sideOrientation?: number;
  12951. frontUVs?: Vector4;
  12952. backUVs?: Vector4;
  12953. }, scene: Scene): Mesh;
  12954. /**
  12955. * Creates a tube mesh.
  12956. * The tube is a parametric shape : http://doc.babylonjs.com/tutorials/Parametric_Shapes. It has no predefined shape. Its final shape will depend on the input parameters.
  12957. *
  12958. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#tube
  12959. * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube.
  12960. * The parameter `radius` (positive float, default 1) sets the tube radius size.
  12961. * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface.
  12962. * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`.
  12963. * 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.
  12964. * It must return a radius value (positive float) :
  12965. * ```javascript
  12966. * var radiusFunction = function(i, distance) {
  12967. * // do things
  12968. * return radius; }
  12969. * ```
  12970. * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc.
  12971. * 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
  12972. * The optional parameter `instance` is an instance of an existing Tube object to be updated with the passed `pathArray` parameter : http://doc.babylonjs.com/tutorials/How_to_dynamically_morph_a_mesh#tube
  12973. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  12974. * 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).
  12975. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  12976. * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  12977. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  12978. */
  12979. static CreateTube(name: string, options: {
  12980. path: Vector3[];
  12981. radius?: number;
  12982. tessellation?: number;
  12983. radiusFunction?: {
  12984. (i: number, distance: number): number;
  12985. };
  12986. cap?: number;
  12987. arc?: number;
  12988. updatable?: boolean;
  12989. sideOrientation?: number;
  12990. frontUVs?: Vector4;
  12991. backUVs?: Vector4;
  12992. instance?: Mesh;
  12993. invertUV?: boolean;
  12994. }, scene: Scene): Mesh;
  12995. /**
  12996. * Creates a polyhedron mesh.
  12997. *
  12998. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#polyhedron
  12999. * 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
  13000. * to choose the wanted type.
  13001. * The parameter `size` (positive float, default 1) sets the polygon size.
  13002. * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value).
  13003. * 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`.
  13004. * 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
  13005. * 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)`).
  13006. * 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 : http://doc.babylonjs.com/tutorials/CreateBox_Per_Face_Textures_And_Colors
  13007. * 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.
  13008. * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  13009. * 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).
  13010. * Detail here : http://doc.babylonjs.com/tutorials/02._Discover_Basic_Elements#side-orientation
  13011. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  13012. */
  13013. static CreatePolyhedron(name: string, options: {
  13014. type?: number;
  13015. size?: number;
  13016. sizeX?: number;
  13017. sizeY?: number;
  13018. sizeZ?: number;
  13019. custom?: any;
  13020. faceUV?: Vector4[];
  13021. faceColors?: Color4[];
  13022. flat?: boolean;
  13023. updatable?: boolean;
  13024. sideOrientation?: number;
  13025. frontUVs?: Vector4;
  13026. backUVs?: Vector4;
  13027. }, scene: Scene): Mesh;
  13028. /**
  13029. * Creates a decal mesh.
  13030. * tuto : http://doc.babylonjs.com/tutorials/Mesh_CreateXXX_Methods_With_Options_Parameter#decals
  13031. * 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.
  13032. * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates.
  13033. * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates.
  13034. * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling.
  13035. * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal.
  13036. */
  13037. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  13038. position?: Vector3;
  13039. normal?: Vector3;
  13040. size?: Vector3;
  13041. angle?: number;
  13042. }): Mesh;
  13043. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs);
  13044. }
  13045. }
  13046. declare module BABYLON {
  13047. class MeshLODLevel {
  13048. distance: number;
  13049. mesh: Mesh;
  13050. constructor(distance: number, mesh: Mesh);
  13051. }
  13052. }
  13053. declare module BABYLON {
  13054. /**
  13055. * A simplifier interface for future simplification implementations.
  13056. */
  13057. interface ISimplifier {
  13058. /**
  13059. * Simplification of a given mesh according to the given settings.
  13060. * Since this requires computation, it is assumed that the function runs async.
  13061. * @param settings The settings of the simplification, including quality and distance
  13062. * @param successCallback A callback that will be called after the mesh was simplified.
  13063. * @param errorCallback in case of an error, this callback will be called. optional.
  13064. */
  13065. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  13066. }
  13067. /**
  13068. * Expected simplification settings.
  13069. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  13070. */
  13071. interface ISimplificationSettings {
  13072. quality: number;
  13073. distance: number;
  13074. optimizeMesh?: boolean;
  13075. }
  13076. class SimplificationSettings implements ISimplificationSettings {
  13077. quality: number;
  13078. distance: number;
  13079. optimizeMesh: boolean | undefined;
  13080. constructor(quality: number, distance: number, optimizeMesh?: boolean | undefined);
  13081. }
  13082. interface ISimplificationTask {
  13083. settings: Array<ISimplificationSettings>;
  13084. simplificationType: SimplificationType;
  13085. mesh: Mesh;
  13086. successCallback?: () => void;
  13087. parallelProcessing: boolean;
  13088. }
  13089. class SimplificationQueue {
  13090. private _simplificationArray;
  13091. running: boolean;
  13092. constructor();
  13093. addTask(task: ISimplificationTask): void;
  13094. executeNext(): void;
  13095. runSimplification(task: ISimplificationTask): void;
  13096. private getSimplifier(task);
  13097. }
  13098. /**
  13099. * The implemented types of simplification.
  13100. * At the moment only Quadratic Error Decimation is implemented.
  13101. */
  13102. enum SimplificationType {
  13103. QUADRATIC = 0,
  13104. }
  13105. class DecimationTriangle {
  13106. vertices: Array<DecimationVertex>;
  13107. normal: Vector3;
  13108. error: Array<number>;
  13109. deleted: boolean;
  13110. isDirty: boolean;
  13111. borderFactor: number;
  13112. deletePending: boolean;
  13113. originalOffset: number;
  13114. constructor(vertices: Array<DecimationVertex>);
  13115. }
  13116. class DecimationVertex {
  13117. position: Vector3;
  13118. id: number;
  13119. q: QuadraticMatrix;
  13120. isBorder: boolean;
  13121. triangleStart: number;
  13122. triangleCount: number;
  13123. originalOffsets: Array<number>;
  13124. constructor(position: Vector3, id: number);
  13125. updatePosition(newPosition: Vector3): void;
  13126. }
  13127. class QuadraticMatrix {
  13128. data: Array<number>;
  13129. constructor(data?: Array<number>);
  13130. det(a11: number, a12: number, a13: number, a21: number, a22: number, a23: number, a31: number, a32: number, a33: number): number;
  13131. addInPlace(matrix: QuadraticMatrix): void;
  13132. addArrayInPlace(data: Array<number>): void;
  13133. add(matrix: QuadraticMatrix): QuadraticMatrix;
  13134. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  13135. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  13136. }
  13137. class Reference {
  13138. vertexId: number;
  13139. triangleId: number;
  13140. constructor(vertexId: number, triangleId: number);
  13141. }
  13142. /**
  13143. * An implementation of the Quadratic Error simplification algorithm.
  13144. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  13145. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  13146. * @author RaananW
  13147. */
  13148. class QuadraticErrorSimplification implements ISimplifier {
  13149. private _mesh;
  13150. private triangles;
  13151. private vertices;
  13152. private references;
  13153. private _reconstructedMesh;
  13154. syncIterations: number;
  13155. aggressiveness: number;
  13156. decimationIterations: number;
  13157. boundingBoxEpsilon: number;
  13158. constructor(_mesh: Mesh);
  13159. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  13160. private runDecimation(settings, submeshIndex, successCallback);
  13161. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  13162. private init(callback);
  13163. private reconstructMesh(submeshIndex);
  13164. private initDecimatedMesh();
  13165. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  13166. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  13167. private identifyBorder();
  13168. private updateMesh(identifyBorders?);
  13169. private vertexError(q, point);
  13170. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  13171. }
  13172. }
  13173. declare module BABYLON {
  13174. class Polygon {
  13175. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  13176. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  13177. static Parse(input: string): Vector2[];
  13178. static StartingAt(x: number, y: number): Path2;
  13179. }
  13180. class PolygonMeshBuilder {
  13181. private _points;
  13182. private _outlinepoints;
  13183. private _holes;
  13184. private _name;
  13185. private _scene;
  13186. private _epoints;
  13187. private _eholes;
  13188. private _addToepoint(points);
  13189. constructor(name: string, contours: Path2, scene: Scene);
  13190. constructor(name: string, contours: Vector2[], scene: Scene);
  13191. addHole(hole: Vector2[]): PolygonMeshBuilder;
  13192. build(updatable?: boolean, depth?: number): Mesh;
  13193. private addSide(positions, normals, uvs, indices, bounds, points, depth, flip);
  13194. }
  13195. }
  13196. declare module BABYLON {
  13197. class BaseSubMesh {
  13198. _materialDefines: Nullable<MaterialDefines>;
  13199. _materialEffect: Nullable<Effect>;
  13200. readonly effect: Nullable<Effect>;
  13201. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  13202. }
  13203. class SubMesh extends BaseSubMesh implements ICullable {
  13204. materialIndex: number;
  13205. verticesStart: number;
  13206. verticesCount: number;
  13207. indexStart: number;
  13208. indexCount: number;
  13209. linesIndexCount: number;
  13210. private _mesh;
  13211. private _renderingMesh;
  13212. private _boundingInfo;
  13213. private _linesIndexBuffer;
  13214. _lastColliderWorldVertices: Nullable<Vector3[]>;
  13215. _trianglePlanes: Plane[];
  13216. _lastColliderTransformMatrix: Matrix;
  13217. _renderId: number;
  13218. _alphaIndex: number;
  13219. _distanceToCamera: number;
  13220. _id: number;
  13221. private _currentMaterial;
  13222. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  13223. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  13224. readonly IsGlobal: boolean;
  13225. /**
  13226. * Returns the submesh BoudingInfo object.
  13227. */
  13228. getBoundingInfo(): BoundingInfo;
  13229. /**
  13230. * Sets the submesh BoundingInfo.
  13231. * Return the SubMesh.
  13232. */
  13233. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  13234. /**
  13235. * Returns the mesh of the current submesh.
  13236. */
  13237. getMesh(): AbstractMesh;
  13238. /**
  13239. * Returns the rendering mesh of the submesh.
  13240. */
  13241. getRenderingMesh(): Mesh;
  13242. /**
  13243. * Returns the submesh material.
  13244. */
  13245. getMaterial(): Nullable<Material>;
  13246. /**
  13247. * Sets a new updated BoundingInfo object to the submesh.
  13248. * Returns the SubMesh.
  13249. */
  13250. refreshBoundingInfo(): SubMesh;
  13251. _checkCollision(collider: Collider): boolean;
  13252. /**
  13253. * Updates the submesh BoundingInfo.
  13254. * Returns the Submesh.
  13255. */
  13256. updateBoundingInfo(world: Matrix): SubMesh;
  13257. /**
  13258. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  13259. * Boolean returned.
  13260. */
  13261. isInFrustum(frustumPlanes: Plane[]): boolean;
  13262. /**
  13263. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes.
  13264. * Boolean returned.
  13265. */
  13266. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  13267. /**
  13268. * Renders the submesh.
  13269. * Returns it.
  13270. */
  13271. render(enableAlphaMode: boolean): SubMesh;
  13272. /**
  13273. * Returns a new Index Buffer.
  13274. * Type returned : WebGLBuffer.
  13275. */
  13276. getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  13277. /**
  13278. * True is the passed Ray intersects the submesh bounding box.
  13279. * Boolean returned.
  13280. */
  13281. canIntersects(ray: Ray): boolean;
  13282. /**
  13283. * Returns an object IntersectionInfo.
  13284. */
  13285. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean): Nullable<IntersectionInfo>;
  13286. _rebuild(): void;
  13287. /**
  13288. * Creates a new Submesh from the passed Mesh.
  13289. */
  13290. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  13291. /**
  13292. * Disposes the Submesh.
  13293. * Returns nothing.
  13294. */
  13295. dispose(): void;
  13296. /**
  13297. * Creates a new Submesh from the passed parameters :
  13298. * - materialIndex (integer) : the index of the main mesh material.
  13299. * - startIndex (integer) : the index where to start the copy in the mesh indices array.
  13300. * - indexCount (integer) : the number of indices to copy then from the startIndex.
  13301. * - mesh (Mesh) : the main mesh to create the submesh from.
  13302. * - renderingMesh (optional Mesh) : rendering mesh.
  13303. */
  13304. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  13305. }
  13306. }
  13307. declare module BABYLON {
  13308. class TransformNode extends Node {
  13309. static BILLBOARDMODE_NONE: number;
  13310. static BILLBOARDMODE_X: number;
  13311. static BILLBOARDMODE_Y: number;
  13312. static BILLBOARDMODE_Z: number;
  13313. static BILLBOARDMODE_ALL: number;
  13314. private _rotation;
  13315. private _rotationQuaternion;
  13316. protected _scaling: Vector3;
  13317. protected _isDirty: boolean;
  13318. private _transformToBoneReferal;
  13319. billboardMode: number;
  13320. scalingDeterminant: number;
  13321. infiniteDistance: boolean;
  13322. position: Vector3;
  13323. _poseMatrix: Matrix;
  13324. private _localWorld;
  13325. _worldMatrix: Matrix;
  13326. _worldMatrixDeterminant: number;
  13327. private _absolutePosition;
  13328. private _pivotMatrix;
  13329. private _pivotMatrixInverse;
  13330. private _postMultiplyPivotMatrix;
  13331. protected _isWorldMatrixFrozen: boolean;
  13332. /**
  13333. * An event triggered after the world matrix is updated
  13334. * @type {BABYLON.Observable}
  13335. */
  13336. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  13337. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  13338. /**
  13339. * Rotation property : a Vector3 depicting the rotation value in radians around each local axis X, Y, Z.
  13340. * If rotation quaternion is set, this Vector3 will (almost always) be the Zero vector!
  13341. * Default : (0.0, 0.0, 0.0)
  13342. */
  13343. rotation: Vector3;
  13344. /**
  13345. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13346. * Default : (1.0, 1.0, 1.0)
  13347. */
  13348. /**
  13349. * Scaling property : a Vector3 depicting the mesh scaling along each local axis X, Y, Z.
  13350. * Default : (1.0, 1.0, 1.0)
  13351. */
  13352. scaling: Vector3;
  13353. /**
  13354. * Rotation Quaternion property : this a Quaternion object depicting the mesh rotation by using a unit quaternion.
  13355. * It's null by default.
  13356. * If set, only the rotationQuaternion is then used to compute the mesh rotation and its property `.rotation\ is then ignored and set to (0.0, 0.0, 0.0)
  13357. */
  13358. rotationQuaternion: Nullable<Quaternion>;
  13359. /**
  13360. * Returns the latest update of the World matrix
  13361. * Returns a Matrix.
  13362. */
  13363. getWorldMatrix(): Matrix;
  13364. /**
  13365. * Returns the latest update of the World matrix determinant.
  13366. */
  13367. protected _getWorldMatrixDeterminant(): number;
  13368. /**
  13369. * Returns directly the latest state of the mesh World matrix.
  13370. * A Matrix is returned.
  13371. */
  13372. readonly worldMatrixFromCache: Matrix;
  13373. /**
  13374. * Copies the paramater passed Matrix into the mesh Pose matrix.
  13375. * Returns the AbstractMesh.
  13376. */
  13377. updatePoseMatrix(matrix: Matrix): TransformNode;
  13378. /**
  13379. * Returns the mesh Pose matrix.
  13380. * Returned object : Matrix
  13381. */
  13382. getPoseMatrix(): Matrix;
  13383. _isSynchronized(): boolean;
  13384. _initCache(): void;
  13385. markAsDirty(property: string): TransformNode;
  13386. /**
  13387. * Returns the current mesh absolute position.
  13388. * Retuns a Vector3.
  13389. */
  13390. readonly absolutePosition: Vector3;
  13391. /**
  13392. * Sets a new pivot matrix to the mesh.
  13393. * Returns the AbstractMesh.
  13394. */
  13395. setPivotMatrix(matrix: Matrix, postMultiplyPivotMatrix?: boolean): TransformNode;
  13396. /**
  13397. * Returns the mesh pivot matrix.
  13398. * Default : Identity.
  13399. * A Matrix is returned.
  13400. */
  13401. getPivotMatrix(): Matrix;
  13402. /**
  13403. * Prevents the World matrix to be computed any longer.
  13404. * Returns the AbstractMesh.
  13405. */
  13406. freezeWorldMatrix(): TransformNode;
  13407. /**
  13408. * Allows back the World matrix computation.
  13409. * Returns the AbstractMesh.
  13410. */
  13411. unfreezeWorldMatrix(): this;
  13412. /**
  13413. * True if the World matrix has been frozen.
  13414. * Returns a boolean.
  13415. */
  13416. readonly isWorldMatrixFrozen: boolean;
  13417. /**
  13418. * Retuns the mesh absolute position in the World.
  13419. * Returns a Vector3.
  13420. */
  13421. getAbsolutePosition(): Vector3;
  13422. /**
  13423. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  13424. * Returns the AbstractMesh.
  13425. */
  13426. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  13427. /**
  13428. * Sets the mesh position in its local space.
  13429. * Returns the AbstractMesh.
  13430. */
  13431. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  13432. /**
  13433. * Returns the mesh position in the local space from the current World matrix values.
  13434. * Returns a new Vector3.
  13435. */
  13436. getPositionExpressedInLocalSpace(): Vector3;
  13437. /**
  13438. * Translates the mesh along the passed Vector3 in its local space.
  13439. * Returns the AbstractMesh.
  13440. */
  13441. locallyTranslate(vector3: Vector3): TransformNode;
  13442. private static _lookAtVectorCache;
  13443. /**
  13444. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  13445. * @param targetPoint the position (must be in same space as current mesh) to look at
  13446. * @param yawCor optional yaw (y-axis) correction in radians
  13447. * @param pitchCor optional pitch (x-axis) correction in radians
  13448. * @param rollCor optional roll (z-axis) correction in radians
  13449. * @param space the choosen space of the target
  13450. * @returns the TransformNode.
  13451. */
  13452. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  13453. /**
  13454. * Returns a new Vector3 what is the localAxis, expressed in the mesh local space, rotated like the mesh.
  13455. * This Vector3 is expressed in the World space.
  13456. */
  13457. getDirection(localAxis: Vector3): Vector3;
  13458. /**
  13459. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  13460. * localAxis is expressed in the mesh local space.
  13461. * result is computed in the Wordl space from the mesh World matrix.
  13462. * Returns the AbstractMesh.
  13463. */
  13464. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  13465. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  13466. /**
  13467. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  13468. */
  13469. getPivotPoint(): Vector3;
  13470. /**
  13471. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  13472. * Returns the AbstractMesh.
  13473. */
  13474. getPivotPointToRef(result: Vector3): TransformNode;
  13475. /**
  13476. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  13477. */
  13478. getAbsolutePivotPoint(): Vector3;
  13479. /**
  13480. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  13481. * Returns the AbstractMesh.
  13482. */
  13483. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  13484. /**
  13485. * Defines the passed node as the parent of the current node.
  13486. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  13487. * Returns the TransformNode.
  13488. */
  13489. setParent(node: Nullable<Node>): TransformNode;
  13490. private _nonUniformScaling;
  13491. readonly nonUniformScaling: boolean;
  13492. _updateNonUniformScalingState(value: boolean): boolean;
  13493. /**
  13494. * Attach the current TransformNode to another TransformNode associated with a bone
  13495. * @param bone Bone affecting the TransformNode
  13496. * @param affectedTransformNode TransformNode associated with the bone
  13497. */
  13498. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  13499. detachFromBone(): TransformNode;
  13500. private static _rotationAxisCache;
  13501. /**
  13502. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  13503. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  13504. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13505. * The passed axis is also normalized.
  13506. * Returns the AbstractMesh.
  13507. */
  13508. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  13509. /**
  13510. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  13511. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  13512. * The passed axis is also normalized.
  13513. * Returns the AbstractMesh.
  13514. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  13515. */
  13516. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  13517. /**
  13518. * Translates the mesh along the axis vector for the passed distance in the given space.
  13519. * space (default LOCAL) can be either BABYLON.Space.LOCAL, either BABYLON.Space.WORLD.
  13520. * Returns the AbstractMesh.
  13521. */
  13522. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  13523. /**
  13524. * Adds a rotation step to the mesh current rotation.
  13525. * x, y, z are Euler angles expressed in radians.
  13526. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  13527. * This means this rotation is made in the mesh local space only.
  13528. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  13529. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  13530. * ```javascript
  13531. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  13532. * ```
  13533. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  13534. * 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.
  13535. * Returns the AbstractMesh.
  13536. */
  13537. addRotation(x: number, y: number, z: number): TransformNode;
  13538. /**
  13539. * Computes the mesh World matrix and returns it.
  13540. * If the mesh world matrix is frozen, this computation does nothing more than returning the last frozen values.
  13541. * If the parameter `force` is let to `false` (default), the current cached World matrix is returned.
  13542. * If the parameter `force`is set to `true`, the actual computation is done.
  13543. * Returns the mesh World Matrix.
  13544. */
  13545. computeWorldMatrix(force?: boolean): Matrix;
  13546. protected _afterComputeWorldMatrix(): void;
  13547. /**
  13548. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  13549. * @param func: callback function to add
  13550. *
  13551. * Returns the TransformNode.
  13552. */
  13553. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13554. /**
  13555. * Removes a registered callback function.
  13556. * Returns the TransformNode.
  13557. */
  13558. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  13559. /**
  13560. * Clone the current transform node
  13561. * Returns the new transform node
  13562. * @param name Name of the new clone
  13563. * @param newParent New parent for the clone
  13564. * @param doNotCloneChildren Do not clone children hierarchy
  13565. */
  13566. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  13567. serialize(currentSerializationObject?: any): any;
  13568. /**
  13569. * Returns a new TransformNode object parsed from the source provided.
  13570. * The parameter `parsedMesh` is the source.
  13571. * The parameter `rootUrl` is a string, it's the root URL to prefix the `delayLoadingFile` property with
  13572. */
  13573. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  13574. /**
  13575. * Disposes the TransformNode.
  13576. * By default, all the children are also disposed unless the parameter `doNotRecurse` is set to `true`.
  13577. * Returns nothing.
  13578. */
  13579. dispose(doNotRecurse?: boolean): void;
  13580. }
  13581. }
  13582. declare module BABYLON {
  13583. class VertexBuffer {
  13584. private _buffer;
  13585. private _kind;
  13586. private _offset;
  13587. private _size;
  13588. private _stride;
  13589. private _ownsBuffer;
  13590. constructor(engine: any, data: FloatArray | Buffer, kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number, instanced?: boolean, offset?: number, size?: number);
  13591. _rebuild(): void;
  13592. /**
  13593. * Returns the kind of the VertexBuffer (string).
  13594. */
  13595. getKind(): string;
  13596. /**
  13597. * Boolean : is the VertexBuffer updatable ?
  13598. */
  13599. isUpdatable(): boolean;
  13600. /**
  13601. * Returns an array of numbers or a Float32Array containing the VertexBuffer data.
  13602. */
  13603. getData(): Nullable<FloatArray>;
  13604. /**
  13605. * Returns the WebGLBuffer associated to the VertexBuffer.
  13606. */
  13607. getBuffer(): Nullable<WebGLBuffer>;
  13608. /**
  13609. * Returns the stride of the VertexBuffer (integer).
  13610. */
  13611. getStrideSize(): number;
  13612. /**
  13613. * Returns the offset (integer).
  13614. */
  13615. getOffset(): number;
  13616. /**
  13617. * Returns the VertexBuffer total size (integer).
  13618. */
  13619. getSize(): number;
  13620. /**
  13621. * Boolean : is the WebGLBuffer of the VertexBuffer instanced now ?
  13622. */
  13623. getIsInstanced(): boolean;
  13624. /**
  13625. * Returns the instancing divisor, zero for non-instanced (integer).
  13626. */
  13627. getInstanceDivisor(): number;
  13628. /**
  13629. * Creates the underlying WebGLBuffer from the passed numeric array or Float32Array.
  13630. * Returns the created WebGLBuffer.
  13631. */
  13632. create(data?: FloatArray): void;
  13633. /**
  13634. * Updates the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  13635. * Returns the updated WebGLBuffer.
  13636. */
  13637. update(data: FloatArray): void;
  13638. /**
  13639. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  13640. * Returns the directly updated WebGLBuffer.
  13641. */
  13642. updateDirectly(data: Float32Array, offset: number): void;
  13643. /**
  13644. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  13645. */
  13646. dispose(): void;
  13647. private static _PositionKind;
  13648. private static _NormalKind;
  13649. private static _TangentKind;
  13650. private static _UVKind;
  13651. private static _UV2Kind;
  13652. private static _UV3Kind;
  13653. private static _UV4Kind;
  13654. private static _UV5Kind;
  13655. private static _UV6Kind;
  13656. private static _ColorKind;
  13657. private static _MatricesIndicesKind;
  13658. private static _MatricesWeightsKind;
  13659. private static _MatricesIndicesExtraKind;
  13660. private static _MatricesWeightsExtraKind;
  13661. static readonly PositionKind: string;
  13662. static readonly NormalKind: string;
  13663. static readonly TangentKind: string;
  13664. static readonly UVKind: string;
  13665. static readonly UV2Kind: string;
  13666. static readonly UV3Kind: string;
  13667. static readonly UV4Kind: string;
  13668. static readonly UV5Kind: string;
  13669. static readonly UV6Kind: string;
  13670. static readonly ColorKind: string;
  13671. static readonly MatricesIndicesKind: string;
  13672. static readonly MatricesWeightsKind: string;
  13673. static readonly MatricesIndicesExtraKind: string;
  13674. static readonly MatricesWeightsExtraKind: string;
  13675. }
  13676. }
  13677. declare module BABYLON {
  13678. /**
  13679. * Particle emitter emitting particles from the inside of a box.
  13680. * It emits the particles randomly between 2 given directions.
  13681. */
  13682. class BoxParticleEmitter implements IParticleEmitterType {
  13683. private _particleSystem;
  13684. /**
  13685. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13686. */
  13687. /**
  13688. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13689. */
  13690. direction1: Vector3;
  13691. /**
  13692. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13693. */
  13694. /**
  13695. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13696. */
  13697. direction2: Vector3;
  13698. /**
  13699. * 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.
  13700. */
  13701. /**
  13702. * 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.
  13703. */
  13704. minEmitBox: Vector3;
  13705. /**
  13706. * 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.
  13707. */
  13708. /**
  13709. * 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.
  13710. */
  13711. maxEmitBox: Vector3;
  13712. /**
  13713. * Creates a new instance of @see BoxParticleEmitter
  13714. * @param _particleSystem the particle system associated with the emitter
  13715. */
  13716. constructor(_particleSystem: ParticleSystem);
  13717. /**
  13718. * Called by the particle System when the direction is computed for the created particle.
  13719. * @param emitPower is the power of the particle (speed)
  13720. * @param worldMatrix is the world matrix of the particle system
  13721. * @param directionToUpdate is the direction vector to update with the result
  13722. * @param particle is the particle we are computed the direction for
  13723. */
  13724. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13725. /**
  13726. * Called by the particle System when the position is computed for the created particle.
  13727. * @param worldMatrix is the world matrix of the particle system
  13728. * @param positionToUpdate is the position vector to update with the result
  13729. * @param particle is the particle we are computed the position for
  13730. */
  13731. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13732. }
  13733. }
  13734. declare module BABYLON {
  13735. /**
  13736. * Particle emitter emitting particles from the inside of a cone.
  13737. * It emits the particles alongside the cone volume from the base to the particle.
  13738. * The emission direction might be randomized.
  13739. */
  13740. class ConeParticleEmitter implements IParticleEmitterType {
  13741. /**
  13742. * The radius of the emission cone.
  13743. */
  13744. angle: number;
  13745. /**
  13746. * The cone base angle.
  13747. */
  13748. directionRandomizer: number;
  13749. private _radius;
  13750. private _height;
  13751. /**
  13752. * Gets the radius of the emission cone.
  13753. */
  13754. /**
  13755. * Sets the radius of the emission cone.
  13756. */
  13757. radius: number;
  13758. /**
  13759. * Creates a new instance of @see ConeParticleEmitter
  13760. * @param radius the radius of the emission cone
  13761. * @param angles the cone base angle
  13762. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13763. */
  13764. constructor(radius: number,
  13765. /**
  13766. * The radius of the emission cone.
  13767. */
  13768. angle: number,
  13769. /**
  13770. * The cone base angle.
  13771. */
  13772. directionRandomizer?: number);
  13773. /**
  13774. * Called by the particle System when the direction is computed for the created particle.
  13775. * @param emitPower is the power of the particle (speed)
  13776. * @param worldMatrix is the world matrix of the particle system
  13777. * @param directionToUpdate is the direction vector to update with the result
  13778. * @param particle is the particle we are computed the direction for
  13779. */
  13780. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13781. /**
  13782. * Called by the particle System when the position is computed for the created particle.
  13783. * @param worldMatrix is the world matrix of the particle system
  13784. * @param positionToUpdate is the position vector to update with the result
  13785. * @param particle is the particle we are computed the position for
  13786. */
  13787. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13788. }
  13789. }
  13790. declare module BABYLON {
  13791. /**
  13792. * This represents a GPU particle system in Babylon.
  13793. * This os the fastest particle system in Babylon as it uses the GPU to update the individual particle data.
  13794. */
  13795. class GPUParticleSystem implements IDisposable, IParticleSystem {
  13796. /**
  13797. * The id of the Particle system.
  13798. */
  13799. id: string;
  13800. /**
  13801. * The friendluname of the Particle system.
  13802. */
  13803. name: string;
  13804. /**
  13805. * The emitter represents the Mesh or position we are attaching the particle system to.
  13806. */
  13807. emitter: Nullable<AbstractMesh | Vector3>;
  13808. /**
  13809. * The rendering group used by the Particle system to chose when to render.
  13810. */
  13811. renderingGroupId: number;
  13812. /**
  13813. * The layer mask we are rendering the particles through.
  13814. */
  13815. layerMask: number;
  13816. private _capacity;
  13817. private _renderEffect;
  13818. private _updateEffect;
  13819. private _updateBuffer;
  13820. private _updateVAO;
  13821. private _updateVertexBuffers;
  13822. private _renderBuffer;
  13823. private _renderVAO;
  13824. private _renderVertexBuffers;
  13825. private _sourceVAO;
  13826. private _targetVAO;
  13827. private _sourceBuffer;
  13828. private _targetBuffer;
  13829. private _scene;
  13830. private _engine;
  13831. private _currentRenderId;
  13832. private _started;
  13833. /**
  13834. * An event triggered when the system is disposed.
  13835. */
  13836. onDisposeObservable: Observable<GPUParticleSystem>;
  13837. /**
  13838. * Gets Wether the system has been started.
  13839. * @returns True if it has been started, otherwise false.
  13840. */
  13841. isStarted(): boolean;
  13842. /**
  13843. * Starts the particle system and begins to emit.
  13844. */
  13845. start(): void;
  13846. /**
  13847. * Stops the particle system.
  13848. */
  13849. stop(): void;
  13850. /**
  13851. * Instantiates a GPU particle system.
  13852. * 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.
  13853. * @param name The name of the particle system
  13854. * @param capacity The max number of particles alive at the same time
  13855. * @param scene The scene the particle system belongs to
  13856. */
  13857. constructor(name: string, capacity: number, scene: Scene);
  13858. /**
  13859. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13860. */
  13861. animate(): void;
  13862. private _initialize();
  13863. /**
  13864. * Renders the particle system in its current state.
  13865. * @returns the current number of particles.
  13866. */
  13867. render(): number;
  13868. /**
  13869. * Rebuilds the particle system
  13870. */
  13871. rebuild(): void;
  13872. /**
  13873. * Disposes the particle system and free the associated resources.
  13874. */
  13875. dispose(): void;
  13876. /**
  13877. * Clones the particle system.
  13878. * @param name The name of the cloned object
  13879. * @param newEmitter The new emitter to use
  13880. * @returns the cloned particle system
  13881. */
  13882. clone(name: string, newEmitter: any): Nullable<GPUParticleSystem>;
  13883. /**
  13884. * Serializes the particle system to a JSON object.
  13885. * @returns the JSON object
  13886. */
  13887. serialize(): any;
  13888. }
  13889. }
  13890. declare module BABYLON {
  13891. /**
  13892. * Particle emitter represents a volume emitting particles.
  13893. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13894. */
  13895. interface IParticleEmitterType {
  13896. /**
  13897. * Called by the particle System when the direction is computed for the created particle.
  13898. * @param emitPower is the power of the particle (speed)
  13899. * @param worldMatrix is the world matrix of the particle system
  13900. * @param directionToUpdate is the direction vector to update with the result
  13901. * @param particle is the particle we are computed the direction for
  13902. */
  13903. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13904. /**
  13905. * Called by the particle System when the position is computed for the created particle.
  13906. * @param worldMatrix is the world matrix of the particle system
  13907. * @param positionToUpdate is the position vector to update with the result
  13908. * @param particle is the particle we are computed the position for
  13909. */
  13910. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  13911. }
  13912. }
  13913. declare module BABYLON {
  13914. /**
  13915. * A particle represents one of the element emitted by a particle system.
  13916. * This is mainly define by its coordinates, direction, velocity and age.
  13917. */
  13918. class Particle {
  13919. private particleSystem;
  13920. /**
  13921. * The world position of the particle in the scene.
  13922. */
  13923. position: Vector3;
  13924. /**
  13925. * The world direction of the particle in the scene.
  13926. */
  13927. direction: Vector3;
  13928. /**
  13929. * The color of the particle.
  13930. */
  13931. color: Color4;
  13932. /**
  13933. * The color change of the particle per step.
  13934. */
  13935. colorStep: Color4;
  13936. /**
  13937. * Defines how long will the life of the particle be.
  13938. */
  13939. lifeTime: number;
  13940. /**
  13941. * The current age of the particle.
  13942. */
  13943. age: number;
  13944. /**
  13945. * The current size of the particle.
  13946. */
  13947. size: number;
  13948. /**
  13949. * The current angle of the particle.
  13950. */
  13951. angle: number;
  13952. /**
  13953. * Defines how fast is the angle changing.
  13954. */
  13955. angularSpeed: number;
  13956. /**
  13957. * Defines the cell index used by the particle to be rendered from a sprite.
  13958. */
  13959. cellIndex: number;
  13960. private _currentFrameCounter;
  13961. /**
  13962. * Creates a new instance of @see Particle
  13963. * @param particleSystem the particle system the particle belongs to
  13964. */
  13965. constructor(particleSystem: ParticleSystem);
  13966. /**
  13967. * Defines how the sprite cell index is updated for the particle. This is
  13968. * defined as a callback.
  13969. */
  13970. updateCellIndex: (scaledUpdateSpeed: number) => void;
  13971. private updateCellIndexWithSpeedCalculated(scaledUpdateSpeed);
  13972. private updateCellIndexWithCustomSpeed();
  13973. /**
  13974. * Copy the properties of particle to another one.
  13975. * @param other the particle to copy the information to.
  13976. */
  13977. copyTo(other: Particle): void;
  13978. }
  13979. }
  13980. declare module BABYLON {
  13981. /**
  13982. * Interface representing a particle system in Babylon.
  13983. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  13984. * A particle system represents a way to manage particles (@see Particle) from their emission to their animation and rendering.
  13985. */
  13986. interface IParticleSystem {
  13987. /**
  13988. * The id of the Particle system.
  13989. */
  13990. id: string;
  13991. /**
  13992. * The name of the Particle system.
  13993. */
  13994. name: string;
  13995. /**
  13996. * The emitter represents the Mesh or position we are attaching the particle system to.
  13997. */
  13998. emitter: Nullable<AbstractMesh | Vector3>;
  13999. /**
  14000. * The rendering group used by the Particle system to chose when to render.
  14001. */
  14002. renderingGroupId: number;
  14003. /**
  14004. * The layer mask we are rendering the particles through.
  14005. */
  14006. layerMask: number;
  14007. /**
  14008. * Gets if the particle system has been started.
  14009. * @return true if the system has been started, otherwise false.
  14010. */
  14011. isStarted(): boolean;
  14012. /**
  14013. * Animates the particle system for this frame.
  14014. */
  14015. animate(): void;
  14016. /**
  14017. * Renders the particle system in its current state.
  14018. * @returns the current number of particles.
  14019. */
  14020. render(): number;
  14021. /**
  14022. * Dispose the particle system and frees its associated resources.
  14023. */
  14024. dispose(): void;
  14025. /**
  14026. * Clones the particle system.
  14027. * @param name The name of the cloned object
  14028. * @param newEmitter The new emitter to use
  14029. * @returns the cloned particle system
  14030. */
  14031. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14032. /**
  14033. * Serializes the particle system to a JSON object.
  14034. * @returns the JSON object
  14035. */
  14036. serialize(): any;
  14037. /**
  14038. * Rebuild the particle system
  14039. */
  14040. rebuild(): void;
  14041. }
  14042. /**
  14043. * This represents a particle system in Babylon.
  14044. * 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.
  14045. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14046. * @example https://doc.babylonjs.com/babylon101/particles
  14047. */
  14048. class ParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  14049. /**
  14050. * Source color is added to the destination color without alpha affecting the result.
  14051. */
  14052. static BLENDMODE_ONEONE: number;
  14053. /**
  14054. * Blend current color and particle color using particle’s alpha.
  14055. */
  14056. static BLENDMODE_STANDARD: number;
  14057. /**
  14058. * List of animations used by the particle system.
  14059. */
  14060. animations: Animation[];
  14061. /**
  14062. * The id of the Particle system.
  14063. */
  14064. id: string;
  14065. /**
  14066. * The friendly name of the Particle system.
  14067. */
  14068. name: string;
  14069. /**
  14070. * The rendering group used by the Particle system to chose when to render.
  14071. */
  14072. renderingGroupId: number;
  14073. /**
  14074. * The emitter represents the Mesh or position we are attaching the particle system to.
  14075. */
  14076. emitter: Nullable<AbstractMesh | Vector3>;
  14077. /**
  14078. * The density of particles, the rate of particle flow
  14079. */
  14080. emitRate: number;
  14081. /**
  14082. * If you want to launch only a few particles at once, that can be done, as well.
  14083. */
  14084. manualEmitCount: number;
  14085. /**
  14086. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14087. */
  14088. updateSpeed: number;
  14089. /**
  14090. * The amount of time the particle system is running (depends of the overall speed above).
  14091. */
  14092. targetStopDuration: number;
  14093. /**
  14094. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14095. */
  14096. disposeOnStop: boolean;
  14097. /**
  14098. * Minimum power of emitting particles.
  14099. */
  14100. minEmitPower: number;
  14101. /**
  14102. * Maximum power of emitting particles.
  14103. */
  14104. maxEmitPower: number;
  14105. /**
  14106. * Minimum life time of emitting particles.
  14107. */
  14108. minLifeTime: number;
  14109. /**
  14110. * Maximum life time of emitting particles.
  14111. */
  14112. maxLifeTime: number;
  14113. /**
  14114. * Minimum Size of emitting particles.
  14115. */
  14116. minSize: number;
  14117. /**
  14118. * Maximum Size of emitting particles.
  14119. */
  14120. maxSize: number;
  14121. /**
  14122. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14123. */
  14124. minAngularSpeed: number;
  14125. /**
  14126. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14127. */
  14128. maxAngularSpeed: number;
  14129. /**
  14130. * The texture used to render each particle. (this can be a spritesheet)
  14131. */
  14132. particleTexture: Nullable<Texture>;
  14133. /**
  14134. * The layer mask we are rendering the particles through.
  14135. */
  14136. layerMask: number;
  14137. /**
  14138. * This can help using your own shader to render the particle system.
  14139. * The according effect will be created
  14140. */
  14141. customShader: any;
  14142. /**
  14143. * By default particle system starts as soon as they are created. This prevents the
  14144. * automatic start to happen and let you decide when to start emitting particles.
  14145. */
  14146. preventAutoStart: boolean;
  14147. /**
  14148. * This function can be defined to provide custom update for active particles.
  14149. * This function will be called instead of regular update (age, position, color, etc.).
  14150. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  14151. */
  14152. updateFunction: (particles: Particle[]) => void;
  14153. /**
  14154. * Callback triggered when the particle animation is ending.
  14155. */
  14156. onAnimationEnd: Nullable<() => void>;
  14157. /**
  14158. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14159. */
  14160. blendMode: number;
  14161. /**
  14162. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14163. * to override the particles.
  14164. */
  14165. forceDepthWrite: boolean;
  14166. /**
  14167. * You can use gravity if you want to give an orientation to your particles.
  14168. */
  14169. gravity: Vector3;
  14170. /**
  14171. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14172. */
  14173. direction1: Vector3;
  14174. /**
  14175. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14176. */
  14177. direction2: Vector3;
  14178. /**
  14179. * 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.
  14180. */
  14181. minEmitBox: Vector3;
  14182. /**
  14183. * 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.
  14184. */
  14185. maxEmitBox: Vector3;
  14186. /**
  14187. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14188. */
  14189. color1: Color4;
  14190. /**
  14191. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14192. */
  14193. color2: Color4;
  14194. /**
  14195. * Color the particle will have at the end of its lifetime.
  14196. */
  14197. colorDead: Color4;
  14198. /**
  14199. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel.
  14200. */
  14201. textureMask: Color4;
  14202. /**
  14203. * The particle emitter type defines the emitter used by the particle system.
  14204. * It can be for example box, sphere, or cone...
  14205. */
  14206. particleEmitterType: IParticleEmitterType;
  14207. /**
  14208. * This function can be defined to specify initial direction for every new particle.
  14209. * It by default use the emitterType defined function.
  14210. */
  14211. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  14212. /**
  14213. * This function can be defined to specify initial position for every new particle.
  14214. * It by default use the emitterType defined function.
  14215. */
  14216. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  14217. /**
  14218. * If using a spritesheet (isAnimationSheetEnabled), defines if the sprite animation should loop between startSpriteCellID and endSpriteCellID or not.
  14219. */
  14220. spriteCellLoop: boolean;
  14221. /**
  14222. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the speed of the sprite loop.
  14223. */
  14224. spriteCellChangeSpeed: number;
  14225. /**
  14226. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the first sprite cell to display.
  14227. */
  14228. startSpriteCellID: number;
  14229. /**
  14230. * If using a spritesheet (isAnimationSheetEnabled) and spriteCellLoop defines the last sprite cell to display.
  14231. */
  14232. endSpriteCellID: number;
  14233. /**
  14234. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use.
  14235. */
  14236. spriteCellWidth: number;
  14237. /**
  14238. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use.
  14239. */
  14240. spriteCellHeight: number;
  14241. /**
  14242. * An event triggered when the system is disposed.
  14243. */
  14244. onDisposeObservable: Observable<ParticleSystem>;
  14245. private _onDisposeObserver;
  14246. /**
  14247. * Sets a callback that will be triggered when the system is disposed.
  14248. */
  14249. onDispose: () => void;
  14250. /**
  14251. * Gets wether an animation sprite sheet is enabled or not on the particle system.
  14252. */
  14253. readonly isAnimationSheetEnabled: Boolean;
  14254. private _particles;
  14255. private _epsilon;
  14256. private _capacity;
  14257. private _scene;
  14258. private _stockParticles;
  14259. private _newPartsExcess;
  14260. private _vertexData;
  14261. private _vertexBuffer;
  14262. private _vertexBuffers;
  14263. private _indexBuffer;
  14264. private _effect;
  14265. private _customEffect;
  14266. private _cachedDefines;
  14267. private _scaledColorStep;
  14268. private _colorDiff;
  14269. private _scaledDirection;
  14270. private _scaledGravity;
  14271. private _currentRenderId;
  14272. private _alive;
  14273. private _started;
  14274. private _stopped;
  14275. private _actualFrame;
  14276. private _scaledUpdateSpeed;
  14277. private _vertexBufferSize;
  14278. private _isAnimationSheetEnabled;
  14279. /**
  14280. * Instantiates a particle system.
  14281. * 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.
  14282. * @param name The name of the particle system
  14283. * @param capacity The max number of particles alive at the same time
  14284. * @param scene The scene the particle system belongs to
  14285. * @param customEffect a custom effect used to change the way particles are rendered by default
  14286. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  14287. * @param epsilon Offset used to render the particles
  14288. */
  14289. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  14290. private _createIndexBuffer();
  14291. /**
  14292. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  14293. * Its lifetime will start back at 0.
  14294. * @param particle The particle to recycle
  14295. */
  14296. recycleParticle(particle: Particle): void;
  14297. /**
  14298. * Gets the maximum number of particles active at the same time.
  14299. * @returns The max number of active particles.
  14300. */
  14301. getCapacity(): number;
  14302. /**
  14303. * Gets Wether there are still active particles in the system.
  14304. * @returns True if it is alive, otherwise false.
  14305. */
  14306. isAlive(): boolean;
  14307. /**
  14308. * Gets Wether the system has been started.
  14309. * @returns True if it has been started, otherwise false.
  14310. */
  14311. isStarted(): boolean;
  14312. /**
  14313. * Starts the particle system and begins to emit.
  14314. */
  14315. start(): void;
  14316. /**
  14317. * Stops the particle system.
  14318. */
  14319. stop(): void;
  14320. /**
  14321. * @ignore (for internal use only)
  14322. */
  14323. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14324. /**
  14325. * @ignore (for internal use only)
  14326. */
  14327. _appendParticleVertexWithAnimation(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  14328. private _update(newParticles);
  14329. private _getEffect();
  14330. /**
  14331. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  14332. */
  14333. animate(): void;
  14334. private _appendParticleVertexes;
  14335. private _appenedParticleVertexesWithSheet(offset, particle);
  14336. private _appenedParticleVertexesNoSheet(offset, particle);
  14337. /**
  14338. * Rebuilds the particle system.
  14339. */
  14340. rebuild(): void;
  14341. /**
  14342. * Renders the particle system in its current state.
  14343. * @returns the current number of particles.
  14344. */
  14345. render(): number;
  14346. /**
  14347. * Disposes the particle system and free the associated resources.
  14348. */
  14349. dispose(): void;
  14350. /**
  14351. * Creates a Sphere Emitter for the particle system. (emits along the sphere radius)
  14352. * @param radius The radius of the sphere to emit from
  14353. * @returns the emitter
  14354. */
  14355. createSphereEmitter(radius?: number): SphereParticleEmitter;
  14356. /**
  14357. * Creates a Directed Sphere Emitter for the particle system. (emits between direction1 and direction2)
  14358. * @param radius The radius of the sphere to emit from
  14359. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14360. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14361. * @returns the emitter
  14362. */
  14363. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14364. /**
  14365. * Creates a Cone Emitter for the particle system. (emits from the cone to the particle position)
  14366. * @param radius The radius of the cone to emit from
  14367. * @param angle The base angle of the cone
  14368. * @returns the emitter
  14369. */
  14370. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14371. /**
  14372. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14373. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14374. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14375. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14376. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14377. * @returns the emitter
  14378. */
  14379. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14380. /**
  14381. * Clones the particle system.
  14382. * @param name The name of the cloned object
  14383. * @param newEmitter The new emitter to use
  14384. * @returns the cloned particle system
  14385. */
  14386. clone(name: string, newEmitter: any): ParticleSystem;
  14387. /**
  14388. * Serializes the particle system to a JSON object.
  14389. * @returns the JSON object
  14390. */
  14391. serialize(): any;
  14392. /**
  14393. * Parses a JSON object to create a particle system.
  14394. * @param parsedParticleSystem The JSON object to parse
  14395. * @param scene The scene to create the particle system in
  14396. * @param rootUrl The root url to use to load external dependencies like texture
  14397. * @returns the Parsed particle system
  14398. */
  14399. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string): ParticleSystem;
  14400. }
  14401. }
  14402. declare module BABYLON {
  14403. /**
  14404. * Represents one particle of a solid particle system.
  14405. * @see SolidParticleSystem
  14406. */
  14407. class SolidParticle {
  14408. /**
  14409. * particle global index
  14410. */
  14411. idx: number;
  14412. /**
  14413. * The color of the particle
  14414. */
  14415. color: Nullable<Color4>;
  14416. /**
  14417. * The world space position of the particle.
  14418. */
  14419. position: Vector3;
  14420. /**
  14421. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  14422. */
  14423. rotation: Vector3;
  14424. /**
  14425. * The world space rotation quaternion of the particle.
  14426. */
  14427. rotationQuaternion: Nullable<Quaternion>;
  14428. /**
  14429. * The scaling of the particle.
  14430. */
  14431. scaling: Vector3;
  14432. /**
  14433. * The uvs of the particle.
  14434. */
  14435. uvs: Vector4;
  14436. /**
  14437. * The current speed of the particle.
  14438. */
  14439. velocity: Vector3;
  14440. /**
  14441. * The pivot point in the particle local space.
  14442. */
  14443. pivot: Vector3;
  14444. /**
  14445. * Is the particle active or not ?
  14446. */
  14447. alive: boolean;
  14448. /**
  14449. * Is the particle visible or not ?
  14450. */
  14451. isVisible: boolean;
  14452. /**
  14453. * Index of this particle in the global "positions" array (Internal use)
  14454. */
  14455. _pos: number;
  14456. /**
  14457. * Index of this particle in the global "indices" array (Internal use)
  14458. */
  14459. _ind: number;
  14460. /**
  14461. * ModelShape of this particle (Internal use)
  14462. */
  14463. _model: ModelShape;
  14464. /**
  14465. * ModelShape id of this particle
  14466. */
  14467. shapeId: number;
  14468. /**
  14469. * Index of the particle in its shape id (Internal use)
  14470. */
  14471. idxInShape: number;
  14472. /**
  14473. * Reference to the shape model BoundingInfo object (Internal use)
  14474. */
  14475. _modelBoundingInfo: BoundingInfo;
  14476. /**
  14477. * Particle BoundingInfo object (Internal use)
  14478. */
  14479. _boundingInfo: BoundingInfo;
  14480. /**
  14481. * Reference to the SPS what the particle belongs to (Internal use)
  14482. */
  14483. _sps: SolidParticleSystem;
  14484. /**
  14485. * Still set as invisible in order to skip useless computations (Internal use)
  14486. */
  14487. _stillInvisible: boolean;
  14488. /**
  14489. * Creates a Solid Particle object.
  14490. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  14491. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  14492. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  14493. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  14494. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  14495. * @param shapeId (integer) is the model shape identifier in the SPS.
  14496. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  14497. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  14498. */
  14499. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  14500. /**
  14501. * Legacy support, changed scale to scaling
  14502. */
  14503. /**
  14504. * Legacy support, changed scale to scaling
  14505. */
  14506. scale: Vector3;
  14507. /**
  14508. * Legacy support, changed quaternion to rotationQuaternion
  14509. */
  14510. /**
  14511. * Legacy support, changed quaternion to rotationQuaternion
  14512. */
  14513. quaternion: Nullable<Quaternion>;
  14514. /**
  14515. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  14516. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  14517. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  14518. * @returns true if it intersects
  14519. */
  14520. intersectsMesh(target: Mesh | SolidParticle): boolean;
  14521. }
  14522. /**
  14523. * Represents the shape of the model used by one particle of a solid particle system.
  14524. * SPS internal tool, don't use it manually.
  14525. * @see SolidParticleSystem
  14526. */
  14527. class ModelShape {
  14528. /**
  14529. * The shape id.
  14530. */
  14531. shapeID: number;
  14532. /**
  14533. * flat array of model positions (internal use)
  14534. */
  14535. _shape: Vector3[];
  14536. /**
  14537. * flat array of model UVs (internal use)
  14538. */
  14539. _shapeUV: number[];
  14540. /**
  14541. * length of the shape in the model indices array (internal use)
  14542. */
  14543. _indicesLength: number;
  14544. /**
  14545. * Custom position function (internal use)
  14546. */
  14547. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  14548. /**
  14549. * Custom vertex function (internal use)
  14550. */
  14551. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  14552. /**
  14553. * 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.
  14554. * SPS internal tool, don't use it manually.
  14555. * @ignore
  14556. */
  14557. 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>);
  14558. }
  14559. /**
  14560. * Represents a Depth Sorted Particle in the solid particle system.
  14561. * @see SolidParticleSystem
  14562. */
  14563. class DepthSortedParticle {
  14564. /**
  14565. * Index of the particle in the "indices" array
  14566. */
  14567. ind: number;
  14568. /**
  14569. * Length of the particle shape in the "indices" array
  14570. */
  14571. indicesLength: number;
  14572. /**
  14573. * Squared distance from the particle to the camera
  14574. */
  14575. sqDistance: number;
  14576. }
  14577. }
  14578. declare module BABYLON {
  14579. /**
  14580. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  14581. *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.
  14582. * The SPS is also a particle system. It provides some methods to manage the particles.
  14583. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  14584. *
  14585. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  14586. */
  14587. class SolidParticleSystem implements IDisposable {
  14588. /**
  14589. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  14590. * Example : var p = SPS.particles[i];
  14591. */
  14592. particles: SolidParticle[];
  14593. /**
  14594. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  14595. */
  14596. nbParticles: number;
  14597. /**
  14598. * If the particles must ever face the camera (default false). Useful for planar particles.
  14599. */
  14600. billboard: boolean;
  14601. /**
  14602. * Recompute normals when adding a shape
  14603. */
  14604. recomputeNormals: boolean;
  14605. /**
  14606. * This a counter ofr your own usage. It's not set by any SPS functions.
  14607. */
  14608. counter: number;
  14609. /**
  14610. * The SPS name. This name is also given to the underlying mesh.
  14611. */
  14612. name: string;
  14613. /**
  14614. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  14615. */
  14616. mesh: Mesh;
  14617. /**
  14618. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  14619. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  14620. */
  14621. vars: any;
  14622. /**
  14623. * This array is populated when the SPS is set as 'pickable'.
  14624. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  14625. * Each element of this array is an object `{idx: int, faceId: int}`.
  14626. * `idx` is the picked particle index in the `SPS.particles` array
  14627. * `faceId` is the picked face index counted within this particle.
  14628. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  14629. */
  14630. pickedParticles: {
  14631. idx: number;
  14632. faceId: number;
  14633. }[];
  14634. /**
  14635. * This array is populated when `enableDepthSort` is set to true.
  14636. * Each element of this array is an instance of the class DepthSortedParticle.
  14637. */
  14638. depthSortedParticles: DepthSortedParticle[];
  14639. /**
  14640. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  14641. */
  14642. _bSphereOnly: boolean;
  14643. /**
  14644. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  14645. */
  14646. _bSphereRadiusFactor: number;
  14647. private _scene;
  14648. private _positions;
  14649. private _indices;
  14650. private _normals;
  14651. private _colors;
  14652. private _uvs;
  14653. private _indices32;
  14654. private _positions32;
  14655. private _normals32;
  14656. private _fixedNormal32;
  14657. private _colors32;
  14658. private _uvs32;
  14659. private _index;
  14660. private _updatable;
  14661. private _pickable;
  14662. private _isVisibilityBoxLocked;
  14663. private _alwaysVisible;
  14664. private _depthSort;
  14665. private _shapeCounter;
  14666. private _copy;
  14667. private _shape;
  14668. private _shapeUV;
  14669. private _color;
  14670. private _computeParticleColor;
  14671. private _computeParticleTexture;
  14672. private _computeParticleRotation;
  14673. private _computeParticleVertex;
  14674. private _computeBoundingBox;
  14675. private _depthSortParticles;
  14676. private _cam_axisZ;
  14677. private _cam_axisY;
  14678. private _cam_axisX;
  14679. private _axisZ;
  14680. private _camera;
  14681. private _particle;
  14682. private _camDir;
  14683. private _camInvertedPosition;
  14684. private _rotMatrix;
  14685. private _invertMatrix;
  14686. private _rotated;
  14687. private _quaternion;
  14688. private _vertex;
  14689. private _normal;
  14690. private _yaw;
  14691. private _pitch;
  14692. private _roll;
  14693. private _halfroll;
  14694. private _halfpitch;
  14695. private _halfyaw;
  14696. private _sinRoll;
  14697. private _cosRoll;
  14698. private _sinPitch;
  14699. private _cosPitch;
  14700. private _sinYaw;
  14701. private _cosYaw;
  14702. private _mustUnrotateFixedNormals;
  14703. private _minimum;
  14704. private _maximum;
  14705. private _minBbox;
  14706. private _maxBbox;
  14707. private _particlesIntersect;
  14708. private _depthSortFunction;
  14709. private _needs32Bits;
  14710. /**
  14711. * Creates a SPS (Solid Particle System) object.
  14712. * @param name (String) is the SPS name, this will be the underlying mesh name.
  14713. * @param scene (Scene) is the scene in which the SPS is added.
  14714. * @param updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  14715. * @param isPickable (optional boolean, default false) : if the solid particles must be pickable.
  14716. * @param enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  14717. * @param particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  14718. * @param boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  14719. * @param bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  14720. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  14721. */
  14722. constructor(name: string, scene: Scene, options?: {
  14723. updatable?: boolean;
  14724. isPickable?: boolean;
  14725. enableDepthSort?: boolean;
  14726. particleIntersection?: boolean;
  14727. boundingSphereOnly?: boolean;
  14728. bSphereRadiusFactor?: number;
  14729. });
  14730. /**
  14731. * Builds the SPS underlying mesh. Returns a standard Mesh.
  14732. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  14733. * @returns the created mesh
  14734. */
  14735. buildMesh(): Mesh;
  14736. /**
  14737. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  14738. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  14739. * Thus the particles generated from `digest()` have their property `position` set yet.
  14740. * @param mesh ( Mesh ) is the mesh to be digested
  14741. * @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
  14742. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  14743. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  14744. * @returns the current SPS
  14745. */
  14746. digest(mesh: Mesh, options?: {
  14747. facetNb?: number;
  14748. number?: number;
  14749. delta?: number;
  14750. }): SolidParticleSystem;
  14751. private _unrotateFixedNormals();
  14752. private _resetCopy();
  14753. private _meshBuilder(p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options);
  14754. private _posToShape(positions);
  14755. private _uvsToShapeUV(uvs);
  14756. private _addParticle(idx, idxpos, idxind, model, shapeId, idxInShape, bInfo?);
  14757. /**
  14758. * Adds some particles to the SPS from the model shape. Returns the shape id.
  14759. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  14760. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  14761. * @param nb (positive integer) the number of particles to be created from this model
  14762. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  14763. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  14764. * @returns the number of shapes in the system
  14765. */
  14766. addShape(mesh: Mesh, nb: number, options?: {
  14767. positionFunction?: any;
  14768. vertexFunction?: any;
  14769. }): number;
  14770. private _rebuildParticle(particle);
  14771. /**
  14772. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  14773. * @returns the SPS.
  14774. */
  14775. rebuildMesh(): SolidParticleSystem;
  14776. /**
  14777. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  14778. * This method calls `updateParticle()` for each particle of the SPS.
  14779. * For an animated SPS, it is usually called within the render loop.
  14780. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  14781. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  14782. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  14783. * @returns the SPS.
  14784. */
  14785. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  14786. private _quaternionRotationYPR();
  14787. private _quaternionToRotationMatrix();
  14788. /**
  14789. * Disposes the SPS.
  14790. */
  14791. dispose(): void;
  14792. /**
  14793. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  14794. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14795. * @returns the SPS.
  14796. */
  14797. refreshVisibleSize(): SolidParticleSystem;
  14798. /**
  14799. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  14800. * @param size the size (float) of the visibility box
  14801. * note : this doesn't lock the SPS mesh bounding box.
  14802. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14803. */
  14804. setVisibilityBox(size: number): void;
  14805. /**
  14806. * Gets whether the SPS as always visible or not
  14807. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14808. */
  14809. /**
  14810. * Sets the SPS as always visible or not
  14811. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14812. */
  14813. isAlwaysVisible: boolean;
  14814. /**
  14815. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  14816. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14817. */
  14818. /**
  14819. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  14820. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  14821. */
  14822. isVisibilityBoxLocked: boolean;
  14823. /**
  14824. * Gets if `setParticles()` computes the particle rotations or not.
  14825. * Default value : true. The SPS is faster when it's set to false.
  14826. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  14827. */
  14828. /**
  14829. * Tells to `setParticles()` to compute the particle rotations or not.
  14830. * Default value : true. The SPS is faster when it's set to false.
  14831. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  14832. */
  14833. computeParticleRotation: boolean;
  14834. /**
  14835. * Gets if `setParticles()` computes the particle colors or not.
  14836. * Default value : true. The SPS is faster when it's set to false.
  14837. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  14838. */
  14839. /**
  14840. * Tells to `setParticles()` to compute the particle colors or not.
  14841. * Default value : true. The SPS is faster when it's set to false.
  14842. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  14843. */
  14844. computeParticleColor: boolean;
  14845. /**
  14846. * Gets if `setParticles()` computes the particle textures or not.
  14847. * Default value : true. The SPS is faster when it's set to false.
  14848. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  14849. */
  14850. computeParticleTexture: boolean;
  14851. /**
  14852. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  14853. * Default value : false. The SPS is faster when it's set to false.
  14854. * Note : the particle custom vertex positions aren't stored values.
  14855. */
  14856. /**
  14857. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  14858. * Default value : false. The SPS is faster when it's set to false.
  14859. * Note : the particle custom vertex positions aren't stored values.
  14860. */
  14861. computeParticleVertex: boolean;
  14862. /**
  14863. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  14864. */
  14865. /**
  14866. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  14867. */
  14868. computeBoundingBox: boolean;
  14869. /**
  14870. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  14871. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  14872. * Default : `true`
  14873. */
  14874. /**
  14875. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  14876. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  14877. * Default : `true`
  14878. */
  14879. depthSortParticles: boolean;
  14880. /**
  14881. * This function does nothing. It may be overwritten to set all the particle first values.
  14882. * The SPS doesn't call this function, you may have to call it by your own.
  14883. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  14884. */
  14885. initParticles(): void;
  14886. /**
  14887. * This function does nothing. It may be overwritten to recycle a particle.
  14888. * The SPS doesn't call this function, you may have to call it by your own.
  14889. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  14890. * @param particle The particle to recycle
  14891. * @returns the recycled particle
  14892. */
  14893. recycleParticle(particle: SolidParticle): SolidParticle;
  14894. /**
  14895. * Updates a particle : this function should be overwritten by the user.
  14896. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  14897. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  14898. * @example : just set a particle position or velocity and recycle conditions
  14899. * @param particle The particle to update
  14900. * @returns the updated particle
  14901. */
  14902. updateParticle(particle: SolidParticle): SolidParticle;
  14903. /**
  14904. * Updates a vertex of a particle : it can be overwritten by the user.
  14905. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  14906. * @param particle the current particle
  14907. * @param vertex the current index of the current particle
  14908. * @param pt the index of the current vertex in the particle shape
  14909. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  14910. * @example : just set a vertex particle position
  14911. * @returns the updated vertex
  14912. */
  14913. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  14914. /**
  14915. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  14916. * This does nothing and may be overwritten by the user.
  14917. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14918. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14919. * @param update the boolean update value actually passed to setParticles()
  14920. */
  14921. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  14922. /**
  14923. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  14924. * This will be passed three parameters.
  14925. * This does nothing and may be overwritten by the user.
  14926. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14927. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  14928. * @param update the boolean update value actually passed to setParticles()
  14929. */
  14930. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  14931. }
  14932. }
  14933. declare module BABYLON {
  14934. /**
  14935. * Particle emitter emitting particles from the inside of a sphere.
  14936. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14937. */
  14938. class SphereParticleEmitter implements IParticleEmitterType {
  14939. /**
  14940. * The radius of the emission sphere.
  14941. */
  14942. radius: number;
  14943. /**
  14944. * How much to randomize the particle direction [0-1].
  14945. */
  14946. directionRandomizer: number;
  14947. /**
  14948. * Creates a new instance of @see SphereParticleEmitter
  14949. * @param radius the radius of the emission sphere
  14950. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14951. */
  14952. constructor(
  14953. /**
  14954. * The radius of the emission sphere.
  14955. */
  14956. radius: number,
  14957. /**
  14958. * How much to randomize the particle direction [0-1].
  14959. */
  14960. directionRandomizer?: number);
  14961. /**
  14962. * Called by the particle System when the direction is computed for the created particle.
  14963. * @param emitPower is the power of the particle (speed)
  14964. * @param worldMatrix is the world matrix of the particle system
  14965. * @param directionToUpdate is the direction vector to update with the result
  14966. * @param particle is the particle we are computed the direction for
  14967. */
  14968. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14969. /**
  14970. * Called by the particle System when the position is computed for the created particle.
  14971. * @param worldMatrix is the world matrix of the particle system
  14972. * @param positionToUpdate is the position vector to update with the result
  14973. * @param particle is the particle we are computed the position for
  14974. */
  14975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  14976. }
  14977. /**
  14978. * Particle emitter emitting particles from the inside of a sphere.
  14979. * It emits the particles randomly between two vectors.
  14980. */
  14981. class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14982. /**
  14983. * The min limit of the emission direction.
  14984. */
  14985. direction1: Vector3;
  14986. /**
  14987. * The max limit of the emission direction.
  14988. */
  14989. direction2: Vector3;
  14990. /**
  14991. * Creates a new instance of @see SphereDirectedParticleEmitter
  14992. * @param radius the radius of the emission sphere
  14993. * @param direction1 the min limit of the emission direction
  14994. * @param direction2 the max limit of the emission direction
  14995. */
  14996. constructor(radius: number,
  14997. /**
  14998. * The min limit of the emission direction.
  14999. */
  15000. direction1: Vector3,
  15001. /**
  15002. * The max limit of the emission direction.
  15003. */
  15004. direction2: Vector3);
  15005. /**
  15006. * Called by the particle System when the direction is computed for the created particle.
  15007. * @param emitPower is the power of the particle (speed)
  15008. * @param worldMatrix is the world matrix of the particle system
  15009. * @param directionToUpdate is the direction vector to update with the result
  15010. * @param particle is the particle we are computed the direction for
  15011. */
  15012. startDirectionFunction(emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15013. }
  15014. }
  15015. declare module BABYLON {
  15016. interface PhysicsImpostorJoint {
  15017. mainImpostor: PhysicsImpostor;
  15018. connectedImpostor: PhysicsImpostor;
  15019. joint: PhysicsJoint;
  15020. }
  15021. class PhysicsEngine {
  15022. private _physicsPlugin;
  15023. gravity: Vector3;
  15024. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  15025. setGravity(gravity: Vector3): void;
  15026. /**
  15027. * Set the time step of the physics engine.
  15028. * default is 1/60.
  15029. * To slow it down, enter 1/600 for example.
  15030. * To speed it up, 1/30
  15031. * @param {number} newTimeStep the new timestep to apply to this world.
  15032. */
  15033. setTimeStep(newTimeStep?: number): void;
  15034. /**
  15035. * Get the time step of the physics engine.
  15036. */
  15037. getTimeStep(): number;
  15038. dispose(): void;
  15039. getPhysicsPluginName(): string;
  15040. static Epsilon: number;
  15041. private _impostors;
  15042. private _joints;
  15043. /**
  15044. * Adding a new impostor for the impostor tracking.
  15045. * This will be done by the impostor itself.
  15046. * @param {PhysicsImpostor} impostor the impostor to add
  15047. */
  15048. addImpostor(impostor: PhysicsImpostor): void;
  15049. /**
  15050. * Remove an impostor from the engine.
  15051. * This impostor and its mesh will not longer be updated by the physics engine.
  15052. * @param {PhysicsImpostor} impostor the impostor to remove
  15053. */
  15054. removeImpostor(impostor: PhysicsImpostor): void;
  15055. /**
  15056. * Add a joint to the physics engine
  15057. * @param {PhysicsImpostor} mainImpostor the main impostor to which the joint is added.
  15058. * @param {PhysicsImpostor} connectedImpostor the impostor that is connected to the main impostor using this joint
  15059. * @param {PhysicsJoint} the joint that will connect both impostors.
  15060. */
  15061. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  15062. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  15063. /**
  15064. * Called by the scene. no need to call it.
  15065. */
  15066. _step(delta: number): void;
  15067. getPhysicsPlugin(): IPhysicsEnginePlugin;
  15068. getImpostors(): Array<PhysicsImpostor>;
  15069. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  15070. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  15071. }
  15072. interface IPhysicsEnginePlugin {
  15073. world: any;
  15074. name: string;
  15075. setGravity(gravity: Vector3): void;
  15076. setTimeStep(timeStep: number): void;
  15077. getTimeStep(): number;
  15078. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  15079. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  15080. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  15081. generatePhysicsBody(impostor: PhysicsImpostor): void;
  15082. removePhysicsBody(impostor: PhysicsImpostor): void;
  15083. generateJoint(joint: PhysicsImpostorJoint): void;
  15084. removeJoint(joint: PhysicsImpostorJoint): void;
  15085. isSupported(): boolean;
  15086. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  15087. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  15088. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  15089. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  15090. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  15091. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  15092. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  15093. getBodyMass(impostor: PhysicsImpostor): number;
  15094. getBodyFriction(impostor: PhysicsImpostor): number;
  15095. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  15096. getBodyRestitution(impostor: PhysicsImpostor): number;
  15097. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  15098. sleepBody(impostor: PhysicsImpostor): void;
  15099. wakeUpBody(impostor: PhysicsImpostor): void;
  15100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  15101. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  15102. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  15103. getRadius(impostor: PhysicsImpostor): number;
  15104. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  15105. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  15106. dispose(): void;
  15107. }
  15108. }
  15109. declare module BABYLON {
  15110. class PhysicsHelper {
  15111. private _scene;
  15112. private _physicsEngine;
  15113. constructor(scene: Scene);
  15114. /**
  15115. * @param {Vector3} origin the origin of the explosion
  15116. * @param {number} radius the explosion radius
  15117. * @param {number} strength the explosion strength
  15118. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  15119. */
  15120. applyRadialExplosionImpulse(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  15121. /**
  15122. * @param {Vector3} origin the origin of the explosion
  15123. * @param {number} radius the explosion radius
  15124. * @param {number} strength the explosion strength
  15125. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  15126. */
  15127. applyRadialExplosionForce(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  15128. /**
  15129. * @param {Vector3} origin the origin of the explosion
  15130. * @param {number} radius the explosion radius
  15131. * @param {number} strength the explosion strength
  15132. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear. Defaults to Constant
  15133. */
  15134. gravitationalField(origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  15135. /**
  15136. * @param {Vector3} origin the origin of the updraft
  15137. * @param {number} radius the radius of the updraft
  15138. * @param {number} strength the strength of the updraft
  15139. * @param {number} height the height of the updraft
  15140. * @param {PhysicsUpdraftMode} updraftMode possible options: Center & Perpendicular. Defaults to Center
  15141. */
  15142. updraft(origin: Vector3, radius: number, strength: number, height: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  15143. /**
  15144. * @param {Vector3} origin the of the vortex
  15145. * @param {number} radius the radius of the vortex
  15146. * @param {number} strength the strength of the vortex
  15147. * @param {number} height the height of the vortex
  15148. */
  15149. vortex(origin: Vector3, radius: number, strength: number, height: number): Nullable<PhysicsVortexEvent>;
  15150. }
  15151. /***** Radial explosion *****/
  15152. class PhysicsRadialExplosionEvent {
  15153. private _scene;
  15154. private _sphere;
  15155. private _sphereOptions;
  15156. private _rays;
  15157. private _dataFetched;
  15158. constructor(scene: Scene);
  15159. /**
  15160. * Returns the data related to the radial explosion event (sphere & rays).
  15161. * @returns {PhysicsRadialExplosionEventData}
  15162. */
  15163. getData(): PhysicsRadialExplosionEventData;
  15164. /**
  15165. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  15166. * @param impostor
  15167. * @param {Vector3} origin the origin of the explosion
  15168. * @param {number} radius the explosion radius
  15169. * @param {number} strength the explosion strength
  15170. * @param {PhysicsRadialImpulseFalloff} falloff possible options: Constant & Linear
  15171. * @returns {Nullable<PhysicsForceAndContactPoint>}
  15172. */
  15173. getImpostorForceAndContactPoint(impostor: PhysicsImpostor, origin: Vector3, radius: number, strength: number, falloff: PhysicsRadialImpulseFalloff): Nullable<PhysicsForceAndContactPoint>;
  15174. /**
  15175. * Disposes the sphere.
  15176. * @param {bolean} force
  15177. */
  15178. dispose(force?: boolean): void;
  15179. /*** Helpers ***/
  15180. private _prepareSphere();
  15181. private _intersectsWithSphere(impostor, origin, radius);
  15182. }
  15183. /***** Gravitational Field *****/
  15184. class PhysicsGravitationalFieldEvent {
  15185. private _physicsHelper;
  15186. private _scene;
  15187. private _origin;
  15188. private _radius;
  15189. private _strength;
  15190. private _falloff;
  15191. private _tickCallback;
  15192. private _sphere;
  15193. private _dataFetched;
  15194. constructor(physicsHelper: PhysicsHelper, scene: Scene, origin: Vector3, radius: number, strength: number, falloff?: PhysicsRadialImpulseFalloff);
  15195. /**
  15196. * Returns the data related to the gravitational field event (sphere).
  15197. * @returns {PhysicsGravitationalFieldEventData}
  15198. */
  15199. getData(): PhysicsGravitationalFieldEventData;
  15200. /**
  15201. * Enables the gravitational field.
  15202. */
  15203. enable(): void;
  15204. /**
  15205. * Disables the gravitational field.
  15206. */
  15207. disable(): void;
  15208. /**
  15209. * Disposes the sphere.
  15210. * @param {bolean} force
  15211. */
  15212. dispose(force?: boolean): void;
  15213. private _tick();
  15214. }
  15215. /***** Updraft *****/
  15216. class PhysicsUpdraftEvent {
  15217. private _scene;
  15218. private _origin;
  15219. private _radius;
  15220. private _strength;
  15221. private _height;
  15222. private _updraftMode;
  15223. private _physicsEngine;
  15224. private _originTop;
  15225. private _originDirection;
  15226. private _tickCallback;
  15227. private _cylinder;
  15228. private _cylinderPosition;
  15229. private _dataFetched;
  15230. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number, _updraftMode: PhysicsUpdraftMode);
  15231. /**
  15232. * Returns the data related to the updraft event (cylinder).
  15233. * @returns {PhysicsUpdraftEventData}
  15234. */
  15235. getData(): PhysicsUpdraftEventData;
  15236. /**
  15237. * Enables the updraft.
  15238. */
  15239. enable(): void;
  15240. /**
  15241. * Disables the cortex.
  15242. */
  15243. disable(): void;
  15244. /**
  15245. * Disposes the sphere.
  15246. * @param {bolean} force
  15247. */
  15248. dispose(force?: boolean): void;
  15249. private getImpostorForceAndContactPoint(impostor);
  15250. private _tick();
  15251. /*** Helpers ***/
  15252. private _prepareCylinder();
  15253. private _intersectsWithCylinder(impostor);
  15254. }
  15255. /***** Vortex *****/
  15256. class PhysicsVortexEvent {
  15257. private _scene;
  15258. private _origin;
  15259. private _radius;
  15260. private _strength;
  15261. private _height;
  15262. private _physicsEngine;
  15263. private _originTop;
  15264. private _centripetalForceThreshold;
  15265. private _updraftMultiplier;
  15266. private _tickCallback;
  15267. private _cylinder;
  15268. private _cylinderPosition;
  15269. private _dataFetched;
  15270. constructor(_scene: Scene, _origin: Vector3, _radius: number, _strength: number, _height: number);
  15271. /**
  15272. * Returns the data related to the vortex event (cylinder).
  15273. * @returns {PhysicsVortexEventData}
  15274. */
  15275. getData(): PhysicsVortexEventData;
  15276. /**
  15277. * Enables the vortex.
  15278. */
  15279. enable(): void;
  15280. /**
  15281. * Disables the cortex.
  15282. */
  15283. disable(): void;
  15284. /**
  15285. * Disposes the sphere.
  15286. * @param {bolean} force
  15287. */
  15288. dispose(force?: boolean): void;
  15289. private getImpostorForceAndContactPoint(impostor);
  15290. private _tick();
  15291. /*** Helpers ***/
  15292. private _prepareCylinder();
  15293. private _intersectsWithCylinder(impostor);
  15294. }
  15295. /***** Enums *****/
  15296. /**
  15297. * The strenght of the force in correspondence to the distance of the affected object
  15298. */
  15299. enum PhysicsRadialImpulseFalloff {
  15300. Constant = 0,
  15301. Linear = 1,
  15302. }
  15303. /**
  15304. * The strenght of the force in correspondence to the distance of the affected object
  15305. */
  15306. enum PhysicsUpdraftMode {
  15307. Center = 0,
  15308. Perpendicular = 1,
  15309. }
  15310. /***** Data interfaces *****/
  15311. interface PhysicsForceAndContactPoint {
  15312. force: Vector3;
  15313. contactPoint: Vector3;
  15314. }
  15315. interface PhysicsRadialExplosionEventData {
  15316. sphere: Mesh;
  15317. rays: Array<Ray>;
  15318. }
  15319. interface PhysicsGravitationalFieldEventData {
  15320. sphere: Mesh;
  15321. }
  15322. interface PhysicsUpdraftEventData {
  15323. cylinder: Mesh;
  15324. }
  15325. interface PhysicsVortexEventData {
  15326. cylinder: Mesh;
  15327. }
  15328. }
  15329. declare module BABYLON {
  15330. interface PhysicsImpostorParameters {
  15331. mass: number;
  15332. friction?: number;
  15333. restitution?: number;
  15334. nativeOptions?: any;
  15335. ignoreParent?: boolean;
  15336. disableBidirectionalTransformation?: boolean;
  15337. }
  15338. interface IPhysicsEnabledObject {
  15339. position: Vector3;
  15340. rotationQuaternion: Nullable<Quaternion>;
  15341. scaling: Vector3;
  15342. rotation?: Vector3;
  15343. parent?: any;
  15344. getBoundingInfo(): BoundingInfo;
  15345. computeWorldMatrix(force: boolean): Matrix;
  15346. getWorldMatrix?(): Matrix;
  15347. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  15348. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  15349. getIndices?(): Nullable<IndicesArray>;
  15350. getScene?(): Scene;
  15351. getAbsolutePosition(): Vector3;
  15352. getAbsolutePivotPoint(): Vector3;
  15353. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15354. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15355. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15356. getClassName(): string;
  15357. }
  15358. class PhysicsImpostor {
  15359. object: IPhysicsEnabledObject;
  15360. type: number;
  15361. private _options;
  15362. private _scene;
  15363. static DEFAULT_OBJECT_SIZE: Vector3;
  15364. static IDENTITY_QUATERNION: Quaternion;
  15365. private _physicsEngine;
  15366. private _physicsBody;
  15367. private _bodyUpdateRequired;
  15368. private _onBeforePhysicsStepCallbacks;
  15369. private _onAfterPhysicsStepCallbacks;
  15370. private _onPhysicsCollideCallbacks;
  15371. private _deltaPosition;
  15372. private _deltaRotation;
  15373. private _deltaRotationConjugated;
  15374. private _parent;
  15375. private _isDisposed;
  15376. private static _tmpVecs;
  15377. private static _tmpQuat;
  15378. readonly isDisposed: boolean;
  15379. mass: number;
  15380. friction: number;
  15381. restitution: number;
  15382. uniqueId: number;
  15383. private _joints;
  15384. constructor(object: IPhysicsEnabledObject, type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  15385. /**
  15386. * This function will completly initialize this impostor.
  15387. * It will create a new body - but only if this mesh has no parent.
  15388. * If it has, this impostor will not be used other than to define the impostor
  15389. * of the child mesh.
  15390. */
  15391. _init(): void;
  15392. private _getPhysicsParent();
  15393. /**
  15394. * Should a new body be generated.
  15395. */
  15396. isBodyInitRequired(): boolean;
  15397. setScalingUpdated(updated: boolean): void;
  15398. /**
  15399. * Force a regeneration of this or the parent's impostor's body.
  15400. * Use under cautious - This will remove all joints already implemented.
  15401. */
  15402. forceUpdate(): void;
  15403. /**
  15404. * Gets the body that holds this impostor. Either its own, or its parent.
  15405. */
  15406. /**
  15407. * Set the physics body. Used mainly by the physics engine/plugin
  15408. */
  15409. physicsBody: any;
  15410. parent: Nullable<PhysicsImpostor>;
  15411. resetUpdateFlags(): void;
  15412. getObjectExtendSize(): Vector3;
  15413. getObjectCenter(): Vector3;
  15414. /**
  15415. * Get a specific parametes from the options parameter.
  15416. */
  15417. getParam(paramName: string): any;
  15418. /**
  15419. * Sets a specific parameter in the options given to the physics plugin
  15420. */
  15421. setParam(paramName: string, value: number): void;
  15422. /**
  15423. * Specifically change the body's mass option. Won't recreate the physics body object
  15424. */
  15425. setMass(mass: number): void;
  15426. getLinearVelocity(): Nullable<Vector3>;
  15427. setLinearVelocity(velocity: Nullable<Vector3>): void;
  15428. getAngularVelocity(): Nullable<Vector3>;
  15429. setAngularVelocity(velocity: Nullable<Vector3>): void;
  15430. /**
  15431. * Execute a function with the physics plugin native code.
  15432. * Provide a function the will have two variables - the world object and the physics body object.
  15433. */
  15434. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  15435. /**
  15436. * Register a function that will be executed before the physics world is stepping forward.
  15437. */
  15438. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15439. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15440. /**
  15441. * Register a function that will be executed after the physics step
  15442. */
  15443. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15444. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  15445. /**
  15446. * register a function that will be executed when this impostor collides against a different body.
  15447. */
  15448. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  15449. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  15450. private _tmpQuat;
  15451. private _tmpQuat2;
  15452. getParentsRotation(): Quaternion;
  15453. /**
  15454. * this function is executed by the physics engine.
  15455. */
  15456. beforeStep: () => void;
  15457. /**
  15458. * this function is executed by the physics engine.
  15459. */
  15460. afterStep: () => void;
  15461. /**
  15462. * Legacy collision detection event support
  15463. */
  15464. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  15465. onCollide: (e: {
  15466. body: any;
  15467. }) => void;
  15468. /**
  15469. * Apply a force
  15470. */
  15471. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  15472. /**
  15473. * Apply an impulse
  15474. */
  15475. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  15476. /**
  15477. * A help function to create a joint.
  15478. */
  15479. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  15480. /**
  15481. * Add a joint to this impostor with a different impostor.
  15482. */
  15483. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  15484. /**
  15485. * Will keep this body still, in a sleep mode.
  15486. */
  15487. sleep(): PhysicsImpostor;
  15488. /**
  15489. * Wake the body up.
  15490. */
  15491. wakeUp(): PhysicsImpostor;
  15492. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  15493. dispose(): void;
  15494. setDeltaPosition(position: Vector3): void;
  15495. setDeltaRotation(rotation: Quaternion): void;
  15496. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  15497. getRadius(): number;
  15498. /**
  15499. * Sync a bone with this impostor
  15500. * @param bone The bone to sync to the impostor.
  15501. * @param boneMesh The mesh that the bone is influencing.
  15502. * @param jointPivot The pivot of the joint / bone in local space.
  15503. * @param distToJoint Optional distance from the impostor to the joint.
  15504. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  15505. */
  15506. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  15507. /**
  15508. * Sync impostor to a bone
  15509. * @param bone The bone that the impostor will be synced to.
  15510. * @param boneMesh The mesh that the bone is influencing.
  15511. * @param jointPivot The pivot of the joint / bone in local space.
  15512. * @param distToJoint Optional distance from the impostor to the joint.
  15513. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  15514. * @param boneAxis Optional vector3 axis the bone is aligned with
  15515. */
  15516. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  15517. static NoImpostor: number;
  15518. static SphereImpostor: number;
  15519. static BoxImpostor: number;
  15520. static PlaneImpostor: number;
  15521. static MeshImpostor: number;
  15522. static CylinderImpostor: number;
  15523. static ParticleImpostor: number;
  15524. static HeightmapImpostor: number;
  15525. }
  15526. }
  15527. declare module BABYLON {
  15528. interface PhysicsJointData {
  15529. mainPivot?: Vector3;
  15530. connectedPivot?: Vector3;
  15531. mainAxis?: Vector3;
  15532. connectedAxis?: Vector3;
  15533. collision?: boolean;
  15534. nativeParams?: any;
  15535. }
  15536. /**
  15537. * This is a holder class for the physics joint created by the physics plugin.
  15538. * It holds a set of functions to control the underlying joint.
  15539. */
  15540. class PhysicsJoint {
  15541. type: number;
  15542. jointData: PhysicsJointData;
  15543. private _physicsJoint;
  15544. protected _physicsPlugin: IPhysicsEnginePlugin;
  15545. constructor(type: number, jointData: PhysicsJointData);
  15546. physicsJoint: any;
  15547. physicsPlugin: IPhysicsEnginePlugin;
  15548. /**
  15549. * Execute a function that is physics-plugin specific.
  15550. * @param {Function} func the function that will be executed.
  15551. * It accepts two parameters: the physics world and the physics joint.
  15552. */
  15553. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  15554. static DistanceJoint: number;
  15555. static HingeJoint: number;
  15556. static BallAndSocketJoint: number;
  15557. static WheelJoint: number;
  15558. static SliderJoint: number;
  15559. static PrismaticJoint: number;
  15560. static UniversalJoint: number;
  15561. static Hinge2Joint: number;
  15562. static PointToPointJoint: number;
  15563. static SpringJoint: number;
  15564. static LockJoint: number;
  15565. }
  15566. /**
  15567. * A class representing a physics distance joint.
  15568. */
  15569. class DistanceJoint extends PhysicsJoint {
  15570. constructor(jointData: DistanceJointData);
  15571. /**
  15572. * Update the predefined distance.
  15573. */
  15574. updateDistance(maxDistance: number, minDistance?: number): void;
  15575. }
  15576. class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  15577. constructor(type: number, jointData: PhysicsJointData);
  15578. /**
  15579. * Set the motor values.
  15580. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15581. * @param {number} force the force to apply
  15582. * @param {number} maxForce max force for this motor.
  15583. */
  15584. setMotor(force?: number, maxForce?: number): void;
  15585. /**
  15586. * Set the motor's limits.
  15587. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15588. */
  15589. setLimit(upperLimit: number, lowerLimit?: number): void;
  15590. }
  15591. /**
  15592. * This class represents a single hinge physics joint
  15593. */
  15594. class HingeJoint extends MotorEnabledJoint {
  15595. constructor(jointData: PhysicsJointData);
  15596. /**
  15597. * Set the motor values.
  15598. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15599. * @param {number} force the force to apply
  15600. * @param {number} maxForce max force for this motor.
  15601. */
  15602. setMotor(force?: number, maxForce?: number): void;
  15603. /**
  15604. * Set the motor's limits.
  15605. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15606. */
  15607. setLimit(upperLimit: number, lowerLimit?: number): void;
  15608. }
  15609. /**
  15610. * This class represents a dual hinge physics joint (same as wheel joint)
  15611. */
  15612. class Hinge2Joint extends MotorEnabledJoint {
  15613. constructor(jointData: PhysicsJointData);
  15614. /**
  15615. * Set the motor values.
  15616. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15617. * @param {number} force the force to apply
  15618. * @param {number} maxForce max force for this motor.
  15619. * @param {motorIndex} the motor's index, 0 or 1.
  15620. */
  15621. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  15622. /**
  15623. * Set the motor limits.
  15624. * Attention, this function is plugin specific. Engines won't react 100% the same.
  15625. * @param {number} upperLimit the upper limit
  15626. * @param {number} lowerLimit lower limit
  15627. * @param {motorIndex} the motor's index, 0 or 1.
  15628. */
  15629. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  15630. }
  15631. interface IMotorEnabledJoint {
  15632. physicsJoint: any;
  15633. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  15634. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  15635. }
  15636. interface DistanceJointData extends PhysicsJointData {
  15637. maxDistance: number;
  15638. }
  15639. interface SpringJointData extends PhysicsJointData {
  15640. length: number;
  15641. stiffness: number;
  15642. damping: number;
  15643. }
  15644. }
  15645. declare module BABYLON {
  15646. class ReflectionProbe {
  15647. name: string;
  15648. private _scene;
  15649. private _renderTargetTexture;
  15650. private _projectionMatrix;
  15651. private _viewMatrix;
  15652. private _target;
  15653. private _add;
  15654. private _attachedMesh;
  15655. invertYAxis: boolean;
  15656. position: Vector3;
  15657. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  15658. samples: number;
  15659. refreshRate: number;
  15660. getScene(): Scene;
  15661. readonly cubeTexture: RenderTargetTexture;
  15662. readonly renderList: Nullable<AbstractMesh[]>;
  15663. attachToMesh(mesh: AbstractMesh): void;
  15664. /**
  15665. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  15666. *
  15667. * @param renderingGroupId The rendering group id corresponding to its index
  15668. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  15669. */
  15670. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  15671. dispose(): void;
  15672. }
  15673. }
  15674. declare module BABYLON {
  15675. class AnaglyphPostProcess extends PostProcess {
  15676. private _passedProcess;
  15677. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  15678. }
  15679. }
  15680. declare module BABYLON {
  15681. class BlackAndWhitePostProcess extends PostProcess {
  15682. degree: number;
  15683. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  15684. }
  15685. }
  15686. declare module BABYLON {
  15687. class BlurPostProcess extends PostProcess {
  15688. direction: Vector2;
  15689. protected _kernel: number;
  15690. protected _idealKernel: number;
  15691. protected _packedFloat: boolean;
  15692. /**
  15693. * Gets the length in pixels of the blur sample region
  15694. */
  15695. /**
  15696. * Sets the length in pixels of the blur sample region
  15697. */
  15698. kernel: number;
  15699. /**
  15700. * Gets wether or not the blur is unpacking/repacking floats
  15701. */
  15702. /**
  15703. * Sets wether or not the blur needs to unpack/repack floats
  15704. */
  15705. packedFloat: boolean;
  15706. constructor(name: string, direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  15707. protected _updateParameters(): void;
  15708. /**
  15709. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15710. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15711. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15712. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15713. * The gaps between physical kernels are compensated for in the weighting of the samples
  15714. * @param idealKernel Ideal blur kernel.
  15715. * @return Nearest best kernel.
  15716. */
  15717. protected _nearestBestKernel(idealKernel: number): number;
  15718. /**
  15719. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  15720. * @param x The point on the Gaussian distribution to sample.
  15721. * @return the value of the Gaussian function at x.
  15722. */
  15723. protected _gaussianWeight(x: number): number;
  15724. /**
  15725. * Generates a string that can be used as a floating point number in GLSL.
  15726. * @param x Value to print.
  15727. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  15728. * @return GLSL float string.
  15729. */
  15730. protected _glslFloat(x: number, decimalFigures?: number): string;
  15731. }
  15732. }
  15733. declare module BABYLON {
  15734. class ColorCorrectionPostProcess extends PostProcess {
  15735. private _colorTableTexture;
  15736. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  15737. }
  15738. }
  15739. declare module BABYLON {
  15740. class ConvolutionPostProcess extends PostProcess {
  15741. kernel: number[];
  15742. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  15743. static EdgeDetect0Kernel: number[];
  15744. static EdgeDetect1Kernel: number[];
  15745. static EdgeDetect2Kernel: number[];
  15746. static SharpenKernel: number[];
  15747. static EmbossKernel: number[];
  15748. static GaussianKernel: number[];
  15749. }
  15750. }
  15751. declare module BABYLON {
  15752. class DisplayPassPostProcess extends PostProcess {
  15753. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  15754. }
  15755. }
  15756. declare module BABYLON {
  15757. class FilterPostProcess extends PostProcess {
  15758. kernelMatrix: Matrix;
  15759. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  15760. }
  15761. }
  15762. declare module BABYLON {
  15763. class FxaaPostProcess extends PostProcess {
  15764. texelWidth: number;
  15765. texelHeight: number;
  15766. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  15767. }
  15768. }
  15769. declare module BABYLON {
  15770. class HighlightsPostProcess extends PostProcess {
  15771. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  15772. }
  15773. }
  15774. declare module BABYLON {
  15775. class ImageProcessingPostProcess extends PostProcess {
  15776. /**
  15777. * Default configuration related to image processing available in the PBR Material.
  15778. */
  15779. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  15780. /**
  15781. * Gets the image processing configuration used either in this material.
  15782. */
  15783. /**
  15784. * Sets the Default image processing configuration used either in the this material.
  15785. *
  15786. * If sets to null, the scene one is in use.
  15787. */
  15788. imageProcessingConfiguration: ImageProcessingConfiguration;
  15789. /**
  15790. * Keep track of the image processing observer to allow dispose and replace.
  15791. */
  15792. private _imageProcessingObserver;
  15793. /**
  15794. * Attaches a new image processing configuration to the PBR Material.
  15795. * @param configuration
  15796. */
  15797. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  15798. /**
  15799. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  15800. */
  15801. /**
  15802. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  15803. */
  15804. colorCurves: Nullable<ColorCurves>;
  15805. /**
  15806. * Gets wether the color curves effect is enabled.
  15807. */
  15808. /**
  15809. * Sets wether the color curves effect is enabled.
  15810. */
  15811. colorCurvesEnabled: boolean;
  15812. /**
  15813. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  15814. */
  15815. /**
  15816. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  15817. */
  15818. colorGradingTexture: Nullable<BaseTexture>;
  15819. /**
  15820. * Gets wether the color grading effect is enabled.
  15821. */
  15822. /**
  15823. * Gets wether the color grading effect is enabled.
  15824. */
  15825. colorGradingEnabled: boolean;
  15826. /**
  15827. * Gets exposure used in the effect.
  15828. */
  15829. /**
  15830. * Sets exposure used in the effect.
  15831. */
  15832. exposure: number;
  15833. /**
  15834. * Gets wether tonemapping is enabled or not.
  15835. */
  15836. /**
  15837. * Sets wether tonemapping is enabled or not
  15838. */
  15839. toneMappingEnabled: boolean;
  15840. /**
  15841. * Gets contrast used in the effect.
  15842. */
  15843. /**
  15844. * Sets contrast used in the effect.
  15845. */
  15846. contrast: number;
  15847. /**
  15848. * Gets Vignette stretch size.
  15849. */
  15850. /**
  15851. * Sets Vignette stretch size.
  15852. */
  15853. vignetteStretch: number;
  15854. /**
  15855. * Gets Vignette centre X Offset.
  15856. */
  15857. /**
  15858. * Sets Vignette centre X Offset.
  15859. */
  15860. vignetteCentreX: number;
  15861. /**
  15862. * Gets Vignette centre Y Offset.
  15863. */
  15864. /**
  15865. * Sets Vignette centre Y Offset.
  15866. */
  15867. vignetteCentreY: number;
  15868. /**
  15869. * Gets Vignette weight or intensity of the vignette effect.
  15870. */
  15871. /**
  15872. * Sets Vignette weight or intensity of the vignette effect.
  15873. */
  15874. vignetteWeight: number;
  15875. /**
  15876. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  15877. * if vignetteEnabled is set to true.
  15878. */
  15879. /**
  15880. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  15881. * if vignetteEnabled is set to true.
  15882. */
  15883. vignetteColor: Color4;
  15884. /**
  15885. * Gets Camera field of view used by the Vignette effect.
  15886. */
  15887. /**
  15888. * Sets Camera field of view used by the Vignette effect.
  15889. */
  15890. vignetteCameraFov: number;
  15891. /**
  15892. * Gets the vignette blend mode allowing different kind of effect.
  15893. */
  15894. /**
  15895. * Sets the vignette blend mode allowing different kind of effect.
  15896. */
  15897. vignetteBlendMode: number;
  15898. /**
  15899. * Gets wether the vignette effect is enabled.
  15900. */
  15901. /**
  15902. * Sets wether the vignette effect is enabled.
  15903. */
  15904. vignetteEnabled: boolean;
  15905. private _fromLinearSpace;
  15906. /**
  15907. * Gets wether the input of the processing is in Gamma or Linear Space.
  15908. */
  15909. /**
  15910. * Sets wether the input of the processing is in Gamma or Linear Space.
  15911. */
  15912. fromLinearSpace: boolean;
  15913. /**
  15914. * Defines cache preventing GC.
  15915. */
  15916. private _defines;
  15917. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  15918. getClassName(): string;
  15919. protected _updateParameters(): void;
  15920. dispose(camera?: Camera): void;
  15921. }
  15922. }
  15923. declare module BABYLON {
  15924. class PassPostProcess extends PostProcess {
  15925. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  15926. }
  15927. }
  15928. declare module BABYLON {
  15929. type PostProcessOptions = {
  15930. width: number;
  15931. height: number;
  15932. };
  15933. class PostProcess {
  15934. name: string;
  15935. width: number;
  15936. height: number;
  15937. renderTargetSamplingMode: number;
  15938. clearColor: Color4;
  15939. autoClear: boolean;
  15940. alphaMode: number;
  15941. alphaConstants: Color4;
  15942. animations: Animation[];
  15943. enablePixelPerfectMode: boolean;
  15944. scaleMode: number;
  15945. alwaysForcePOT: boolean;
  15946. samples: number;
  15947. adaptScaleToCurrentViewport: boolean;
  15948. private _camera;
  15949. private _scene;
  15950. private _engine;
  15951. private _options;
  15952. private _reusable;
  15953. private _textureType;
  15954. _textures: SmartArray<InternalTexture>;
  15955. _currentRenderTextureInd: number;
  15956. private _effect;
  15957. private _samplers;
  15958. private _fragmentUrl;
  15959. private _vertexUrl;
  15960. private _parameters;
  15961. private _scaleRatio;
  15962. protected _indexParameters: any;
  15963. private _shareOutputWithPostProcess;
  15964. private _texelSize;
  15965. private _forcedOutputTexture;
  15966. /**
  15967. * An event triggered when the postprocess is activated.
  15968. * @type {BABYLON.Observable}
  15969. */
  15970. onActivateObservable: Observable<Camera>;
  15971. private _onActivateObserver;
  15972. onActivate: Nullable<(camera: Camera) => void>;
  15973. /**
  15974. * An event triggered when the postprocess changes its size.
  15975. * @type {BABYLON.Observable}
  15976. */
  15977. onSizeChangedObservable: Observable<PostProcess>;
  15978. private _onSizeChangedObserver;
  15979. onSizeChanged: (postProcess: PostProcess) => void;
  15980. /**
  15981. * An event triggered when the postprocess applies its effect.
  15982. * @type {BABYLON.Observable}
  15983. */
  15984. onApplyObservable: Observable<Effect>;
  15985. private _onApplyObserver;
  15986. onApply: (effect: Effect) => void;
  15987. /**
  15988. * An event triggered before rendering the postprocess
  15989. * @type {BABYLON.Observable}
  15990. */
  15991. onBeforeRenderObservable: Observable<Effect>;
  15992. private _onBeforeRenderObserver;
  15993. onBeforeRender: (effect: Effect) => void;
  15994. /**
  15995. * An event triggered after rendering the postprocess
  15996. * @type {BABYLON.Observable}
  15997. */
  15998. onAfterRenderObservable: Observable<Effect>;
  15999. private _onAfterRenderObserver;
  16000. onAfterRender: (efect: Effect) => void;
  16001. outputTexture: InternalTexture;
  16002. getCamera(): Camera;
  16003. readonly texelSize: Vector2;
  16004. constructor(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);
  16005. getEngine(): Engine;
  16006. getEffect(): Effect;
  16007. shareOutputWith(postProcess: PostProcess): PostProcess;
  16008. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  16009. isReusable(): boolean;
  16010. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  16011. markTextureDirty(): void;
  16012. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): void;
  16013. readonly isSupported: boolean;
  16014. readonly aspectRatio: number;
  16015. /**
  16016. * Get a value indicating if the post-process is ready to be used
  16017. * @returns true if the post-process is ready (shader is compiled)
  16018. */
  16019. isReady(): boolean;
  16020. apply(): Nullable<Effect>;
  16021. private _disposeTextures();
  16022. dispose(camera?: Camera): void;
  16023. }
  16024. }
  16025. declare module BABYLON {
  16026. class PostProcessManager {
  16027. private _scene;
  16028. private _indexBuffer;
  16029. private _vertexBuffers;
  16030. constructor(scene: Scene);
  16031. private _prepareBuffers();
  16032. private _buildIndexBuffer();
  16033. _rebuild(): void;
  16034. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16035. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean): void;
  16036. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: PostProcess[], forceFullscreenViewport?: boolean): void;
  16037. dispose(): void;
  16038. }
  16039. }
  16040. declare module BABYLON {
  16041. class RefractionPostProcess extends PostProcess {
  16042. color: Color3;
  16043. depth: number;
  16044. colorLevel: number;
  16045. private _refRexture;
  16046. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  16047. dispose(camera: Camera): void;
  16048. }
  16049. }
  16050. declare module BABYLON {
  16051. class StereoscopicInterlacePostProcess extends PostProcess {
  16052. private _stepSize;
  16053. private _passedProcess;
  16054. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  16055. }
  16056. }
  16057. declare module BABYLON {
  16058. enum TonemappingOperator {
  16059. Hable = 0,
  16060. Reinhard = 1,
  16061. HejiDawson = 2,
  16062. Photographic = 3,
  16063. }
  16064. class TonemapPostProcess extends PostProcess {
  16065. private _operator;
  16066. exposureAdjustment: number;
  16067. constructor(name: string, _operator: TonemappingOperator, exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  16068. }
  16069. }
  16070. declare module BABYLON {
  16071. class VolumetricLightScatteringPostProcess extends PostProcess {
  16072. private _volumetricLightScatteringPass;
  16073. private _volumetricLightScatteringRTT;
  16074. private _viewPort;
  16075. private _screenCoordinates;
  16076. private _cachedDefines;
  16077. /**
  16078. * If not undefined, the mesh position is computed from the attached node position
  16079. * @type {{position: Vector3}}
  16080. */
  16081. attachedNode: {
  16082. position: Vector3;
  16083. };
  16084. /**
  16085. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  16086. * @type {Vector3}
  16087. */
  16088. customMeshPosition: Vector3;
  16089. /**
  16090. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  16091. * @type {boolean}
  16092. */
  16093. useCustomMeshPosition: boolean;
  16094. /**
  16095. * If the post-process should inverse the light scattering direction
  16096. * @type {boolean}
  16097. */
  16098. invert: boolean;
  16099. /**
  16100. * The internal mesh used by the post-process
  16101. * @type {boolean}
  16102. */
  16103. mesh: Mesh;
  16104. useDiffuseColor: boolean;
  16105. /**
  16106. * Array containing the excluded meshes not rendered in the internal pass
  16107. */
  16108. excludedMeshes: AbstractMesh[];
  16109. /**
  16110. * Controls the overall intensity of the post-process
  16111. * @type {number}
  16112. */
  16113. exposure: number;
  16114. /**
  16115. * Dissipates each sample's contribution in range [0, 1]
  16116. * @type {number}
  16117. */
  16118. decay: number;
  16119. /**
  16120. * Controls the overall intensity of each sample
  16121. * @type {number}
  16122. */
  16123. weight: number;
  16124. /**
  16125. * Controls the density of each sample
  16126. * @type {number}
  16127. */
  16128. density: number;
  16129. /**
  16130. * @constructor
  16131. * @param {string} name - The post-process name
  16132. * @param {any} 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)
  16133. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  16134. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  16135. * @param {number} samples - The post-process quality, default 100
  16136. * @param {number} samplingMode - The post-process filtering mode
  16137. * @param {BABYLON.Engine} engine - The babylon engine
  16138. * @param {boolean} reusable - If the post-process is reusable
  16139. * @param {BABYLON.Scene} scene - The constructor needs a scene reference to initialize internal components. If "camera" is null (RenderPipelineà, "scene" must be provided
  16140. */
  16141. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  16142. getClassName(): string;
  16143. private _isReady(subMesh, useInstances);
  16144. /**
  16145. * Sets the new light position for light scattering effect
  16146. * @param {BABYLON.Vector3} The new custom light position
  16147. */
  16148. setCustomMeshPosition(position: Vector3): void;
  16149. /**
  16150. * Returns the light position for light scattering effect
  16151. * @return {BABYLON.Vector3} The custom light position
  16152. */
  16153. getCustomMeshPosition(): Vector3;
  16154. /**
  16155. * Disposes the internal assets and detaches the post-process from the camera
  16156. */
  16157. dispose(camera: Camera): void;
  16158. /**
  16159. * Returns the render target texture used by the post-process
  16160. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  16161. */
  16162. getPass(): RenderTargetTexture;
  16163. private _meshExcluded(mesh);
  16164. private _createPass(scene, ratio);
  16165. private _updateMeshScreenCoordinates(scene);
  16166. /**
  16167. * Creates a default mesh for the Volumeric Light Scattering post-process
  16168. * @param {string} The mesh name
  16169. * @param {BABYLON.Scene} The scene where to create the mesh
  16170. * @return {BABYLON.Mesh} the default mesh
  16171. */
  16172. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  16173. }
  16174. }
  16175. declare module BABYLON {
  16176. class VRDistortionCorrectionPostProcess extends PostProcess {
  16177. aspectRatio: number;
  16178. private _isRightEye;
  16179. private _distortionFactors;
  16180. private _postProcessScaleFactor;
  16181. private _lensCenterOffset;
  16182. private _scaleIn;
  16183. private _scaleFactor;
  16184. private _lensCenter;
  16185. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  16186. }
  16187. }
  16188. declare module BABYLON {
  16189. class BoundingBoxRenderer {
  16190. frontColor: Color3;
  16191. backColor: Color3;
  16192. showBackLines: boolean;
  16193. renderList: SmartArray<BoundingBox>;
  16194. private _scene;
  16195. private _colorShader;
  16196. private _vertexBuffers;
  16197. private _indexBuffer;
  16198. constructor(scene: Scene);
  16199. private _prepareRessources();
  16200. private _createIndexBuffer();
  16201. _rebuild(): void;
  16202. reset(): void;
  16203. render(): void;
  16204. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  16205. dispose(): void;
  16206. }
  16207. }
  16208. declare module BABYLON {
  16209. class DepthRenderer {
  16210. private _scene;
  16211. private _depthMap;
  16212. private _effect;
  16213. private _cachedDefines;
  16214. constructor(scene: Scene, type?: number);
  16215. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16216. getDepthMap(): RenderTargetTexture;
  16217. dispose(): void;
  16218. }
  16219. }
  16220. declare module BABYLON {
  16221. class EdgesRenderer {
  16222. edgesWidthScalerForOrthographic: number;
  16223. edgesWidthScalerForPerspective: number;
  16224. private _source;
  16225. private _linesPositions;
  16226. private _linesNormals;
  16227. private _linesIndices;
  16228. private _epsilon;
  16229. private _indicesCount;
  16230. private _lineShader;
  16231. private _ib;
  16232. private _buffers;
  16233. private _checkVerticesInsteadOfIndices;
  16234. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  16235. private _prepareRessources();
  16236. _rebuild(): void;
  16237. dispose(): void;
  16238. private _processEdgeForAdjacencies(pa, pb, p0, p1, p2);
  16239. private _processEdgeForAdjacenciesWithVertices(pa, pb, p0, p1, p2);
  16240. private _checkEdge(faceIndex, edge, faceNormals, p0, p1);
  16241. _generateEdgesLines(): void;
  16242. render(): void;
  16243. }
  16244. }
  16245. declare module BABYLON {
  16246. class GeometryBufferRenderer {
  16247. private _scene;
  16248. private _multiRenderTarget;
  16249. private _effect;
  16250. private _ratio;
  16251. private _cachedDefines;
  16252. private _enablePosition;
  16253. renderList: Mesh[];
  16254. readonly isSupported: boolean;
  16255. enablePosition: boolean;
  16256. constructor(scene: Scene, ratio?: number);
  16257. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16258. getGBuffer(): MultiRenderTarget;
  16259. samples: number;
  16260. dispose(): void;
  16261. private _createRenderTargets();
  16262. }
  16263. }
  16264. declare module BABYLON {
  16265. class OutlineRenderer {
  16266. private _scene;
  16267. private _effect;
  16268. private _cachedDefines;
  16269. zOffset: number;
  16270. constructor(scene: Scene);
  16271. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  16272. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  16273. }
  16274. }
  16275. declare module BABYLON {
  16276. class RenderingGroup {
  16277. index: number;
  16278. private _scene;
  16279. private _opaqueSubMeshes;
  16280. private _transparentSubMeshes;
  16281. private _alphaTestSubMeshes;
  16282. private _depthOnlySubMeshes;
  16283. private _particleSystems;
  16284. private _spriteManagers;
  16285. private _opaqueSortCompareFn;
  16286. private _alphaTestSortCompareFn;
  16287. private _transparentSortCompareFn;
  16288. private _renderOpaque;
  16289. private _renderAlphaTest;
  16290. private _renderTransparent;
  16291. private _edgesRenderers;
  16292. onBeforeTransparentRendering: () => void;
  16293. /**
  16294. * Set the opaque sort comparison function.
  16295. * If null the sub meshes will be render in the order they were created
  16296. */
  16297. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16298. /**
  16299. * Set the alpha test sort comparison function.
  16300. * If null the sub meshes will be render in the order they were created
  16301. */
  16302. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16303. /**
  16304. * Set the transparent sort comparison function.
  16305. * If null the sub meshes will be render in the order they were created
  16306. */
  16307. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  16308. /**
  16309. * Creates a new rendering group.
  16310. * @param index The rendering group index
  16311. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  16312. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  16313. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  16314. */
  16315. 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>);
  16316. /**
  16317. * Render all the sub meshes contained in the group.
  16318. * @param customRenderFunction Used to override the default render behaviour of the group.
  16319. * @returns true if rendered some submeshes.
  16320. */
  16321. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  16322. /**
  16323. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  16324. * @param subMeshes The submeshes to render
  16325. */
  16326. private renderOpaqueSorted(subMeshes);
  16327. /**
  16328. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  16329. * @param subMeshes The submeshes to render
  16330. */
  16331. private renderAlphaTestSorted(subMeshes);
  16332. /**
  16333. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  16334. * @param subMeshes The submeshes to render
  16335. */
  16336. private renderTransparentSorted(subMeshes);
  16337. /**
  16338. * Renders the submeshes in a specified order.
  16339. * @param subMeshes The submeshes to sort before render
  16340. * @param sortCompareFn The comparison function use to sort
  16341. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  16342. * @param transparent Specifies to activate blending if true
  16343. */
  16344. private static renderSorted(subMeshes, sortCompareFn, camera, transparent);
  16345. /**
  16346. * Renders the submeshes in the order they were dispatched (no sort applied).
  16347. * @param subMeshes The submeshes to render
  16348. */
  16349. private static renderUnsorted(subMeshes);
  16350. /**
  16351. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16352. * are rendered back to front if in the same alpha index.
  16353. *
  16354. * @param a The first submesh
  16355. * @param b The second submesh
  16356. * @returns The result of the comparison
  16357. */
  16358. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  16359. /**
  16360. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16361. * are rendered back to front.
  16362. *
  16363. * @param a The first submesh
  16364. * @param b The second submesh
  16365. * @returns The result of the comparison
  16366. */
  16367. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  16368. /**
  16369. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  16370. * are rendered front to back (prevent overdraw).
  16371. *
  16372. * @param a The first submesh
  16373. * @param b The second submesh
  16374. * @returns The result of the comparison
  16375. */
  16376. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  16377. /**
  16378. * Resets the different lists of submeshes to prepare a new frame.
  16379. */
  16380. prepare(): void;
  16381. dispose(): void;
  16382. /**
  16383. * Inserts the submesh in its correct queue depending on its material.
  16384. * @param subMesh The submesh to dispatch
  16385. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16386. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16387. */
  16388. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16389. dispatchSprites(spriteManager: SpriteManager): void;
  16390. dispatchParticles(particleSystem: IParticleSystem): void;
  16391. private _renderParticles(activeMeshes);
  16392. private _renderSprites();
  16393. }
  16394. }
  16395. declare module BABYLON {
  16396. class RenderingManager {
  16397. /**
  16398. * The max id used for rendering groups (not included)
  16399. */
  16400. static MAX_RENDERINGGROUPS: number;
  16401. /**
  16402. * The min id used for rendering groups (included)
  16403. */
  16404. static MIN_RENDERINGGROUPS: number;
  16405. /**
  16406. * Used to globally prevent autoclearing scenes.
  16407. */
  16408. static AUTOCLEAR: boolean;
  16409. private _scene;
  16410. private _renderingGroups;
  16411. private _depthStencilBufferAlreadyCleaned;
  16412. private _autoClearDepthStencil;
  16413. private _customOpaqueSortCompareFn;
  16414. private _customAlphaTestSortCompareFn;
  16415. private _customTransparentSortCompareFn;
  16416. private _renderinGroupInfo;
  16417. constructor(scene: Scene);
  16418. private _clearDepthStencilBuffer(depth?, stencil?);
  16419. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  16420. reset(): void;
  16421. dispose(): void;
  16422. private _prepareRenderingGroup(renderingGroupId);
  16423. dispatchSprites(spriteManager: SpriteManager): void;
  16424. dispatchParticles(particleSystem: IParticleSystem): void;
  16425. /**
  16426. * @param subMesh The submesh to dispatch
  16427. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  16428. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  16429. */
  16430. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  16431. /**
  16432. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  16433. * This allowed control for front to back rendering or reversly depending of the special needs.
  16434. *
  16435. * @param renderingGroupId The rendering group id corresponding to its index
  16436. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  16437. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  16438. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  16439. */
  16440. 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;
  16441. /**
  16442. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  16443. *
  16444. * @param renderingGroupId The rendering group id corresponding to its index
  16445. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  16446. * @param depth Automatically clears depth between groups if true and autoClear is true.
  16447. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  16448. */
  16449. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  16450. }
  16451. }
  16452. declare module BABYLON {
  16453. class Sprite {
  16454. name: string;
  16455. position: Vector3;
  16456. color: Color4;
  16457. width: number;
  16458. height: number;
  16459. angle: number;
  16460. cellIndex: number;
  16461. invertU: number;
  16462. invertV: number;
  16463. disposeWhenFinishedAnimating: boolean;
  16464. animations: Animation[];
  16465. isPickable: boolean;
  16466. actionManager: ActionManager;
  16467. private _animationStarted;
  16468. private _loopAnimation;
  16469. private _fromIndex;
  16470. private _toIndex;
  16471. private _delay;
  16472. private _direction;
  16473. private _manager;
  16474. private _time;
  16475. private _onAnimationEnd;
  16476. size: number;
  16477. constructor(name: string, manager: SpriteManager);
  16478. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  16479. stopAnimation(): void;
  16480. _animate(deltaTime: number): void;
  16481. dispose(): void;
  16482. }
  16483. }
  16484. declare module BABYLON {
  16485. class SpriteManager {
  16486. name: string;
  16487. sprites: Sprite[];
  16488. renderingGroupId: number;
  16489. layerMask: number;
  16490. fogEnabled: boolean;
  16491. isPickable: boolean;
  16492. cellWidth: number;
  16493. cellHeight: number;
  16494. /**
  16495. * An event triggered when the manager is disposed.
  16496. * @type {BABYLON.Observable}
  16497. */
  16498. onDisposeObservable: Observable<SpriteManager>;
  16499. private _onDisposeObserver;
  16500. onDispose: () => void;
  16501. private _capacity;
  16502. private _spriteTexture;
  16503. private _epsilon;
  16504. private _scene;
  16505. private _vertexData;
  16506. private _buffer;
  16507. private _vertexBuffers;
  16508. private _indexBuffer;
  16509. private _effectBase;
  16510. private _effectFog;
  16511. texture: Texture;
  16512. constructor(name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  16513. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  16514. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  16515. render(): void;
  16516. dispose(): void;
  16517. }
  16518. }
  16519. declare module BABYLON {
  16520. class _AlphaState {
  16521. private _isAlphaBlendDirty;
  16522. private _isBlendFunctionParametersDirty;
  16523. private _isBlendEquationParametersDirty;
  16524. private _isBlendConstantsDirty;
  16525. private _alphaBlend;
  16526. private _blendFunctionParameters;
  16527. private _blendEquationParameters;
  16528. private _blendConstants;
  16529. /**
  16530. * Initializes the state.
  16531. */
  16532. constructor();
  16533. readonly isDirty: boolean;
  16534. alphaBlend: boolean;
  16535. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  16536. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  16537. setAlphaEquationParameters(rgb: number, alpha: number): void;
  16538. reset(): void;
  16539. apply(gl: WebGLRenderingContext): void;
  16540. }
  16541. }
  16542. declare module BABYLON {
  16543. class _DepthCullingState {
  16544. private _isDepthTestDirty;
  16545. private _isDepthMaskDirty;
  16546. private _isDepthFuncDirty;
  16547. private _isCullFaceDirty;
  16548. private _isCullDirty;
  16549. private _isZOffsetDirty;
  16550. private _isFrontFaceDirty;
  16551. private _depthTest;
  16552. private _depthMask;
  16553. private _depthFunc;
  16554. private _cull;
  16555. private _cullFace;
  16556. private _zOffset;
  16557. private _frontFace;
  16558. /**
  16559. * Initializes the state.
  16560. */
  16561. constructor();
  16562. readonly isDirty: boolean;
  16563. zOffset: number;
  16564. cullFace: Nullable<number>;
  16565. cull: Nullable<boolean>;
  16566. depthFunc: Nullable<number>;
  16567. depthMask: boolean;
  16568. depthTest: boolean;
  16569. frontFace: Nullable<number>;
  16570. reset(): void;
  16571. apply(gl: WebGLRenderingContext): void;
  16572. }
  16573. }
  16574. declare module BABYLON {
  16575. class _StencilState {
  16576. private _isStencilTestDirty;
  16577. private _isStencilMaskDirty;
  16578. private _isStencilFuncDirty;
  16579. private _isStencilOpDirty;
  16580. private _stencilTest;
  16581. private _stencilMask;
  16582. private _stencilFunc;
  16583. private _stencilFuncRef;
  16584. private _stencilFuncMask;
  16585. private _stencilOpStencilFail;
  16586. private _stencilOpDepthFail;
  16587. private _stencilOpStencilDepthPass;
  16588. readonly isDirty: boolean;
  16589. stencilFunc: number;
  16590. stencilFuncRef: number;
  16591. stencilFuncMask: number;
  16592. stencilOpStencilFail: number;
  16593. stencilOpDepthFail: number;
  16594. stencilOpStencilDepthPass: number;
  16595. stencilMask: number;
  16596. stencilTest: boolean;
  16597. constructor();
  16598. reset(): void;
  16599. apply(gl: WebGLRenderingContext): void;
  16600. }
  16601. }
  16602. declare module BABYLON {
  16603. class AndOrNotEvaluator {
  16604. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  16605. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  16606. private static _SimplifyNegation(booleanString);
  16607. }
  16608. }
  16609. declare module BABYLON {
  16610. /**
  16611. * Defines the list of states available for a task inside a {BABYLON.AssetsManager}
  16612. */
  16613. enum AssetTaskState {
  16614. /**
  16615. * Initialization
  16616. */
  16617. INIT = 0,
  16618. /**
  16619. * Running
  16620. */
  16621. RUNNING = 1,
  16622. /**
  16623. * Done
  16624. */
  16625. DONE = 2,
  16626. /**
  16627. * Error
  16628. */
  16629. ERROR = 3,
  16630. }
  16631. /**
  16632. * Define an abstract asset task used with a {BABYLON.AssetsManager} class to load assets into a scene
  16633. */
  16634. abstract class AbstractAssetTask {
  16635. /**
  16636. * Task name
  16637. */ name: string;
  16638. /**
  16639. * Callback called when the task is successful
  16640. */
  16641. onSuccess: (task: any) => void;
  16642. /**
  16643. * Callback called when the task is successful
  16644. */
  16645. onError: (task: any, message?: string, exception?: any) => void;
  16646. /**
  16647. * Creates a new {BABYLON.AssetsManager}
  16648. * @param name defines the name of the task
  16649. */
  16650. constructor(
  16651. /**
  16652. * Task name
  16653. */ name: string);
  16654. private _isCompleted;
  16655. private _taskState;
  16656. private _errorObject;
  16657. /**
  16658. * Get if the task is completed
  16659. */
  16660. readonly isCompleted: boolean;
  16661. /**
  16662. * Gets the current state of the task
  16663. */
  16664. readonly taskState: AssetTaskState;
  16665. /**
  16666. * Gets the current error object (if task is in error)
  16667. */
  16668. readonly errorObject: {
  16669. message?: string;
  16670. exception?: any;
  16671. };
  16672. /**
  16673. * Internal only
  16674. * @ignore
  16675. */
  16676. _setErrorObject(message?: string, exception?: any): void;
  16677. /**
  16678. * Execute the current task
  16679. * @param scene defines the scene where you want your assets to be loaded
  16680. * @param onSuccess is a callback called when the task is successfully executed
  16681. * @param onError is a callback called if an error occurs
  16682. */
  16683. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  16684. /**
  16685. * Execute the current task
  16686. * @param scene defines the scene where you want your assets to be loaded
  16687. * @param onSuccess is a callback called when the task is successfully executed
  16688. * @param onError is a callback called if an error occurs
  16689. */
  16690. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  16691. private onErrorCallback(onError, message?, exception?);
  16692. private onDoneCallback(onSuccess, onError);
  16693. }
  16694. /**
  16695. * Define the interface used by progress events raised during assets loading
  16696. */
  16697. interface IAssetsProgressEvent {
  16698. /**
  16699. * Defines the number of remaining tasks to process
  16700. */
  16701. remainingCount: number;
  16702. /**
  16703. * Defines the total number of tasks
  16704. */
  16705. totalCount: number;
  16706. /**
  16707. * Defines the task that was just processed
  16708. */
  16709. task: AbstractAssetTask;
  16710. }
  16711. /**
  16712. * Class used to share progress information about assets loading
  16713. */
  16714. class AssetsProgressEvent implements IAssetsProgressEvent {
  16715. /**
  16716. * Defines the number of remaining tasks to process
  16717. */
  16718. remainingCount: number;
  16719. /**
  16720. * Defines the total number of tasks
  16721. */
  16722. totalCount: number;
  16723. /**
  16724. * Defines the task that was just processed
  16725. */
  16726. task: AbstractAssetTask;
  16727. /**
  16728. * Creates a {BABYLON.AssetsProgressEvent}
  16729. * @param remainingCount defines the number of remaining tasks to process
  16730. * @param totalCount defines the total number of tasks
  16731. * @param task defines the task that was just processed
  16732. */
  16733. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  16734. }
  16735. /**
  16736. * Define a task used by {BABYLON.AssetsManager} to load meshes
  16737. */
  16738. class MeshAssetTask extends AbstractAssetTask {
  16739. /**
  16740. * Defines the name of the task
  16741. */
  16742. name: string;
  16743. /**
  16744. * Defines the list of mesh's names you want to load
  16745. */
  16746. meshesNames: any;
  16747. /**
  16748. * Defines the root url to use as a base to load your meshes and associated resources
  16749. */
  16750. rootUrl: string;
  16751. /**
  16752. * Defines the filename of the scene to load from
  16753. */
  16754. sceneFilename: string;
  16755. /**
  16756. * Gets the list of loaded meshes
  16757. */
  16758. loadedMeshes: Array<AbstractMesh>;
  16759. /**
  16760. * Gets the list of loaded particle systems
  16761. */
  16762. loadedParticleSystems: Array<ParticleSystem>;
  16763. /**
  16764. * Gets the list of loaded skeletons
  16765. */
  16766. loadedSkeletons: Array<Skeleton>;
  16767. /**
  16768. * Callback called when the task is successful
  16769. */
  16770. onSuccess: (task: MeshAssetTask) => void;
  16771. /**
  16772. * Callback called when the task is successful
  16773. */
  16774. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  16775. /**
  16776. * Creates a new {BABYLON.MeshAssetTask}
  16777. * @param name defines the name of the task
  16778. * @param meshesNames defines the list of mesh's names you want to load
  16779. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  16780. * @param sceneFilename defines the filename of the scene to load from
  16781. */
  16782. constructor(
  16783. /**
  16784. * Defines the name of the task
  16785. */
  16786. name: string,
  16787. /**
  16788. * Defines the list of mesh's names you want to load
  16789. */
  16790. meshesNames: any,
  16791. /**
  16792. * Defines the root url to use as a base to load your meshes and associated resources
  16793. */
  16794. rootUrl: string,
  16795. /**
  16796. * Defines the filename of the scene to load from
  16797. */
  16798. sceneFilename: string);
  16799. /**
  16800. * Execute the current task
  16801. * @param scene defines the scene where you want your assets to be loaded
  16802. * @param onSuccess is a callback called when the task is successfully executed
  16803. * @param onError is a callback called if an error occurs
  16804. */
  16805. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  16806. }
  16807. /**
  16808. * Define a task used by {BABYLON.AssetsManager} to load text content
  16809. */
  16810. class TextFileAssetTask extends AbstractAssetTask {
  16811. /**
  16812. * Defines the name of the task
  16813. */
  16814. name: string;
  16815. /**
  16816. * Defines the location of the file to load
  16817. */
  16818. url: string;
  16819. /**
  16820. * Gets the loaded text string
  16821. */
  16822. text: string;
  16823. /**
  16824. * Callback called when the task is successful
  16825. */
  16826. onSuccess: (task: TextFileAssetTask) => void;
  16827. /**
  16828. * Callback called when the task is successful
  16829. */
  16830. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  16831. /**
  16832. * Creates a new TextFileAssetTask object
  16833. * @param name defines the name of the task
  16834. * @param url defines the location of the file to load
  16835. */
  16836. constructor(
  16837. /**
  16838. * Defines the name of the task
  16839. */
  16840. name: string,
  16841. /**
  16842. * Defines the location of the file to load
  16843. */
  16844. url: string);
  16845. /**
  16846. * Execute the current task
  16847. * @param scene defines the scene where you want your assets to be loaded
  16848. * @param onSuccess is a callback called when the task is successfully executed
  16849. * @param onError is a callback called if an error occurs
  16850. */
  16851. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  16852. }
  16853. /**
  16854. * Define a task used by {BABYLON.AssetsManager} to load binary data
  16855. */
  16856. class BinaryFileAssetTask extends AbstractAssetTask {
  16857. /**
  16858. * Defines the name of the task
  16859. */
  16860. name: string;
  16861. /**
  16862. * Defines the location of the file to load
  16863. */
  16864. url: string;
  16865. /**
  16866. * Gets the lodaded data (as an array buffer)
  16867. */
  16868. data: ArrayBuffer;
  16869. /**
  16870. * Callback called when the task is successful
  16871. */
  16872. onSuccess: (task: BinaryFileAssetTask) => void;
  16873. /**
  16874. * Callback called when the task is successful
  16875. */
  16876. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  16877. /**
  16878. * Creates a new BinaryFileAssetTask object
  16879. * @param name defines the name of the new task
  16880. * @param url defines the location of the file to load
  16881. */
  16882. constructor(
  16883. /**
  16884. * Defines the name of the task
  16885. */
  16886. name: string,
  16887. /**
  16888. * Defines the location of the file to load
  16889. */
  16890. url: string);
  16891. /**
  16892. * Execute the current task
  16893. * @param scene defines the scene where you want your assets to be loaded
  16894. * @param onSuccess is a callback called when the task is successfully executed
  16895. * @param onError is a callback called if an error occurs
  16896. */
  16897. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  16898. }
  16899. /**
  16900. * Define a task used by {BABYLON.AssetsManager} to load images
  16901. */
  16902. class ImageAssetTask extends AbstractAssetTask {
  16903. /**
  16904. * Defines the name of the task
  16905. */
  16906. name: string;
  16907. /**
  16908. * Defines the location of the image to load
  16909. */
  16910. url: string;
  16911. /**
  16912. * Gets the loaded images
  16913. */
  16914. image: HTMLImageElement;
  16915. /**
  16916. * Callback called when the task is successful
  16917. */
  16918. onSuccess: (task: ImageAssetTask) => void;
  16919. /**
  16920. * Callback called when the task is successful
  16921. */
  16922. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  16923. /**
  16924. * Creates a new ImageAssetTask
  16925. * @param name defines the name of the task
  16926. * @param url defines the location of the image to load
  16927. */
  16928. constructor(
  16929. /**
  16930. * Defines the name of the task
  16931. */
  16932. name: string,
  16933. /**
  16934. * Defines the location of the image to load
  16935. */
  16936. url: string);
  16937. /**
  16938. * Execute the current task
  16939. * @param scene defines the scene where you want your assets to be loaded
  16940. * @param onSuccess is a callback called when the task is successfully executed
  16941. * @param onError is a callback called if an error occurs
  16942. */
  16943. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  16944. }
  16945. /**
  16946. * Defines the interface used by texture loading tasks
  16947. */
  16948. interface ITextureAssetTask<TEX extends BaseTexture> {
  16949. /**
  16950. * Gets the loaded texture
  16951. */
  16952. texture: TEX;
  16953. }
  16954. /**
  16955. * Define a task used by {BABYLON.AssetsManager} to load 2D textures
  16956. */
  16957. class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  16958. /**
  16959. * Defines the name of the task
  16960. */
  16961. name: string;
  16962. /**
  16963. * Defines the location of the file to load
  16964. */
  16965. url: string;
  16966. /**
  16967. * Defines if mipmap should not be generated (default is false)
  16968. */
  16969. noMipmap: boolean | undefined;
  16970. /**
  16971. * Defines if texture must be inverted on Y axis (default is false)
  16972. */
  16973. invertY: boolean | undefined;
  16974. /**
  16975. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  16976. */
  16977. samplingMode: number;
  16978. /**
  16979. * Gets the loaded texture
  16980. */
  16981. texture: Texture;
  16982. /**
  16983. * Callback called when the task is successful
  16984. */
  16985. onSuccess: (task: TextureAssetTask) => void;
  16986. /**
  16987. * Callback called when the task is successful
  16988. */
  16989. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  16990. /**
  16991. * Creates a new TextureAssetTask object
  16992. * @param name defines the name of the task
  16993. * @param url defines the location of the file to load
  16994. * @param noMipmap defines if mipmap should not be generated (default is false)
  16995. * @param invertY defines if texture must be inverted on Y axis (default is false)
  16996. * @param samplingMode defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  16997. */
  16998. constructor(
  16999. /**
  17000. * Defines the name of the task
  17001. */
  17002. name: string,
  17003. /**
  17004. * Defines the location of the file to load
  17005. */
  17006. url: string,
  17007. /**
  17008. * Defines if mipmap should not be generated (default is false)
  17009. */
  17010. noMipmap?: boolean | undefined,
  17011. /**
  17012. * Defines if texture must be inverted on Y axis (default is false)
  17013. */
  17014. invertY?: boolean | undefined,
  17015. /**
  17016. * Defines the sampling mode to use (default is BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  17017. */
  17018. samplingMode?: number);
  17019. /**
  17020. * Execute the current task
  17021. * @param scene defines the scene where you want your assets to be loaded
  17022. * @param onSuccess is a callback called when the task is successfully executed
  17023. * @param onError is a callback called if an error occurs
  17024. */
  17025. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  17026. }
  17027. /**
  17028. * Define a task used by {BABYLON.AssetsManager} to load cube textures
  17029. */
  17030. class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  17031. /**
  17032. * Defines the name of the task
  17033. */
  17034. name: string;
  17035. /**
  17036. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  17037. */
  17038. url: string;
  17039. /**
  17040. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  17041. */
  17042. extensions: string[] | undefined;
  17043. /**
  17044. * Defines if mipmaps should not be generated (default is false)
  17045. */
  17046. noMipmap: boolean | undefined;
  17047. /**
  17048. * Defines the explicit list of files (undefined by default)
  17049. */
  17050. files: string[] | undefined;
  17051. /**
  17052. * Gets the loaded texture
  17053. */
  17054. texture: CubeTexture;
  17055. /**
  17056. * Callback called when the task is successful
  17057. */
  17058. onSuccess: (task: CubeTextureAssetTask) => void;
  17059. /**
  17060. * Callback called when the task is successful
  17061. */
  17062. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  17063. /**
  17064. * Creates a new CubeTextureAssetTask
  17065. * @param name defines the name of the task
  17066. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  17067. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  17068. * @param noMipmap defines if mipmaps should not be generated (default is false)
  17069. * @param files defines the explicit list of files (undefined by default)
  17070. */
  17071. constructor(
  17072. /**
  17073. * Defines the name of the task
  17074. */
  17075. name: string,
  17076. /**
  17077. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  17078. */
  17079. url: string,
  17080. /**
  17081. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  17082. */
  17083. extensions?: string[] | undefined,
  17084. /**
  17085. * Defines if mipmaps should not be generated (default is false)
  17086. */
  17087. noMipmap?: boolean | undefined,
  17088. /**
  17089. * Defines the explicit list of files (undefined by default)
  17090. */
  17091. files?: string[] | undefined);
  17092. /**
  17093. * Execute the current task
  17094. * @param scene defines the scene where you want your assets to be loaded
  17095. * @param onSuccess is a callback called when the task is successfully executed
  17096. * @param onError is a callback called if an error occurs
  17097. */
  17098. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  17099. }
  17100. /**
  17101. * Define a task used by {BABYLON.AssetsManager} to load HDR cube textures
  17102. */
  17103. class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  17104. /**
  17105. * Defines the name of the task
  17106. */
  17107. name: string;
  17108. /**
  17109. * Defines the location of the file to load
  17110. */
  17111. url: string;
  17112. /**
  17113. * 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.
  17114. */
  17115. size: number | undefined;
  17116. /**
  17117. * Defines if mipmaps should not be generated (default is false)
  17118. */
  17119. noMipmap: boolean;
  17120. /**
  17121. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  17122. */
  17123. generateHarmonics: boolean;
  17124. /**
  17125. * 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)
  17126. */
  17127. useInGammaSpace: boolean;
  17128. /**
  17129. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  17130. */
  17131. usePMREMGenerator: boolean;
  17132. /**
  17133. * Gets the loaded texture
  17134. */
  17135. texture: HDRCubeTexture;
  17136. /**
  17137. * Callback called when the task is successful
  17138. */
  17139. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  17140. /**
  17141. * Callback called when the task is successful
  17142. */
  17143. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  17144. /**
  17145. * Creates a new HDRCubeTextureAssetTask object
  17146. * @param name defines the name of the task
  17147. * @param url defines the location of the file to load
  17148. * @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.
  17149. * @param noMipmap defines if mipmaps should not be generated (default is false)
  17150. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  17151. * @param useInGammaSpace 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)
  17152. * @param usePMREMGenerator specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  17153. */
  17154. constructor(
  17155. /**
  17156. * Defines the name of the task
  17157. */
  17158. name: string,
  17159. /**
  17160. * Defines the location of the file to load
  17161. */
  17162. url: string,
  17163. /**
  17164. * 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.
  17165. */
  17166. size?: number | undefined,
  17167. /**
  17168. * Defines if mipmaps should not be generated (default is false)
  17169. */
  17170. noMipmap?: boolean,
  17171. /**
  17172. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  17173. */
  17174. generateHarmonics?: boolean,
  17175. /**
  17176. * 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)
  17177. */
  17178. useInGammaSpace?: boolean,
  17179. /**
  17180. * Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time (default is false)
  17181. */
  17182. usePMREMGenerator?: boolean);
  17183. /**
  17184. * Execute the current task
  17185. * @param scene defines the scene where you want your assets to be loaded
  17186. * @param onSuccess is a callback called when the task is successfully executed
  17187. * @param onError is a callback called if an error occurs
  17188. */
  17189. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  17190. }
  17191. /**
  17192. * This class can be used to easily import assets into a scene
  17193. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  17194. */
  17195. class AssetsManager {
  17196. private _scene;
  17197. private _isLoading;
  17198. protected _tasks: AbstractAssetTask[];
  17199. protected _waitingTasksCount: number;
  17200. protected _totalTasksCount: number;
  17201. /**
  17202. * Callback called when all tasks are processed
  17203. */
  17204. onFinish: (tasks: AbstractAssetTask[]) => void;
  17205. /**
  17206. * Callback called when a task is successful
  17207. */
  17208. onTaskSuccess: (task: AbstractAssetTask) => void;
  17209. /**
  17210. * Callback called when a task had an error
  17211. */
  17212. onTaskError: (task: AbstractAssetTask) => void;
  17213. /**
  17214. * Callback called when a task is done (whatever the result is)
  17215. */
  17216. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  17217. /**
  17218. * Observable called when all tasks are processed
  17219. */
  17220. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  17221. /**
  17222. * Observable called when a task had an error
  17223. */
  17224. onTaskErrorObservable: Observable<AbstractAssetTask>;
  17225. /**
  17226. * Observable called when a task is successful
  17227. */
  17228. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  17229. /**
  17230. * Observable called when a task is done (whatever the result is)
  17231. */
  17232. onProgressObservable: Observable<IAssetsProgressEvent>;
  17233. /**
  17234. * Gets or sets a boolean defining if the {BABYLON.AssetsManager} should use the default loading screen
  17235. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  17236. */
  17237. useDefaultLoadingScreen: boolean;
  17238. /**
  17239. * Creates a new AssetsManager
  17240. * @param scene defines the scene to work on
  17241. */
  17242. constructor(scene: Scene);
  17243. /**
  17244. * Add a {BABYLON.MeshAssetTask} to the list of active tasks
  17245. * @param taskName defines the name of the new task
  17246. * @param meshesNames defines the name of meshes to load
  17247. * @param rootUrl defines the root url to use to locate files
  17248. * @param sceneFilename defines the filename of the scene file
  17249. * @returns a new {BABYLON.MeshAssetTask} object
  17250. */
  17251. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  17252. /**
  17253. * Add a {BABYLON.TextFileAssetTask} to the list of active tasks
  17254. * @param taskName defines the name of the new task
  17255. * @param url defines the url of the file to load
  17256. * @returns a new {BABYLON.TextFileAssetTask} object
  17257. */
  17258. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  17259. /**
  17260. * Add a {BABYLON.BinaryFileAssetTask} to the list of active tasks
  17261. * @param taskName defines the name of the new task
  17262. * @param url defines the url of the file to load
  17263. * @returns a new {BABYLON.BinaryFileAssetTask} object
  17264. */
  17265. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  17266. /**
  17267. * Add a {BABYLON.ImageAssetTask} to the list of active tasks
  17268. * @param taskName defines the name of the new task
  17269. * @param url defines the url of the file to load
  17270. * @returns a new {BABYLON.ImageAssetTask} object
  17271. */
  17272. addImageTask(taskName: string, url: string): ImageAssetTask;
  17273. /**
  17274. * Add a {BABYLON.TextureAssetTask} to the list of active tasks
  17275. * @param taskName defines the name of the new task
  17276. * @param url defines the url of the file to load
  17277. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  17278. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  17279. * @param samplingMode defines the sampling mode to use (BABYLON.Texture.TRILINEAR_SAMPLINGMODE by default)
  17280. * @returns a new {BABYLON.TextureAssetTask} object
  17281. */
  17282. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  17283. /**
  17284. * Add a {BABYLON.CubeTextureAssetTask} to the list of active tasks
  17285. * @param taskName defines the name of the new task
  17286. * @param url defines the url of the file to load
  17287. * @param extensions defines the extension to use to load the cube map (can be null)
  17288. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  17289. * @param files defines the list of files to load (can be null)
  17290. * @returns a new {BABYLON.CubeTextureAssetTask} object
  17291. */
  17292. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  17293. /**
  17294. *
  17295. * Add a {BABYLON.HDRCubeTextureAssetTask} to the list of active tasks
  17296. * @param taskName defines the name of the new task
  17297. * @param url defines the url of the file to load
  17298. * @param size defines the size you want for the cubemap (can be null)
  17299. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  17300. * @param generateHarmonics defines if you want to automatically generate (true by default)
  17301. * @param useInGammaSpace defines if the texture must be considered in gamma space (false by default)
  17302. * @param usePMREMGenerator is a reserved parameter and must be set to false or ignored
  17303. * @returns a new {BABYLON.HDRCubeTextureAssetTask} object
  17304. */
  17305. addHDRCubeTextureTask(taskName: string, url: string, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean): HDRCubeTextureAssetTask;
  17306. private _decreaseWaitingTasksCount(task);
  17307. private _runTask(task);
  17308. /**
  17309. * Reset the {BABYLON.AssetsManager} and remove all tasks
  17310. * @return the current instance of the {BABYLON.AssetsManager}
  17311. */
  17312. reset(): AssetsManager;
  17313. /**
  17314. * Start the loading process
  17315. * @return the current instance of the {BABYLON.AssetsManager}
  17316. */
  17317. load(): AssetsManager;
  17318. }
  17319. }
  17320. declare module BABYLON {
  17321. class Database {
  17322. private callbackManifestChecked;
  17323. private currentSceneUrl;
  17324. private db;
  17325. private _enableSceneOffline;
  17326. private _enableTexturesOffline;
  17327. private manifestVersionFound;
  17328. private mustUpdateRessources;
  17329. private hasReachedQuota;
  17330. private isSupported;
  17331. private idbFactory;
  17332. static IsUASupportingBlobStorage: boolean;
  17333. static IDBStorageEnabled: boolean;
  17334. readonly enableSceneOffline: boolean;
  17335. readonly enableTexturesOffline: boolean;
  17336. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any);
  17337. static parseURL: (url: string) => string;
  17338. static ReturnFullUrlLocation: (url: string) => string;
  17339. checkManifestFile(): void;
  17340. openAsync(successCallback: () => void, errorCallback: () => void): void;
  17341. loadImageFromDB(url: string, image: HTMLImageElement): void;
  17342. private _loadImageFromDBAsync(url, image, notInDBCallback);
  17343. private _saveImageIntoDBAsync(url, image);
  17344. private _checkVersionFromDB(url, versionLoaded);
  17345. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  17346. private _saveVersionIntoDBAsync(url, callback);
  17347. loadFileFromDB(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  17348. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  17349. private _saveFileIntoDBAsync(url, callback, progressCallback?, useArrayBuffer?);
  17350. }
  17351. }
  17352. declare module BABYLON {
  17353. interface DDSInfo {
  17354. width: number;
  17355. height: number;
  17356. mipmapCount: number;
  17357. isFourCC: boolean;
  17358. isRGB: boolean;
  17359. isLuminance: boolean;
  17360. isCube: boolean;
  17361. isCompressed: boolean;
  17362. dxgiFormat: number;
  17363. textureType: number;
  17364. }
  17365. class DDSTools {
  17366. static StoreLODInAlphaChannel: boolean;
  17367. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  17368. private static _FloatView;
  17369. private static _Int32View;
  17370. private static _ToHalfFloat(value);
  17371. private static _FromHalfFloat(value);
  17372. private static _GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  17373. private static _GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  17374. private static _GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  17375. private static _GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  17376. private static _GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, lod);
  17377. private static _GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  17378. private static _GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  17379. private static _GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  17380. static UploadDDSLevels(engine: Engine, gl: WebGLRenderingContext, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  17381. }
  17382. }
  17383. declare module BABYLON {
  17384. function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  17385. function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17386. function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17387. function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17388. function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17389. function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17390. function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17391. function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17392. function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17393. function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17394. function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17395. function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  17396. class SerializationHelper {
  17397. static Serialize<T>(entity: T, serializationObject?: any): any;
  17398. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  17399. static Clone<T>(creationFunction: () => T, source: T): T;
  17400. static Instanciate<T>(creationFunction: () => T, source: T): T;
  17401. }
  17402. }
  17403. declare module Earcut {
  17404. /**
  17405. * The fastest and smallest JavaScript polygon triangulation library for your WebGL apps
  17406. * @param data is a flat array of vertice coordinates like [x0, y0, x1, y1, x2, y2, ...].
  17407. * @param holeIndices is an array of hole indices if any (e.g. [5, 8] for a 12- vertice input would mean one hole with vertices 5–7 and another with 8–11).
  17408. * @param dim is the number of coordinates per vertice in the input array (2 by default).
  17409. */
  17410. function earcut(data: number[], holeIndices: number[], dim: number): Array<number>;
  17411. /**
  17412. * return a percentage difference between the polygon area and its triangulation area;
  17413. * used to verify correctness of triangulation
  17414. */
  17415. function deviation(data: number[], holeIndices: number[], dim: number, triangles: number[]): number;
  17416. /**
  17417. * turn a polygon in a multi-dimensional array form (e.g. as in GeoJSON) into a form Earcut accepts
  17418. */
  17419. function flatten(data: number[][][]): {
  17420. vertices: number[];
  17421. holes: number[];
  17422. dimensions: number;
  17423. };
  17424. }
  17425. declare module BABYLON {
  17426. class FilesInput {
  17427. static FilesToLoad: {
  17428. [key: string]: File;
  17429. };
  17430. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  17431. private _engine;
  17432. private _currentScene;
  17433. private _sceneLoadedCallback;
  17434. private _progressCallback;
  17435. private _additionalRenderLoopLogicCallback;
  17436. private _textureLoadingCallback;
  17437. private _startingProcessingFilesCallback;
  17438. private _onReloadCallback;
  17439. private _errorCallback;
  17440. private _elementToMonitor;
  17441. private _sceneFileToLoad;
  17442. private _filesToLoad;
  17443. constructor(engine: Engine, scene: Scene, sceneLoadedCallback: (sceneFile: File, scene: Scene) => void, progressCallback: (progress: SceneLoaderProgressEvent) => void, additionalRenderLoopLogicCallback: () => void, textureLoadingCallback: (remaining: number) => void, startingProcessingFilesCallback: () => void, onReloadCallback: (sceneFile: File) => void, errorCallback: (sceneFile: File, scene: Scene, message: string) => void);
  17444. private _dragEnterHandler;
  17445. private _dragOverHandler;
  17446. private _dropHandler;
  17447. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  17448. dispose(): void;
  17449. private renderFunction();
  17450. private drag(e);
  17451. private drop(eventDrop);
  17452. private _traverseFolder(folder, files, remaining, callback);
  17453. private _processFiles(files);
  17454. loadFiles(event: any): void;
  17455. private _processReload();
  17456. reload(): void;
  17457. }
  17458. }
  17459. declare module BABYLON {
  17460. /**
  17461. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  17462. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  17463. */
  17464. class KhronosTextureContainer {
  17465. arrayBuffer: any;
  17466. static HEADER_LEN: number;
  17467. static COMPRESSED_2D: number;
  17468. static COMPRESSED_3D: number;
  17469. static TEX_2D: number;
  17470. static TEX_3D: number;
  17471. glType: number;
  17472. glTypeSize: number;
  17473. glFormat: number;
  17474. glInternalFormat: number;
  17475. glBaseInternalFormat: number;
  17476. pixelWidth: number;
  17477. pixelHeight: number;
  17478. pixelDepth: number;
  17479. numberOfArrayElements: number;
  17480. numberOfFaces: number;
  17481. numberOfMipmapLevels: number;
  17482. bytesOfKeyValueData: number;
  17483. loadType: number;
  17484. /**
  17485. * @param {ArrayBuffer} arrayBuffer- contents of the KTX container file
  17486. * @param {number} facesExpected- should be either 1 or 6, based whether a cube texture or or
  17487. * @param {boolean} threeDExpected- provision for indicating that data should be a 3D texture, not implemented
  17488. * @param {boolean} textureArrayExpected- provision for indicating that data should be a texture array, not implemented
  17489. */
  17490. constructor(arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  17491. switchEndainness(val: number): number;
  17492. /**
  17493. * It is assumed that the texture has already been created & is currently bound
  17494. */
  17495. uploadLevels(gl: WebGLRenderingContext, loadMipmaps: boolean): void;
  17496. private _upload2DCompressedLevels(gl, loadMipmaps);
  17497. }
  17498. }
  17499. declare module BABYLON {
  17500. /**
  17501. * A class serves as a medium between the observable and its observers
  17502. */
  17503. class EventState {
  17504. /**
  17505. * If the callback of a given Observer set skipNextObservers to true the following observers will be ignored
  17506. */
  17507. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  17508. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  17509. /**
  17510. * An Observer can set this property to true to prevent subsequent observers of being notified
  17511. */
  17512. skipNextObservers: boolean;
  17513. /**
  17514. * Get the mask value that were used to trigger the event corresponding to this EventState object
  17515. */
  17516. mask: number;
  17517. /**
  17518. * The object that originally notified the event
  17519. */
  17520. target?: any;
  17521. /**
  17522. * The current object in the bubbling phase
  17523. */
  17524. currentTarget?: any;
  17525. }
  17526. /**
  17527. * Represent an Observer registered to a given Observable object.
  17528. */
  17529. class Observer<T> {
  17530. callback: (eventData: T, eventState: EventState) => void;
  17531. mask: number;
  17532. scope: any;
  17533. constructor(callback: (eventData: T, eventState: EventState) => void, mask: number, scope?: any);
  17534. }
  17535. /**
  17536. * Represent a list of observers registered to multiple Observables object.
  17537. */
  17538. class MultiObserver<T> {
  17539. private _observers;
  17540. private _observables;
  17541. dispose(): void;
  17542. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  17543. }
  17544. /**
  17545. * The Observable class is a simple implementation of the Observable pattern.
  17546. * 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.
  17547. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  17548. * 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).
  17549. * 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.
  17550. */
  17551. class Observable<T> {
  17552. _observers: Observer<T>[];
  17553. private _eventState;
  17554. private _onObserverAdded;
  17555. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  17556. /**
  17557. * Create a new Observer with the specified callback
  17558. * @param callback the callback that will be executed for that Observer
  17559. * @param mask the mask used to filter observers
  17560. * @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.
  17561. * @param scope optional scope for the callback to be called from
  17562. */
  17563. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any): Nullable<Observer<T>>;
  17564. /**
  17565. * Remove an Observer from the Observable object
  17566. * @param observer the instance of the Observer to remove. If it doesn't belong to this Observable, false will be returned.
  17567. */
  17568. remove(observer: Nullable<Observer<T>>): boolean;
  17569. /**
  17570. * Remove a callback from the Observable object
  17571. * @param callback the callback to remove. If it doesn't belong to this Observable, false will be returned.
  17572. * @param scope optional scope. If used only the callbacks with this scope will be removed.
  17573. */
  17574. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  17575. /**
  17576. * Notify all Observers by calling their respective callback with the given data
  17577. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  17578. * @param eventData
  17579. * @param mask
  17580. */
  17581. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  17582. /**
  17583. * Notify a specific observer
  17584. * @param eventData
  17585. * @param mask
  17586. */
  17587. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  17588. /**
  17589. * return true is the Observable has at least one Observer registered
  17590. */
  17591. hasObservers(): boolean;
  17592. /**
  17593. * Clear the list of observers
  17594. */
  17595. clear(): void;
  17596. /**
  17597. * Clone the current observable
  17598. */
  17599. clone(): Observable<T>;
  17600. /**
  17601. * Does this observable handles observer registered with a given mask
  17602. * @param {number} trigger - the mask to be tested
  17603. * @return {boolean} whether or not one observer registered with the given mask is handeled
  17604. **/
  17605. hasSpecificMask(mask?: number): boolean;
  17606. }
  17607. }
  17608. declare module BABYLON {
  17609. /**
  17610. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  17611. */
  17612. class PerformanceMonitor {
  17613. private _enabled;
  17614. private _rollingFrameTime;
  17615. private _lastFrameTimeMs;
  17616. /**
  17617. * constructor
  17618. * @param frameSampleSize The number of samples required to saturate the sliding window
  17619. */
  17620. constructor(frameSampleSize?: number);
  17621. /**
  17622. * Samples current frame
  17623. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  17624. */
  17625. sampleFrame(timeMs?: number): void;
  17626. /**
  17627. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  17628. * @return Average frame time in milliseconds
  17629. */
  17630. readonly averageFrameTime: number;
  17631. /**
  17632. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  17633. * @return Frame time variance in milliseconds squared
  17634. */
  17635. readonly averageFrameTimeVariance: number;
  17636. /**
  17637. * Returns the frame time of the most recent frame
  17638. * @return Frame time in milliseconds
  17639. */
  17640. readonly instantaneousFrameTime: number;
  17641. /**
  17642. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  17643. * @return Framerate in frames per second
  17644. */
  17645. readonly averageFPS: number;
  17646. /**
  17647. * Returns the average framerate in frames per second using the most recent frame time
  17648. * @return Framerate in frames per second
  17649. */
  17650. readonly instantaneousFPS: number;
  17651. /**
  17652. * Returns true if enough samples have been taken to completely fill the sliding window
  17653. * @return true if saturated
  17654. */
  17655. readonly isSaturated: boolean;
  17656. /**
  17657. * Enables contributions to the sliding window sample set
  17658. */
  17659. enable(): void;
  17660. /**
  17661. * Disables contributions to the sliding window sample set
  17662. * Samples will not be interpolated over the disabled period
  17663. */
  17664. disable(): void;
  17665. /**
  17666. * Returns true if sampling is enabled
  17667. * @return true if enabled
  17668. */
  17669. readonly isEnabled: boolean;
  17670. /**
  17671. * Resets performance monitor
  17672. */
  17673. reset(): void;
  17674. }
  17675. /**
  17676. * RollingAverage
  17677. *
  17678. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  17679. */
  17680. class RollingAverage {
  17681. /**
  17682. * Current average
  17683. */
  17684. average: number;
  17685. /**
  17686. * Current variance
  17687. */
  17688. variance: number;
  17689. protected _samples: Array<number>;
  17690. protected _sampleCount: number;
  17691. protected _pos: number;
  17692. protected _m2: number;
  17693. /**
  17694. * constructor
  17695. * @param length The number of samples required to saturate the sliding window
  17696. */
  17697. constructor(length: number);
  17698. /**
  17699. * Adds a sample to the sample set
  17700. * @param v The sample value
  17701. */
  17702. add(v: number): void;
  17703. /**
  17704. * Returns previously added values or null if outside of history or outside the sliding window domain
  17705. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  17706. * @return Value previously recorded with add() or null if outside of range
  17707. */
  17708. history(i: number): number;
  17709. /**
  17710. * Returns true if enough samples have been taken to completely fill the sliding window
  17711. * @return true if sample-set saturated
  17712. */
  17713. isSaturated(): boolean;
  17714. /**
  17715. * Resets the rolling average (equivalent to 0 samples taken so far)
  17716. */
  17717. reset(): void;
  17718. /**
  17719. * Wraps a value around the sample range boundaries
  17720. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  17721. * @return Wrapped position in sample range
  17722. */
  17723. protected _wrapPosition(i: number): number;
  17724. }
  17725. }
  17726. declare module BABYLON {
  17727. /**
  17728. * Defines the root class used to create scene optimization to use with SceneOptimizer
  17729. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17730. */
  17731. class SceneOptimization {
  17732. /**
  17733. * Defines the priority of this optimization (0 by default which means first in the list)
  17734. */
  17735. priority: number;
  17736. /**
  17737. * Gets a string describing the action executed by the current optimization
  17738. * @returns description string
  17739. */
  17740. getDescription(): string;
  17741. /**
  17742. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17743. * @param scene defines the current scene where to apply this optimization
  17744. * @returns true if everything that can be done was applied
  17745. */
  17746. apply(scene: Scene): boolean;
  17747. /**
  17748. * Creates the SceneOptimization object
  17749. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  17750. * @param desc defines the description associated with the optimization
  17751. */
  17752. constructor(
  17753. /**
  17754. * Defines the priority of this optimization (0 by default which means first in the list)
  17755. */
  17756. priority?: number);
  17757. }
  17758. /**
  17759. * Defines an optimization used to reduce the size of render target textures
  17760. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17761. */
  17762. class TextureOptimization extends SceneOptimization {
  17763. /**
  17764. * Defines the priority of this optimization (0 by default which means first in the list)
  17765. */
  17766. priority: number;
  17767. /**
  17768. * 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
  17769. */
  17770. maximumSize: number;
  17771. /**
  17772. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  17773. */
  17774. step: number;
  17775. /**
  17776. * Gets a string describing the action executed by the current optimization
  17777. * @returns description string
  17778. */
  17779. getDescription(): string;
  17780. /**
  17781. * Creates the TextureOptimization object
  17782. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  17783. * @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
  17784. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  17785. */
  17786. constructor(
  17787. /**
  17788. * Defines the priority of this optimization (0 by default which means first in the list)
  17789. */
  17790. priority?: number,
  17791. /**
  17792. * 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
  17793. */
  17794. maximumSize?: number,
  17795. /**
  17796. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  17797. */
  17798. step?: number);
  17799. /**
  17800. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17801. * @param scene defines the current scene where to apply this optimization
  17802. * @returns true if everything that can be done was applied
  17803. */
  17804. apply(scene: Scene): boolean;
  17805. }
  17806. /**
  17807. * Defines an optimization used to increase or decrease the rendering resolution
  17808. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17809. */
  17810. class HardwareScalingOptimization extends SceneOptimization {
  17811. /**
  17812. * Defines the priority of this optimization (0 by default which means first in the list)
  17813. */
  17814. priority: number;
  17815. /**
  17816. * Defines the maximum scale to use (2 by default)
  17817. */
  17818. maximumScale: number;
  17819. /**
  17820. * Defines the step to use between two passes (0.5 by default)
  17821. */
  17822. step: number;
  17823. private _currentScale;
  17824. private _directionOffset;
  17825. /**
  17826. * Gets a string describing the action executed by the current optimization
  17827. * @return description string
  17828. */
  17829. getDescription(): string;
  17830. /**
  17831. * Creates the HardwareScalingOptimization object
  17832. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  17833. * @param maximumScale defines the maximum scale to use (2 by default)
  17834. * @param step defines the step to use between two passes (0.5 by default)
  17835. */
  17836. constructor(
  17837. /**
  17838. * Defines the priority of this optimization (0 by default which means first in the list)
  17839. */
  17840. priority?: number,
  17841. /**
  17842. * Defines the maximum scale to use (2 by default)
  17843. */
  17844. maximumScale?: number,
  17845. /**
  17846. * Defines the step to use between two passes (0.5 by default)
  17847. */
  17848. step?: number);
  17849. /**
  17850. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17851. * @param scene defines the current scene where to apply this optimization
  17852. * @returns true if everything that can be done was applied
  17853. */
  17854. apply(scene: Scene): boolean;
  17855. }
  17856. /**
  17857. * Defines an optimization used to remove shadows
  17858. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17859. */
  17860. class ShadowsOptimization extends SceneOptimization {
  17861. /**
  17862. * Defines the priority of this optimization (0 by default which means first in the list)
  17863. */
  17864. priority: number;
  17865. /**
  17866. * Defines the value to set the scene.shadowsEnabled property to (false by default)
  17867. */
  17868. target: boolean;
  17869. /**
  17870. * Gets a string describing the action executed by the current optimization
  17871. * @return description string
  17872. */
  17873. getDescription(): string;
  17874. /**
  17875. * Creates the ShadowsOptimization object
  17876. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  17877. * @param target defines the value to set the scene.shadowsEnabled property to (false by default)
  17878. */
  17879. constructor(
  17880. /**
  17881. * Defines the priority of this optimization (0 by default which means first in the list)
  17882. */
  17883. priority?: number,
  17884. /**
  17885. * Defines the value to set the scene.shadowsEnabled property to (false by default)
  17886. */
  17887. target?: boolean);
  17888. /**
  17889. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17890. * @param scene defines the current scene where to apply this optimization
  17891. * @returns true if everything that can be done was applied
  17892. */
  17893. apply(scene: Scene): boolean;
  17894. }
  17895. /**
  17896. * Defines an optimization used to turn post-processes off
  17897. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17898. */
  17899. class PostProcessesOptimization extends SceneOptimization {
  17900. /**
  17901. * Defines the priority of this optimization (0 by default which means first in the list)
  17902. */
  17903. priority: number;
  17904. /**
  17905. * Defines the value to set the scene.postProcessesEnabled property to (false by default)
  17906. */
  17907. target: boolean;
  17908. /**
  17909. * Gets a string describing the action executed by the current optimization
  17910. * @return description string
  17911. */
  17912. getDescription(): string;
  17913. /**
  17914. * Creates the PostProcessesOptimization object
  17915. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  17916. * @param target defines the value to set the scene.postProcessesEnabled property to (false by default)
  17917. */
  17918. constructor(
  17919. /**
  17920. * Defines the priority of this optimization (0 by default which means first in the list)
  17921. */
  17922. priority?: number,
  17923. /**
  17924. * Defines the value to set the scene.postProcessesEnabled property to (false by default)
  17925. */
  17926. target?: boolean);
  17927. /**
  17928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17929. * @param scene defines the current scene where to apply this optimization
  17930. * @returns true if everything that can be done was applied
  17931. */
  17932. apply(scene: Scene): boolean;
  17933. }
  17934. /**
  17935. * Defines an optimization used to turn lens flares off
  17936. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17937. */
  17938. class LensFlaresOptimization extends SceneOptimization {
  17939. /**
  17940. * Defines the priority of this optimization (0 by default which means first in the list)
  17941. */
  17942. priority: number;
  17943. /**
  17944. * Defines the value to set the scene.lensFlaresEnabled property to (false by default)
  17945. */
  17946. target: boolean;
  17947. /**
  17948. * Gets a string describing the action executed by the current optimization
  17949. * @return description string
  17950. */
  17951. getDescription(): string;
  17952. /**
  17953. * Creates the LensFlaresOptimization object
  17954. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  17955. * @param target defines the value to set the scene.lensFlaresEnabled property to (false by default)
  17956. */
  17957. constructor(
  17958. /**
  17959. * Defines the priority of this optimization (0 by default which means first in the list)
  17960. */
  17961. priority?: number,
  17962. /**
  17963. * Defines the value to set the scene.lensFlaresEnabled property to (false by default)
  17964. */
  17965. target?: boolean);
  17966. /**
  17967. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17968. * @param scene defines the current scene where to apply this optimization
  17969. * @returns true if everything that can be done was applied
  17970. */
  17971. apply(scene: Scene): boolean;
  17972. }
  17973. /**
  17974. * Defines an optimization based on user defined callback.
  17975. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  17976. */
  17977. class CustomOptimization extends SceneOptimization {
  17978. /**
  17979. * Callback called to apply the custom optimization.
  17980. */
  17981. onApply: (scene: Scene) => boolean;
  17982. /**
  17983. * Callback called to get custom description
  17984. */
  17985. onGetDescription: () => string;
  17986. /**
  17987. * Gets a string describing the action executed by the current optimization
  17988. * @returns description string
  17989. */
  17990. getDescription(): string;
  17991. /**
  17992. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  17993. * @param scene defines the current scene where to apply this optimization
  17994. * @returns true if everything that can be done was applied
  17995. */
  17996. apply(scene: Scene): boolean;
  17997. }
  17998. /**
  17999. * Defines an optimization used to turn particles off
  18000. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  18001. */
  18002. class ParticlesOptimization extends SceneOptimization {
  18003. /**
  18004. * Defines the priority of this optimization (0 by default which means first in the list)
  18005. */
  18006. priority: number;
  18007. /**
  18008. * Defines the value to set the scene.particlesEnabled property to (false by default)
  18009. */
  18010. target: boolean;
  18011. /**
  18012. * Gets a string describing the action executed by the current optimization
  18013. * @return description string
  18014. */
  18015. getDescription(): string;
  18016. /**
  18017. * Creates the ParticlesOptimization object
  18018. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  18019. * @param target defines the value to set the scene.particlesEnabled property to (false by default)
  18020. */
  18021. constructor(
  18022. /**
  18023. * Defines the priority of this optimization (0 by default which means first in the list)
  18024. */
  18025. priority?: number,
  18026. /**
  18027. * Defines the value to set the scene.particlesEnabled property to (false by default)
  18028. */
  18029. target?: boolean);
  18030. /**
  18031. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  18032. * @param scene defines the current scene where to apply this optimization
  18033. * @returns true if everything that can be done was applied
  18034. */
  18035. apply(scene: Scene): boolean;
  18036. }
  18037. /**
  18038. * Defines an optimization used to turn render targets off
  18039. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  18040. */
  18041. class RenderTargetsOptimization extends SceneOptimization {
  18042. /**
  18043. * Gets a string describing the action executed by the current optimization
  18044. * @return description string
  18045. */
  18046. getDescription(): string;
  18047. /**
  18048. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  18049. * @param scene defines the current scene where to apply this optimization
  18050. * @returns true if everything that can be done was applied
  18051. */
  18052. apply(scene: Scene): boolean;
  18053. }
  18054. /**
  18055. * Defines an optimization used to merge meshes with compatible materials
  18056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  18057. */
  18058. class MergeMeshesOptimization extends SceneOptimization {
  18059. private static _UpdateSelectionTree;
  18060. /**
  18061. * Gets or sets a boolean which defines if optimization octree has to be updated
  18062. */
  18063. /**
  18064. * Gets or sets a boolean which defines if optimization octree has to be updated
  18065. */
  18066. static UpdateSelectionTree: boolean;
  18067. /**
  18068. * Gets a string describing the action executed by the current optimization
  18069. * @return description string
  18070. */
  18071. getDescription(): string;
  18072. private _canBeMerged;
  18073. /**
  18074. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  18075. * @param scene defines the current scene where to apply this optimization
  18076. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  18077. * @returns true if everything that can be done was applied
  18078. */
  18079. apply(scene: Scene, updateSelectionTree?: boolean): boolean;
  18080. }
  18081. /**
  18082. * Defines a list of options used by SceneOptimizer
  18083. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  18084. */
  18085. class SceneOptimizerOptions {
  18086. /**
  18087. * Defines the target frame rate to reach (60 by default)
  18088. */
  18089. targetFrameRate: number;
  18090. /**
  18091. * Defines the interval between two checkes (2000ms by default)
  18092. */
  18093. trackerDuration: number;
  18094. /**
  18095. * Gets the list of optimizations to apply
  18096. */
  18097. optimizations: SceneOptimization[];
  18098. /**
  18099. * Creates a new list of options used by SceneOptimizer
  18100. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  18101. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  18102. */
  18103. constructor(
  18104. /**
  18105. * Defines the target frame rate to reach (60 by default)
  18106. */
  18107. targetFrameRate?: number,
  18108. /**
  18109. * Defines the interval between two checkes (2000ms by default)
  18110. */
  18111. trackerDuration?: number);
  18112. /**
  18113. * Add a new optimization
  18114. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  18115. * @returns the current SceneOptimizerOptions
  18116. */
  18117. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  18118. /**
  18119. * Add a new custom optimization
  18120. * @param onApply defines the callback called to apply the custom optimization.
  18121. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  18122. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  18123. * @returns the current SceneOptimizerOptions
  18124. */
  18125. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  18126. /**
  18127. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  18128. * @param targetFrameRate defines the target frame rate (60 by default)
  18129. * @returns a SceneOptimizerOptions object
  18130. */
  18131. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  18132. /**
  18133. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  18134. * @param targetFrameRate defines the target frame rate (60 by default)
  18135. * @returns a SceneOptimizerOptions object
  18136. */
  18137. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  18138. /**
  18139. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  18140. * @param targetFrameRate defines the target frame rate (60 by default)
  18141. * @returns a SceneOptimizerOptions object
  18142. */
  18143. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  18144. }
  18145. /**
  18146. * Class used to run optimizations in order to reach a target frame rate
  18147. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  18148. */
  18149. class SceneOptimizer implements IDisposable {
  18150. private _isRunning;
  18151. private _options;
  18152. private _scene;
  18153. private _currentPriorityLevel;
  18154. private _targetFrameRate;
  18155. private _trackerDuration;
  18156. private _currentFrameRate;
  18157. private _sceneDisposeObserver;
  18158. private _improvementMode;
  18159. /**
  18160. * Defines an observable called when the optimizer reaches the target frame rate
  18161. */
  18162. onSuccessObservable: Observable<SceneOptimizer>;
  18163. /**
  18164. * Defines an observable called when the optimizer enables an optimization
  18165. */
  18166. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  18167. /**
  18168. * Defines an observable called when the optimizer is not able to reach the target frame rate
  18169. */
  18170. onFailureObservable: Observable<SceneOptimizer>;
  18171. /**
  18172. * Gets the current priority level (0 at start)
  18173. */
  18174. readonly currentPriorityLevel: number;
  18175. /**
  18176. * Gets the current frame rate checked by the SceneOptimizer
  18177. */
  18178. readonly currentFrameRate: number;
  18179. /**
  18180. * Gets or sets the current target frame rate (60 by default)
  18181. */
  18182. /**
  18183. * Gets or sets the current target frame rate (60 by default)
  18184. */
  18185. targetFrameRate: number;
  18186. /**
  18187. * Gets or sets the current interval between two checks (every 2000ms by default)
  18188. */
  18189. /**
  18190. * Gets or sets the current interval between two checks (every 2000ms by default)
  18191. */
  18192. trackerDuration: number;
  18193. /**
  18194. * Gets the list of active optimizations
  18195. */
  18196. readonly optimizations: SceneOptimization[];
  18197. /**
  18198. * Creates a new SceneOptimizer
  18199. * @param scene defines the scene to work on
  18200. * @param options defines the options to use with the SceneOptimizer
  18201. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  18202. * @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)
  18203. */
  18204. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  18205. /**
  18206. * Stops the current optimizer
  18207. */
  18208. stop(): void;
  18209. /**
  18210. * Reset the optimizer to initial step (current priority level = 0)
  18211. */
  18212. reset(): void;
  18213. /**
  18214. * Start the optimizer. By default it will try to reach a specific framerate
  18215. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  18216. */
  18217. start(): void;
  18218. private _checkCurrentState();
  18219. /**
  18220. * Release all resources
  18221. */
  18222. dispose(): void;
  18223. /**
  18224. * Helper function to create a SceneOptimizer with one single line of code
  18225. * @param scene defines the scene to work on
  18226. * @param options defines the options to use with the SceneOptimizer
  18227. * @param onSuccess defines a callback to call on success
  18228. * @param onFailure defines a callback to call on failure
  18229. * @returns the new SceneOptimizer object
  18230. */
  18231. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  18232. }
  18233. }
  18234. declare module BABYLON {
  18235. class SceneSerializer {
  18236. static ClearCache(): void;
  18237. static Serialize(scene: Scene): any;
  18238. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  18239. }
  18240. }
  18241. declare module BABYLON {
  18242. class SmartArray<T> {
  18243. data: Array<T>;
  18244. length: number;
  18245. protected _id: number;
  18246. [index: number]: T;
  18247. constructor(capacity: number);
  18248. push(value: T): void;
  18249. forEach(func: (content: T) => void): void;
  18250. sort(compareFn: (a: T, b: T) => number): void;
  18251. reset(): void;
  18252. dispose(): void;
  18253. concat(array: any): void;
  18254. indexOf(value: T): number;
  18255. contains(value: T): boolean;
  18256. private static _GlobalId;
  18257. }
  18258. class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  18259. private _duplicateId;
  18260. [index: number]: T;
  18261. push(value: T): void;
  18262. pushNoDuplicate(value: T): boolean;
  18263. reset(): void;
  18264. concatWithNoDuplicate(array: any): void;
  18265. }
  18266. }
  18267. declare module BABYLON {
  18268. /**
  18269. * This class implement a typical dictionary using a string as key and the generic type T as value.
  18270. * The underlying implementation relies on an associative array to ensure the best performances.
  18271. * The value can be anything including 'null' but except 'undefined'
  18272. */
  18273. class StringDictionary<T> {
  18274. /**
  18275. * This will clear this dictionary and copy the content from the 'source' one.
  18276. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  18277. * @param source the dictionary to take the content from and copy to this dictionary
  18278. */
  18279. copyFrom(source: StringDictionary<T>): void;
  18280. /**
  18281. * Get a value based from its key
  18282. * @param key the given key to get the matching value from
  18283. * @return the value if found, otherwise undefined is returned
  18284. */
  18285. get(key: string): T | undefined;
  18286. /**
  18287. * Get a value from its key or add it if it doesn't exist.
  18288. * This method will ensure you that a given key/data will be present in the dictionary.
  18289. * @param key the given key to get the matching value from
  18290. * @param factory the factory that will create the value if the key is not present in the dictionary.
  18291. * The factory will only be invoked if there's no data for the given key.
  18292. * @return the value corresponding to the key.
  18293. */
  18294. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  18295. /**
  18296. * Get a value from its key if present in the dictionary otherwise add it
  18297. * @param key the key to get the value from
  18298. * @param val if there's no such key/value pair in the dictionary add it with this value
  18299. * @return the value corresponding to the key
  18300. */
  18301. getOrAdd(key: string, val: T): T;
  18302. /**
  18303. * Check if there's a given key in the dictionary
  18304. * @param key the key to check for
  18305. * @return true if the key is present, false otherwise
  18306. */
  18307. contains(key: string): boolean;
  18308. /**
  18309. * Add a new key and its corresponding value
  18310. * @param key the key to add
  18311. * @param value the value corresponding to the key
  18312. * @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
  18313. */
  18314. add(key: string, value: T): boolean;
  18315. set(key: string, value: T): boolean;
  18316. /**
  18317. * Get the element of the given key and remove it from the dictionary
  18318. * @param key
  18319. */
  18320. getAndRemove(key: string): Nullable<T>;
  18321. /**
  18322. * Remove a key/value from the dictionary.
  18323. * @param key the key to remove
  18324. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  18325. */
  18326. remove(key: string): boolean;
  18327. /**
  18328. * Clear the whole content of the dictionary
  18329. */
  18330. clear(): void;
  18331. readonly count: number;
  18332. /**
  18333. * Execute a callback on each key/val of the dictionary.
  18334. * Note that you can remove any element in this dictionary in the callback implementation
  18335. * @param callback the callback to execute on a given key/value pair
  18336. */
  18337. forEach(callback: (key: string, val: T) => void): void;
  18338. /**
  18339. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  18340. * If the callback returns null or undefined the method will iterate to the next key/value pair
  18341. * Note that you can remove any element in this dictionary in the callback implementation
  18342. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  18343. */
  18344. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  18345. private _count;
  18346. private _data;
  18347. }
  18348. }
  18349. declare module BABYLON {
  18350. class Tags {
  18351. static EnableFor(obj: any): void;
  18352. static DisableFor(obj: any): void;
  18353. static HasTags(obj: any): boolean;
  18354. static GetTags(obj: any, asString?: boolean): any;
  18355. static AddTagsTo(obj: any, tagsString: string): void;
  18356. static _AddTagTo(obj: any, tag: string): void;
  18357. static RemoveTagsFrom(obj: any, tagsString: string): void;
  18358. static _RemoveTagFrom(obj: any, tag: string): void;
  18359. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  18360. }
  18361. }
  18362. declare module BABYLON {
  18363. class TextureTools {
  18364. /**
  18365. * Uses the GPU to create a copy texture rescaled at a given size
  18366. * @param texture Texture to copy from
  18367. * @param width Desired width
  18368. * @param height Desired height
  18369. * @return Generated texture
  18370. */
  18371. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  18372. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  18373. private static _environmentBRDFBase64Texture;
  18374. }
  18375. }
  18376. declare module BABYLON {
  18377. class TGATools {
  18378. private static _TYPE_INDEXED;
  18379. private static _TYPE_RGB;
  18380. private static _TYPE_GREY;
  18381. private static _TYPE_RLE_INDEXED;
  18382. private static _TYPE_RLE_RGB;
  18383. private static _TYPE_RLE_GREY;
  18384. private static _ORIGIN_MASK;
  18385. private static _ORIGIN_SHIFT;
  18386. private static _ORIGIN_BL;
  18387. private static _ORIGIN_BR;
  18388. private static _ORIGIN_UL;
  18389. private static _ORIGIN_UR;
  18390. static GetTGAHeader(data: Uint8Array): any;
  18391. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  18392. 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;
  18393. 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;
  18394. 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;
  18395. 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;
  18396. 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;
  18397. 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;
  18398. }
  18399. }
  18400. declare module BABYLON {
  18401. interface IAnimatable {
  18402. animations: Array<Animation>;
  18403. }
  18404. class LoadFileError extends Error {
  18405. request: XMLHttpRequest | undefined;
  18406. private static _setPrototypeOf;
  18407. constructor(message: string, request?: XMLHttpRequest | undefined);
  18408. }
  18409. class RetryStrategy {
  18410. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  18411. }
  18412. interface IFileRequest {
  18413. /**
  18414. * Raised when the request is complete (success or error).
  18415. */
  18416. onCompleteObservable: Observable<IFileRequest>;
  18417. /**
  18418. * Aborts the request for a file.
  18419. */
  18420. abort: () => void;
  18421. }
  18422. class Tools {
  18423. static BaseUrl: string;
  18424. static DefaultRetryStrategy: (url: string, request: XMLHttpRequest, retryIndex: number) => number;
  18425. /**
  18426. * Default behaviour for cors in the application.
  18427. * It can be a string if the expected behavior is identical in the entire app.
  18428. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  18429. */
  18430. static CorsBehavior: string | ((url: string | string[]) => string);
  18431. static UseFallbackTexture: boolean;
  18432. /**
  18433. * Use this object to register external classes like custom textures or material
  18434. * to allow the laoders to instantiate them
  18435. */
  18436. static RegisteredExternalClasses: {
  18437. [key: string]: Object;
  18438. };
  18439. static fallbackTexture: string;
  18440. /**
  18441. * Interpolates between a and b via alpha
  18442. * @param a The lower value (returned when alpha = 0)
  18443. * @param b The upper value (returned when alpha = 1)
  18444. * @param alpha The interpolation-factor
  18445. * @return The mixed value
  18446. */
  18447. static Mix(a: number, b: number, alpha: number): number;
  18448. static Instantiate(className: string): any;
  18449. static SetImmediate(action: () => void): void;
  18450. static IsExponentOfTwo(value: number): boolean;
  18451. /**
  18452. * Find the next highest power of two.
  18453. * @param x Number to start search from.
  18454. * @return Next highest power of two.
  18455. */
  18456. static CeilingPOT(x: number): number;
  18457. /**
  18458. * Find the next lowest power of two.
  18459. * @param x Number to start search from.
  18460. * @return Next lowest power of two.
  18461. */
  18462. static FloorPOT(x: number): number;
  18463. /**
  18464. * Find the nearest power of two.
  18465. * @param x Number to start search from.
  18466. * @return Next nearest power of two.
  18467. */
  18468. static NearestPOT(x: number): number;
  18469. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  18470. static GetFilename(path: string): string;
  18471. static GetFolderPath(uri: string): string;
  18472. static GetDOMTextContent(element: HTMLElement): string;
  18473. static ToDegrees(angle: number): number;
  18474. static ToRadians(angle: number): number;
  18475. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  18476. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  18477. minimum: Vector3;
  18478. maximum: Vector3;
  18479. };
  18480. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  18481. minimum: Vector3;
  18482. maximum: Vector3;
  18483. };
  18484. static Vector2ArrayFeeder(array: Array<Vector2> | Float32Array): (i: number) => Nullable<Vector2>;
  18485. static ExtractMinAndMaxVector2(feeder: (index: number) => Vector2, bias?: Nullable<Vector2>): {
  18486. minimum: Vector2;
  18487. maximum: Vector2;
  18488. };
  18489. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  18490. static GetPointerPrefix(): string;
  18491. /**
  18492. * @param func - the function to be called
  18493. * @param requester - the object that will request the next frame. Falls back to window.
  18494. */
  18495. static QueueNewFrame(func: () => void, requester?: any): number;
  18496. static RequestFullscreen(element: HTMLElement): void;
  18497. static ExitFullscreen(): void;
  18498. static SetCorsBehavior(url: string | string[], element: {
  18499. crossOrigin: string | null;
  18500. }): void;
  18501. static CleanUrl(url: string): string;
  18502. static PreprocessUrl: (url: string) => string;
  18503. static LoadImage(url: any, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, database: Nullable<Database>): HTMLImageElement;
  18504. static LoadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, database?: Database, useArrayBuffer?: boolean, onError?: (request?: XMLHttpRequest, exception?: any) => void): IFileRequest;
  18505. /**
  18506. * Load a script (identified by an url). When the url returns, the
  18507. * content of this file is added into a new script element, attached to the DOM (body element)
  18508. */
  18509. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void): void;
  18510. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (this: MSBaseReader, ev: ProgressEvent) => any): IFileRequest;
  18511. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (this: MSBaseReader, ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  18512. static FileAsURL(content: string): string;
  18513. static Format(value: number, decimals?: number): string;
  18514. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  18515. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  18516. static IsEmpty(obj: any): boolean;
  18517. static RegisterTopRootEvents(events: {
  18518. name: string;
  18519. handler: Nullable<(e: FocusEvent) => any>;
  18520. }[]): void;
  18521. static UnregisterTopRootEvents(events: {
  18522. name: string;
  18523. handler: Nullable<(e: FocusEvent) => any>;
  18524. }[]): void;
  18525. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  18526. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  18527. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  18528. /**
  18529. * Generates an image screenshot from the specified camera.
  18530. *
  18531. * @param engine The engine to use for rendering
  18532. * @param camera The camera to use for rendering
  18533. * @param size This parameter can be set to a single number or to an object with the
  18534. * following (optional) properties: precision, width, height. If a single number is passed,
  18535. * it will be used for both width and height. If an object is passed, the screenshot size
  18536. * will be derived from the parameters. The precision property is a multiplier allowing
  18537. * rendering at a higher or lower resolution.
  18538. * @param successCallback The callback receives a single parameter which contains the
  18539. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  18540. * src parameter of an <img> to display it.
  18541. * @param mimeType The MIME type of the screenshot image (default: image/png).
  18542. * Check your browser for supported MIME types.
  18543. * @param samples Texture samples (default: 1)
  18544. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  18545. * @param fileName A name for for the downloaded file.
  18546. * @constructor
  18547. */
  18548. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  18549. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  18550. /**
  18551. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  18552. * Be aware Math.random() could cause collisions, but:
  18553. * "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"
  18554. */
  18555. static RandomId(): string;
  18556. private static _NoneLogLevel;
  18557. private static _MessageLogLevel;
  18558. private static _WarningLogLevel;
  18559. private static _ErrorLogLevel;
  18560. private static _LogCache;
  18561. static errorsCount: number;
  18562. static OnNewCacheEntry: (entry: string) => void;
  18563. static readonly NoneLogLevel: number;
  18564. static readonly MessageLogLevel: number;
  18565. static readonly WarningLogLevel: number;
  18566. static readonly ErrorLogLevel: number;
  18567. static readonly AllLogLevel: number;
  18568. private static _AddLogEntry(entry);
  18569. private static _FormatMessage(message);
  18570. private static _LogDisabled(message);
  18571. private static _LogEnabled(message);
  18572. private static _WarnDisabled(message);
  18573. private static _WarnEnabled(message);
  18574. private static _ErrorDisabled(message);
  18575. private static _ErrorEnabled(message);
  18576. static Log: (message: string) => void;
  18577. static Warn: (message: string) => void;
  18578. static Error: (message: string) => void;
  18579. static readonly LogCache: string;
  18580. static ClearLogCache(): void;
  18581. static LogLevels: number;
  18582. static IsWindowObjectExist(): boolean;
  18583. private static _PerformanceNoneLogLevel;
  18584. private static _PerformanceUserMarkLogLevel;
  18585. private static _PerformanceConsoleLogLevel;
  18586. private static _performance;
  18587. static readonly PerformanceNoneLogLevel: number;
  18588. static readonly PerformanceUserMarkLogLevel: number;
  18589. static readonly PerformanceConsoleLogLevel: number;
  18590. static PerformanceLogLevel: number;
  18591. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  18592. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  18593. static _StartUserMark(counterName: string, condition?: boolean): void;
  18594. static _EndUserMark(counterName: string, condition?: boolean): void;
  18595. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  18596. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  18597. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  18598. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  18599. static readonly Now: number;
  18600. /**
  18601. * This method will return the name of the class used to create the instance of the given object.
  18602. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  18603. * @param object the object to get the class name from
  18604. * @return the name of the class, will be "object" for a custom data type not using the @className decorator
  18605. */
  18606. static GetClassName(object: any, isType?: boolean): string;
  18607. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  18608. /**
  18609. * This method will return the name of the full name of the class, including its owning module (if any).
  18610. * 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).
  18611. * @param object the object to get the class name from
  18612. * @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.
  18613. */
  18614. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  18615. /**
  18616. * This method can be used with hashCodeFromStream when your input is an array of values that are either: number, string, boolean or custom type implementing the getHashCode():number method.
  18617. * @param array
  18618. */
  18619. static arrayOrStringFeeder(array: any): (i: number) => number;
  18620. /**
  18621. * Compute the hashCode of a stream of number
  18622. * To compute the HashCode on a string or an Array of data types implementing the getHashCode() method, use the arrayOrStringFeeder method.
  18623. * @param feeder a callback that will be called until it returns null, each valid returned values will be used to compute the hash code.
  18624. * @return the hash code computed
  18625. */
  18626. static hashCodeFromStream(feeder: (index: number) => number): number;
  18627. }
  18628. /**
  18629. * This class is used to track a performance counter which is number based.
  18630. * The user has access to many properties which give statistics of different nature
  18631. *
  18632. * The implementer can track two kinds of Performance Counter: time and count
  18633. * 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.
  18634. * 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.
  18635. */
  18636. class PerfCounter {
  18637. static Enabled: boolean;
  18638. /**
  18639. * Returns the smallest value ever
  18640. */
  18641. readonly min: number;
  18642. /**
  18643. * Returns the biggest value ever
  18644. */
  18645. readonly max: number;
  18646. /**
  18647. * Returns the average value since the performance counter is running
  18648. */
  18649. readonly average: number;
  18650. /**
  18651. * Returns the average value of the last second the counter was monitored
  18652. */
  18653. readonly lastSecAverage: number;
  18654. /**
  18655. * Returns the current value
  18656. */
  18657. readonly current: number;
  18658. readonly total: number;
  18659. readonly count: number;
  18660. constructor();
  18661. /**
  18662. * Call this method to start monitoring a new frame.
  18663. * 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.
  18664. */
  18665. fetchNewFrame(): void;
  18666. /**
  18667. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  18668. * @param newCount the count value to add to the monitored count
  18669. * @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.
  18670. */
  18671. addCount(newCount: number, fetchResult: boolean): void;
  18672. /**
  18673. * Start monitoring this performance counter
  18674. */
  18675. beginMonitoring(): void;
  18676. /**
  18677. * Compute the time lapsed since the previous beginMonitoring() call.
  18678. * @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
  18679. */
  18680. endMonitoring(newFrame?: boolean): void;
  18681. private _fetchResult();
  18682. private _startMonitoringTime;
  18683. private _min;
  18684. private _max;
  18685. private _average;
  18686. private _current;
  18687. private _totalValueCount;
  18688. private _totalAccumulated;
  18689. private _lastSecAverage;
  18690. private _lastSecAccumulated;
  18691. private _lastSecTime;
  18692. private _lastSecValueCount;
  18693. }
  18694. /**
  18695. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  18696. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  18697. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  18698. * @param name The name of the class, case should be preserved
  18699. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  18700. */
  18701. function className(name: string, module?: string): (target: Object) => void;
  18702. /**
  18703. * An implementation of a loop for asynchronous functions.
  18704. */
  18705. class AsyncLoop {
  18706. iterations: number;
  18707. private _fn;
  18708. private _successCallback;
  18709. index: number;
  18710. private _done;
  18711. /**
  18712. * Constroctor.
  18713. * @param iterations the number of iterations.
  18714. * @param _fn the function to run each iteration
  18715. * @param _successCallback the callback that will be called upon succesful execution
  18716. * @param offset starting offset.
  18717. */
  18718. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  18719. /**
  18720. * Execute the next iteration. Must be called after the last iteration was finished.
  18721. */
  18722. executeNext(): void;
  18723. /**
  18724. * Break the loop and run the success callback.
  18725. */
  18726. breakLoop(): void;
  18727. /**
  18728. * Helper function
  18729. */
  18730. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  18731. /**
  18732. * A for-loop that will run a given number of iterations synchronous and the rest async.
  18733. * @param iterations total number of iterations
  18734. * @param syncedIterations number of synchronous iterations in each async iteration.
  18735. * @param fn the function to call each iteration.
  18736. * @param callback a success call back that will be called when iterating stops.
  18737. * @param breakFunction a break condition (optional)
  18738. * @param timeout timeout settings for the setTimeout function. default - 0.
  18739. * @constructor
  18740. */
  18741. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  18742. }
  18743. }
  18744. declare module BABYLON {
  18745. enum JoystickAxis {
  18746. X = 0,
  18747. Y = 1,
  18748. Z = 2,
  18749. }
  18750. class VirtualJoystick {
  18751. reverseLeftRight: boolean;
  18752. reverseUpDown: boolean;
  18753. deltaPosition: Vector3;
  18754. pressed: boolean;
  18755. private static _globalJoystickIndex;
  18756. private static vjCanvas;
  18757. private static vjCanvasContext;
  18758. private static vjCanvasWidth;
  18759. private static vjCanvasHeight;
  18760. private static halfWidth;
  18761. private _action;
  18762. private _axisTargetedByLeftAndRight;
  18763. private _axisTargetedByUpAndDown;
  18764. private _joystickSensibility;
  18765. private _inversedSensibility;
  18766. private _joystickPointerID;
  18767. private _joystickColor;
  18768. private _joystickPointerPos;
  18769. private _joystickPreviousPointerPos;
  18770. private _joystickPointerStartPos;
  18771. private _deltaJoystickVector;
  18772. private _leftJoystick;
  18773. private _touches;
  18774. private _onPointerDownHandlerRef;
  18775. private _onPointerMoveHandlerRef;
  18776. private _onPointerUpHandlerRef;
  18777. private _onResize;
  18778. constructor(leftJoystick?: boolean);
  18779. setJoystickSensibility(newJoystickSensibility: number): void;
  18780. private _onPointerDown(e);
  18781. private _onPointerMove(e);
  18782. private _onPointerUp(e);
  18783. /**
  18784. * Change the color of the virtual joystick
  18785. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  18786. */
  18787. setJoystickColor(newColor: string): void;
  18788. setActionOnTouch(action: () => any): void;
  18789. setAxisForLeftRight(axis: JoystickAxis): void;
  18790. setAxisForUpDown(axis: JoystickAxis): void;
  18791. private _drawVirtualJoystick();
  18792. releaseCanvas(): void;
  18793. }
  18794. }
  18795. declare module BABYLON {
  18796. class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  18797. readonly name: string;
  18798. private _zoomStopsAnimation;
  18799. private _idleRotationSpeed;
  18800. private _idleRotationWaitTime;
  18801. private _idleRotationSpinupTime;
  18802. /**
  18803. * Gets the flag that indicates if user zooming should stop animation.
  18804. */
  18805. /**
  18806. * Sets the flag that indicates if user zooming should stop animation.
  18807. */
  18808. zoomStopsAnimation: boolean;
  18809. /**
  18810. * Gets the default speed at which the camera rotates around the model.
  18811. */
  18812. /**
  18813. * Sets the default speed at which the camera rotates around the model.
  18814. */
  18815. idleRotationSpeed: number;
  18816. /**
  18817. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  18818. */
  18819. /**
  18820. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  18821. */
  18822. idleRotationWaitTime: number;
  18823. /**
  18824. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  18825. */
  18826. /**
  18827. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  18828. */
  18829. idleRotationSpinupTime: number;
  18830. /**
  18831. * Gets a value indicating if the camera is currently rotating because of this behavior
  18832. */
  18833. readonly rotationInProgress: boolean;
  18834. private _onPrePointerObservableObserver;
  18835. private _onAfterCheckInputsObserver;
  18836. private _attachedCamera;
  18837. private _isPointerDown;
  18838. private _lastFrameTime;
  18839. private _lastInteractionTime;
  18840. private _cameraRotationSpeed;
  18841. init(): void;
  18842. attach(camera: ArcRotateCamera): void;
  18843. detach(): void;
  18844. /**
  18845. * Returns true if user is scrolling.
  18846. * @return true if user is scrolling.
  18847. */
  18848. private _userIsZooming();
  18849. private _lastFrameRadius;
  18850. private _shouldAnimationStopForInteraction();
  18851. /**
  18852. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  18853. */
  18854. private _applyUserInteraction();
  18855. private _userIsMoving();
  18856. }
  18857. }
  18858. declare module BABYLON {
  18859. /**
  18860. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  18861. */
  18862. class BouncingBehavior implements Behavior<ArcRotateCamera> {
  18863. readonly name: string;
  18864. /**
  18865. * The easing function used by animations
  18866. */
  18867. static EasingFunction: BackEase;
  18868. /**
  18869. * The easing mode used by animations
  18870. */
  18871. static EasingMode: number;
  18872. /**
  18873. * The duration of the animation, in milliseconds
  18874. */
  18875. transitionDuration: number;
  18876. /**
  18877. * Length of the distance animated by the transition when lower radius is reached
  18878. */
  18879. lowerRadiusTransitionRange: number;
  18880. /**
  18881. * Length of the distance animated by the transition when upper radius is reached
  18882. */
  18883. upperRadiusTransitionRange: number;
  18884. private _autoTransitionRange;
  18885. /**
  18886. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  18887. */
  18888. /**
  18889. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  18890. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  18891. */
  18892. autoTransitionRange: boolean;
  18893. private _attachedCamera;
  18894. private _onAfterCheckInputsObserver;
  18895. private _onMeshTargetChangedObserver;
  18896. init(): void;
  18897. attach(camera: ArcRotateCamera): void;
  18898. detach(): void;
  18899. private _radiusIsAnimating;
  18900. private _radiusBounceTransition;
  18901. private _animatables;
  18902. private _cachedWheelPrecision;
  18903. /**
  18904. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  18905. * @param radiusLimit The limit to check against.
  18906. * @return Bool to indicate if at limit.
  18907. */
  18908. private _isRadiusAtLimit(radiusLimit);
  18909. /**
  18910. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  18911. * @param radiusDelta The delta by which to animate to. Can be negative.
  18912. */
  18913. private _applyBoundRadiusAnimation(radiusDelta);
  18914. /**
  18915. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  18916. */
  18917. protected _clearAnimationLocks(): void;
  18918. /**
  18919. * Stops and removes all animations that have been applied to the camera
  18920. */
  18921. stopAllAnimations(): void;
  18922. }
  18923. }
  18924. declare module BABYLON {
  18925. class FramingBehavior implements Behavior<ArcRotateCamera> {
  18926. readonly name: string;
  18927. private _mode;
  18928. private _radiusScale;
  18929. private _positionScale;
  18930. private _defaultElevation;
  18931. private _elevationReturnTime;
  18932. private _elevationReturnWaitTime;
  18933. private _zoomStopsAnimation;
  18934. private _framingTime;
  18935. /**
  18936. * The easing function used by animations
  18937. */
  18938. static EasingFunction: ExponentialEase;
  18939. /**
  18940. * The easing mode used by animations
  18941. */
  18942. static EasingMode: number;
  18943. /**
  18944. * Gets current mode used by the behavior.
  18945. */
  18946. /**
  18947. * Sets the current mode used by the behavior
  18948. */
  18949. mode: number;
  18950. /**
  18951. * Gets the scale applied to the radius
  18952. */
  18953. /**
  18954. * Sets the scale applied to the radius (1 by default)
  18955. */
  18956. radiusScale: number;
  18957. /**
  18958. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  18959. */
  18960. /**
  18961. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  18962. */
  18963. positionScale: number;
  18964. /**
  18965. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  18966. * behaviour is triggered, in radians.
  18967. */
  18968. /**
  18969. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  18970. * behaviour is triggered, in radians.
  18971. */
  18972. defaultElevation: number;
  18973. /**
  18974. * Gets the time (in milliseconds) taken to return to the default beta position.
  18975. * Negative value indicates camera should not return to default.
  18976. */
  18977. /**
  18978. * Sets the time (in milliseconds) taken to return to the default beta position.
  18979. * Negative value indicates camera should not return to default.
  18980. */
  18981. elevationReturnTime: number;
  18982. /**
  18983. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  18984. */
  18985. /**
  18986. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  18987. */
  18988. elevationReturnWaitTime: number;
  18989. /**
  18990. * Gets the flag that indicates if user zooming should stop animation.
  18991. */
  18992. /**
  18993. * Sets the flag that indicates if user zooming should stop animation.
  18994. */
  18995. zoomStopsAnimation: boolean;
  18996. /**
  18997. * Gets the transition time when framing the mesh, in milliseconds
  18998. */
  18999. /**
  19000. * Sets the transition time when framing the mesh, in milliseconds
  19001. */
  19002. framingTime: number;
  19003. private _onPrePointerObservableObserver;
  19004. private _onAfterCheckInputsObserver;
  19005. private _onMeshTargetChangedObserver;
  19006. private _attachedCamera;
  19007. private _isPointerDown;
  19008. private _lastInteractionTime;
  19009. init(): void;
  19010. attach(camera: ArcRotateCamera): void;
  19011. detach(): void;
  19012. private _animatables;
  19013. private _betaIsAnimating;
  19014. private _betaTransition;
  19015. private _radiusTransition;
  19016. private _vectorTransition;
  19017. /**
  19018. * Targets the given mesh and updates zoom level accordingly.
  19019. * @param mesh The mesh to target.
  19020. * @param radius Optional. If a cached radius position already exists, overrides default.
  19021. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  19022. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  19023. * @param onAnimationEnd Callback triggered at the end of the framing animation
  19024. */
  19025. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  19026. /**
  19027. * Targets the given mesh with its children and updates zoom level accordingly.
  19028. * @param mesh The mesh to target.
  19029. * @param radius Optional. If a cached radius position already exists, overrides default.
  19030. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  19031. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  19032. * @param onAnimationEnd Callback triggered at the end of the framing animation
  19033. */
  19034. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  19035. /**
  19036. * Targets the given meshes with their children and updates zoom level accordingly.
  19037. * @param meshes The mesh to target.
  19038. * @param radius Optional. If a cached radius position already exists, overrides default.
  19039. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  19040. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  19041. * @param onAnimationEnd Callback triggered at the end of the framing animation
  19042. */
  19043. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  19044. /**
  19045. * Targets the given mesh and updates zoom level accordingly.
  19046. * @param mesh The mesh to target.
  19047. * @param radius Optional. If a cached radius position already exists, overrides default.
  19048. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  19049. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  19050. * @param onAnimationEnd Callback triggered at the end of the framing animation
  19051. */
  19052. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  19053. /**
  19054. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  19055. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  19056. * frustum width.
  19057. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  19058. * to fully enclose the mesh in the viewing frustum.
  19059. */
  19060. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  19061. /**
  19062. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  19063. * is automatically returned to its default position (expected to be above ground plane).
  19064. */
  19065. private _maintainCameraAboveGround();
  19066. /**
  19067. * Returns the frustum slope based on the canvas ratio and camera FOV
  19068. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  19069. */
  19070. private _getFrustumSlope();
  19071. /**
  19072. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  19073. */
  19074. private _clearAnimationLocks();
  19075. /**
  19076. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  19077. */
  19078. private _applyUserInteraction();
  19079. /**
  19080. * Stops and removes all animations that have been applied to the camera
  19081. */
  19082. stopAllAnimations(): void;
  19083. /**
  19084. * Gets a value indicating if the user is moving the camera
  19085. */
  19086. readonly isUserIsMoving: boolean;
  19087. /**
  19088. * The camera can move all the way towards the mesh.
  19089. */
  19090. static IgnoreBoundsSizeMode: number;
  19091. /**
  19092. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  19093. */
  19094. static FitFrustumSidesMode: number;
  19095. }
  19096. }
  19097. declare module BABYLON {
  19098. class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  19099. camera: ArcRotateCamera;
  19100. gamepad: Nullable<Gamepad>;
  19101. private _onGamepadConnectedObserver;
  19102. private _onGamepadDisconnectedObserver;
  19103. gamepadRotationSensibility: number;
  19104. gamepadMoveSensibility: number;
  19105. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19106. detachControl(element: Nullable<HTMLElement>): void;
  19107. checkInputs(): void;
  19108. getClassName(): string;
  19109. getSimpleName(): string;
  19110. }
  19111. }
  19112. declare module BABYLON {
  19113. class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  19114. camera: ArcRotateCamera;
  19115. private _keys;
  19116. keysUp: number[];
  19117. keysDown: number[];
  19118. keysLeft: number[];
  19119. keysRight: number[];
  19120. keysReset: number[];
  19121. panningSensibility: number;
  19122. zoomingSensibility: number;
  19123. useAltToZoom: boolean;
  19124. private _ctrlPressed;
  19125. private _altPressed;
  19126. private _onCanvasBlurObserver;
  19127. private _onKeyboardObserver;
  19128. private _engine;
  19129. private _scene;
  19130. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19131. detachControl(element: Nullable<HTMLElement>): void;
  19132. checkInputs(): void;
  19133. getClassName(): string;
  19134. getSimpleName(): string;
  19135. }
  19136. }
  19137. declare module BABYLON {
  19138. class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  19139. camera: ArcRotateCamera;
  19140. private _wheel;
  19141. private _observer;
  19142. wheelPrecision: number;
  19143. /**
  19144. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  19145. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  19146. */
  19147. wheelDeltaPercentage: number;
  19148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19149. detachControl(element: Nullable<HTMLElement>): void;
  19150. getClassName(): string;
  19151. getSimpleName(): string;
  19152. }
  19153. }
  19154. declare module BABYLON {
  19155. class ArcRotateCameraPointersInput implements ICameraInput<ArcRotateCamera> {
  19156. camera: ArcRotateCamera;
  19157. buttons: number[];
  19158. angularSensibilityX: number;
  19159. angularSensibilityY: number;
  19160. pinchPrecision: number;
  19161. /**
  19162. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  19163. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19164. */
  19165. pinchDeltaPercentage: number;
  19166. panningSensibility: number;
  19167. multiTouchPanning: boolean;
  19168. multiTouchPanAndZoom: boolean;
  19169. private _isPanClick;
  19170. pinchInwards: boolean;
  19171. private _pointerInput;
  19172. private _observer;
  19173. private _onMouseMove;
  19174. private _onGestureStart;
  19175. private _onGesture;
  19176. private _MSGestureHandler;
  19177. private _onLostFocus;
  19178. private _onContextMenu;
  19179. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19180. detachControl(element: Nullable<HTMLElement>): void;
  19181. getClassName(): string;
  19182. getSimpleName(): string;
  19183. }
  19184. }
  19185. declare module BABYLON {
  19186. class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  19187. camera: ArcRotateCamera;
  19188. alphaCorrection: number;
  19189. betaCorrection: number;
  19190. gammaCorrection: number;
  19191. private _alpha;
  19192. private _gamma;
  19193. private _dirty;
  19194. private _deviceOrientationHandler;
  19195. constructor();
  19196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19197. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  19198. checkInputs(): void;
  19199. detachControl(element: Nullable<HTMLElement>): void;
  19200. getClassName(): string;
  19201. getSimpleName(): string;
  19202. }
  19203. }
  19204. declare module BABYLON {
  19205. class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  19206. private _camera;
  19207. private _screenOrientationAngle;
  19208. private _constantTranform;
  19209. private _screenQuaternion;
  19210. private _alpha;
  19211. private _beta;
  19212. private _gamma;
  19213. constructor();
  19214. camera: FreeCamera;
  19215. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19216. private _orientationChanged;
  19217. private _deviceOrientation;
  19218. detachControl(element: Nullable<HTMLElement>): void;
  19219. checkInputs(): void;
  19220. getClassName(): string;
  19221. getSimpleName(): string;
  19222. }
  19223. }
  19224. declare module BABYLON {
  19225. class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  19226. camera: FreeCamera;
  19227. gamepad: Nullable<Gamepad>;
  19228. private _onGamepadConnectedObserver;
  19229. private _onGamepadDisconnectedObserver;
  19230. gamepadAngularSensibility: number;
  19231. gamepadMoveSensibility: number;
  19232. private _cameraTransform;
  19233. private _deltaTransform;
  19234. private _vector3;
  19235. private _vector2;
  19236. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19237. detachControl(element: Nullable<HTMLElement>): void;
  19238. checkInputs(): void;
  19239. getClassName(): string;
  19240. getSimpleName(): string;
  19241. }
  19242. }
  19243. declare module BABYLON {
  19244. class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19245. camera: FreeCamera;
  19246. private _keys;
  19247. private _onCanvasBlurObserver;
  19248. private _onKeyboardObserver;
  19249. private _engine;
  19250. private _scene;
  19251. keysUp: number[];
  19252. keysDown: number[];
  19253. keysLeft: number[];
  19254. keysRight: number[];
  19255. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19256. detachControl(element: Nullable<HTMLElement>): void;
  19257. checkInputs(): void;
  19258. getClassName(): string;
  19259. _onLostFocus(e: FocusEvent): void;
  19260. getSimpleName(): string;
  19261. }
  19262. }
  19263. declare module BABYLON {
  19264. class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19265. touchEnabled: boolean;
  19266. camera: FreeCamera;
  19267. buttons: number[];
  19268. angularSensibility: number;
  19269. private _pointerInput;
  19270. private _onMouseMove;
  19271. private _observer;
  19272. private previousPosition;
  19273. constructor(touchEnabled?: boolean);
  19274. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19275. detachControl(element: Nullable<HTMLElement>): void;
  19276. getClassName(): string;
  19277. getSimpleName(): string;
  19278. }
  19279. }
  19280. declare module BABYLON {
  19281. class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19282. camera: FreeCamera;
  19283. private _offsetX;
  19284. private _offsetY;
  19285. private _pointerPressed;
  19286. private _pointerInput;
  19287. private _observer;
  19288. private _onLostFocus;
  19289. touchAngularSensibility: number;
  19290. touchMoveSensibility: number;
  19291. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19292. detachControl(element: Nullable<HTMLElement>): void;
  19293. checkInputs(): void;
  19294. getClassName(): string;
  19295. getSimpleName(): string;
  19296. }
  19297. }
  19298. declare module BABYLON {
  19299. class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  19300. camera: FreeCamera;
  19301. private _leftjoystick;
  19302. private _rightjoystick;
  19303. getLeftJoystick(): VirtualJoystick;
  19304. getRightJoystick(): VirtualJoystick;
  19305. checkInputs(): void;
  19306. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19307. detachControl(element: Nullable<HTMLElement>): void;
  19308. getClassName(): string;
  19309. getSimpleName(): string;
  19310. }
  19311. }
  19312. declare module BABYLON {
  19313. class VRCameraMetrics {
  19314. hResolution: number;
  19315. vResolution: number;
  19316. hScreenSize: number;
  19317. vScreenSize: number;
  19318. vScreenCenter: number;
  19319. eyeToScreenDistance: number;
  19320. lensSeparationDistance: number;
  19321. interpupillaryDistance: number;
  19322. distortionK: number[];
  19323. chromaAbCorrection: number[];
  19324. postProcessScaleFactor: number;
  19325. lensCenterOffset: number;
  19326. compensateDistortion: boolean;
  19327. readonly aspectRatio: number;
  19328. readonly aspectRatioFov: number;
  19329. readonly leftHMatrix: Matrix;
  19330. readonly rightHMatrix: Matrix;
  19331. readonly leftPreViewMatrix: Matrix;
  19332. readonly rightPreViewMatrix: Matrix;
  19333. static GetDefault(): VRCameraMetrics;
  19334. }
  19335. }
  19336. declare module BABYLON {
  19337. class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  19338. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  19339. getClassName(): string;
  19340. }
  19341. class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  19342. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  19343. getClassName(): string;
  19344. }
  19345. class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  19346. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  19347. getClassName(): string;
  19348. }
  19349. }
  19350. declare module BABYLON {
  19351. interface VRTeleportationOptions {
  19352. floorMeshName?: string;
  19353. floorMeshes?: Mesh[];
  19354. }
  19355. interface VRExperienceHelperOptions extends WebVROptions {
  19356. createDeviceOrientationCamera?: boolean;
  19357. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  19358. }
  19359. class VRExperienceHelper {
  19360. webVROptions: VRExperienceHelperOptions;
  19361. private _scene;
  19362. private _position;
  19363. private _btnVR;
  19364. private _btnVRDisplayed;
  19365. private _webVRsupported;
  19366. private _webVRready;
  19367. private _webVRrequesting;
  19368. private _webVRpresenting;
  19369. private _fullscreenVRpresenting;
  19370. private _canvas;
  19371. private _webVRCamera;
  19372. private _vrDeviceOrientationCamera;
  19373. private _deviceOrientationCamera;
  19374. private _existingCamera;
  19375. private _onKeyDown;
  19376. private _onVrDisplayPresentChange;
  19377. private _onVRDisplayChanged;
  19378. private _onVRRequestPresentStart;
  19379. private _onVRRequestPresentComplete;
  19380. /**
  19381. * Observable raised when entering VR.
  19382. */
  19383. onEnteringVRObservable: Observable<VRExperienceHelper>;
  19384. /**
  19385. * Observable raised when exiting VR.
  19386. */
  19387. onExitingVRObservable: Observable<VRExperienceHelper>;
  19388. /**
  19389. * Observable raised when controller mesh is loaded.
  19390. */
  19391. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19392. /** Return this.onEnteringVRObservable
  19393. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  19394. */
  19395. readonly onEnteringVR: Observable<VRExperienceHelper>;
  19396. /** Return this.onExitingVRObservable
  19397. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  19398. */
  19399. readonly onExitingVR: Observable<VRExperienceHelper>;
  19400. /** Return this.onControllerMeshLoadedObservable
  19401. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  19402. */
  19403. readonly onControllerMeshLoaded: Observable<WebVRController>;
  19404. private _rayLength;
  19405. private _useCustomVRButton;
  19406. private _teleportationRequested;
  19407. private _teleportationEnabledOnLeftController;
  19408. private _teleportationEnabledOnRightController;
  19409. private _interactionsEnabledOnLeftController;
  19410. private _interactionsEnabledOnRightController;
  19411. private _leftControllerReady;
  19412. private _rightControllerReady;
  19413. private _floorMeshName;
  19414. private _floorMeshesCollection;
  19415. private _teleportationAllowed;
  19416. private _rotationAllowed;
  19417. private _teleportationRequestInitiated;
  19418. private _teleportationBackRequestInitiated;
  19419. private teleportBackwardsVector;
  19420. private _rotationRightAsked;
  19421. private _rotationLeftAsked;
  19422. private _teleportationTarget;
  19423. private _isDefaultTeleportationTarget;
  19424. private _postProcessMove;
  19425. private _passProcessMove;
  19426. private _teleportationFillColor;
  19427. private _teleportationBorderColor;
  19428. private _rotationAngle;
  19429. private _haloCenter;
  19430. private _gazeTracker;
  19431. private _padSensibilityUp;
  19432. private _padSensibilityDown;
  19433. private _leftLaserPointer;
  19434. private _rightLaserPointer;
  19435. private _currentMeshSelected;
  19436. /**
  19437. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  19438. */
  19439. onNewMeshSelected: Observable<AbstractMesh>;
  19440. /**
  19441. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  19442. */
  19443. onNewMeshPicked: Observable<PickingInfo>;
  19444. private _circleEase;
  19445. /**
  19446. * Observable raised before camera teleportation
  19447. */
  19448. onBeforeCameraTeleport: Observable<Vector3>;
  19449. /**
  19450. * Observable raised after camera teleportation
  19451. */
  19452. onAfterCameraTeleport: Observable<Vector3>;
  19453. /**
  19454. * Observable raised when current selected mesh gets unselected
  19455. */
  19456. onSelectedMeshUnselected: Observable<AbstractMesh>;
  19457. private _raySelectionPredicate;
  19458. /**
  19459. * To be optionaly changed by user to define custom ray selection
  19460. */
  19461. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  19462. /**
  19463. * To be optionaly changed by user to define custom selection logic (after ray selection)
  19464. */
  19465. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  19466. /**
  19467. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  19468. */
  19469. teleportationEnabled: boolean;
  19470. private _currentHit;
  19471. private _pointerDownOnMeshAsked;
  19472. private _isActionableMesh;
  19473. private _defaultHeight;
  19474. private _teleportationInitialized;
  19475. private _interactionsEnabled;
  19476. private _interactionsRequested;
  19477. private _displayGaze;
  19478. private _displayLaserPointer;
  19479. private _dpadPressed;
  19480. teleportationTarget: Mesh;
  19481. displayGaze: boolean;
  19482. displayLaserPointer: boolean;
  19483. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  19484. readonly currentVRCamera: Nullable<Camera>;
  19485. readonly webVRCamera: WebVRFreeCamera;
  19486. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  19487. constructor(scene: Scene, webVROptions?: VRExperienceHelperOptions);
  19488. private _onDefaultMeshLoaded(webVRController);
  19489. private _onResize;
  19490. private _onFullscreenChange;
  19491. /**
  19492. * Gets a value indicating if we are currently in VR mode.
  19493. */
  19494. readonly isInVRMode: boolean;
  19495. private onVrDisplayPresentChange();
  19496. private onVRDisplayChanged(eventArgs);
  19497. private moveButtonToBottomRight();
  19498. private displayVRButton();
  19499. private updateButtonVisibility();
  19500. /**
  19501. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  19502. * Otherwise, will use the fullscreen API.
  19503. */
  19504. enterVR(): void;
  19505. /**
  19506. * Attempt to exit VR, or fullscreen.
  19507. */
  19508. exitVR(): void;
  19509. position: Vector3;
  19510. enableInteractions(): void;
  19511. private beforeRender;
  19512. private _isTeleportationFloor(mesh);
  19513. addFloorMesh(floorMesh: Mesh): void;
  19514. removeFloorMesh(floorMesh: Mesh): void;
  19515. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  19516. private _onNewGamepadConnected;
  19517. private _tryEnableInteractionOnController;
  19518. private _onNewGamepadDisconnected;
  19519. private _enableInteractionOnController(webVRController);
  19520. private _checkTeleportWithRay(stateObject, webVRController?);
  19521. private _selectionPointerDown();
  19522. private _selectionPointerUp();
  19523. private _checkRotate(stateObject);
  19524. private _checkTeleportBackwards(stateObject);
  19525. private _enableTeleportationOnController(webVRController);
  19526. private _createGazeTracker();
  19527. private _createTeleportationCircles();
  19528. private _displayTeleportationTarget();
  19529. private _hideTeleportationTarget();
  19530. private _rotateCamera(right);
  19531. private _moveTeleportationSelectorTo(hit);
  19532. private _workingVector;
  19533. private _workingQuaternion;
  19534. private _workingMatrix;
  19535. private _teleportCamera(location?);
  19536. private _castRayAndSelectObject();
  19537. changeLaserColor(color: Color3): void;
  19538. changeGazeColor(color: Color3): void;
  19539. dispose(): void;
  19540. getClassName(): string;
  19541. }
  19542. }
  19543. declare var HMDVRDevice: any;
  19544. declare var VRDisplay: any;
  19545. declare var VRFrameData: any;
  19546. declare module BABYLON {
  19547. /**
  19548. * This is a copy of VRPose.
  19549. * IMPORTANT!! The data is right-hand data.
  19550. * @export
  19551. * @interface DevicePose
  19552. */
  19553. interface DevicePose {
  19554. readonly position?: Float32Array;
  19555. readonly linearVelocity?: Float32Array;
  19556. readonly linearAcceleration?: Float32Array;
  19557. readonly orientation?: Float32Array;
  19558. readonly angularVelocity?: Float32Array;
  19559. readonly angularAcceleration?: Float32Array;
  19560. }
  19561. interface PoseControlled {
  19562. position: Vector3;
  19563. rotationQuaternion: Quaternion;
  19564. devicePosition?: Vector3;
  19565. deviceRotationQuaternion: Quaternion;
  19566. rawPose: Nullable<DevicePose>;
  19567. deviceScaleFactor: number;
  19568. updateFromDevice(poseData: DevicePose): void;
  19569. }
  19570. interface WebVROptions {
  19571. trackPosition?: boolean;
  19572. positionScale?: number;
  19573. displayName?: string;
  19574. controllerMeshes?: boolean;
  19575. defaultLightingOnControllers?: boolean;
  19576. useCustomVRButton?: boolean;
  19577. customVRButton?: HTMLButtonElement;
  19578. rayLength?: number;
  19579. defaultHeight?: number;
  19580. }
  19581. class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  19582. private webVROptions;
  19583. _vrDevice: any;
  19584. rawPose: Nullable<DevicePose>;
  19585. private _onVREnabled;
  19586. private _specsVersion;
  19587. private _attached;
  19588. private _frameData;
  19589. protected _descendants: Array<Node>;
  19590. private _deviceRoomPosition;
  19591. private _deviceRoomRotationQuaternion;
  19592. private _standingMatrix;
  19593. devicePosition: Vector3;
  19594. deviceRotationQuaternion: Quaternion;
  19595. deviceScaleFactor: number;
  19596. private _deviceToWorld;
  19597. private _worldToDevice;
  19598. controllers: Array<WebVRController>;
  19599. onControllersAttachedObservable: Observable<WebVRController[]>;
  19600. onControllerMeshLoadedObservable: Observable<WebVRController>;
  19601. rigParenting: boolean;
  19602. private _lightOnControllers;
  19603. private _defaultHeight;
  19604. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  19605. deviceDistanceToRoomGround: () => number;
  19606. useStandingMatrix: (callback?: (bool: boolean) => void) => void;
  19607. dispose(): void;
  19608. getControllerByName(name: string): Nullable<WebVRController>;
  19609. private _leftController;
  19610. readonly leftController: Nullable<WebVRController>;
  19611. private _rightController;
  19612. readonly rightController: Nullable<WebVRController>;
  19613. getForwardRay(length?: number): Ray;
  19614. _checkInputs(): void;
  19615. updateFromDevice(poseData: DevicePose): void;
  19616. /**
  19617. * WebVR's attach control will start broadcasting frames to the device.
  19618. * Note that in certain browsers (chrome for example) this function must be called
  19619. * within a user-interaction callback. Example:
  19620. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  19621. *
  19622. * @param {HTMLElement} element
  19623. * @param {boolean} [noPreventDefault]
  19624. *
  19625. * @memberOf WebVRFreeCamera
  19626. */
  19627. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19628. detachControl(element: HTMLElement): void;
  19629. getClassName(): string;
  19630. resetToCurrentRotation(): void;
  19631. _updateRigCameras(): void;
  19632. private _workingVector;
  19633. private _oneVector;
  19634. private _workingMatrix;
  19635. private updateCacheCalled;
  19636. _updateCache(ignoreParentClass?: boolean): void;
  19637. update(): void;
  19638. _getViewMatrix(): Matrix;
  19639. /**
  19640. * This function is called by the two RIG cameras.
  19641. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  19642. */
  19643. protected _getWebVRViewMatrix(): Matrix;
  19644. protected _getWebVRProjectionMatrix(): Matrix;
  19645. private _onGamepadConnectedObserver;
  19646. private _onGamepadDisconnectedObserver;
  19647. initControllers(): void;
  19648. }
  19649. }
  19650. declare module BABYLON {
  19651. interface IOctreeContainer<T> {
  19652. blocks: Array<OctreeBlock<T>>;
  19653. }
  19654. class Octree<T> {
  19655. maxDepth: number;
  19656. blocks: Array<OctreeBlock<T>>;
  19657. dynamicContent: T[];
  19658. private _maxBlockCapacity;
  19659. private _selectionContent;
  19660. private _creationFunc;
  19661. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  19662. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  19663. addMesh(entry: T): void;
  19664. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  19665. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  19666. intersectsRay(ray: Ray): SmartArray<T>;
  19667. 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;
  19668. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  19669. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  19670. }
  19671. }
  19672. declare module BABYLON {
  19673. class OctreeBlock<T> {
  19674. entries: T[];
  19675. blocks: Array<OctreeBlock<T>>;
  19676. private _depth;
  19677. private _maxDepth;
  19678. private _capacity;
  19679. private _minPoint;
  19680. private _maxPoint;
  19681. private _boundingVectors;
  19682. private _creationFunc;
  19683. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  19684. readonly capacity: number;
  19685. readonly minPoint: Vector3;
  19686. readonly maxPoint: Vector3;
  19687. addEntry(entry: T): void;
  19688. addEntries(entries: T[]): void;
  19689. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  19690. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  19691. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  19692. createInnerBlocks(): void;
  19693. }
  19694. }
  19695. declare module BABYLON {
  19696. class GearVRController extends WebVRController {
  19697. static MODEL_BASE_URL: string;
  19698. static MODEL_FILENAME: string;
  19699. static readonly GAMEPAD_ID_PREFIX: string;
  19700. private readonly _buttonIndexToObservableNameMap;
  19701. constructor(vrGamepad: any);
  19702. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19703. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19704. }
  19705. }
  19706. declare module BABYLON {
  19707. class GenericController extends WebVRController {
  19708. static readonly MODEL_BASE_URL: string;
  19709. static readonly MODEL_FILENAME: string;
  19710. constructor(vrGamepad: any);
  19711. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19712. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19713. }
  19714. }
  19715. declare module BABYLON {
  19716. class OculusTouchController extends WebVRController {
  19717. static MODEL_BASE_URL: string;
  19718. static MODEL_LEFT_FILENAME: string;
  19719. static MODEL_RIGHT_FILENAME: string;
  19720. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19721. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  19722. constructor(vrGamepad: any);
  19723. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19724. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19725. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19726. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19727. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19728. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19729. }
  19730. }
  19731. declare module BABYLON {
  19732. enum PoseEnabledControllerType {
  19733. VIVE = 0,
  19734. OCULUS = 1,
  19735. WINDOWS = 2,
  19736. GEAR_VR = 3,
  19737. GENERIC = 4,
  19738. }
  19739. interface MutableGamepadButton {
  19740. value: number;
  19741. touched: boolean;
  19742. pressed: boolean;
  19743. }
  19744. interface ExtendedGamepadButton extends GamepadButton {
  19745. readonly pressed: boolean;
  19746. readonly touched: boolean;
  19747. readonly value: number;
  19748. }
  19749. class PoseEnabledControllerHelper {
  19750. static InitiateController(vrGamepad: any): OculusTouchController | WindowsMotionController | ViveController | GearVRController | GenericController;
  19751. }
  19752. class PoseEnabledController extends Gamepad implements PoseControlled {
  19753. private _deviceRoomPosition;
  19754. private _deviceRoomRotationQuaternion;
  19755. devicePosition: Vector3;
  19756. deviceRotationQuaternion: Quaternion;
  19757. deviceScaleFactor: number;
  19758. position: Vector3;
  19759. rotationQuaternion: Quaternion;
  19760. controllerType: PoseEnabledControllerType;
  19761. private _calculatedPosition;
  19762. private _calculatedRotation;
  19763. rawPose: DevicePose;
  19764. _mesh: Nullable<AbstractMesh>;
  19765. private _poseControlledCamera;
  19766. private _leftHandSystemQuaternion;
  19767. _deviceToWorld: Matrix;
  19768. constructor(browserGamepad: any);
  19769. private _workingMatrix;
  19770. update(): void;
  19771. updateFromDevice(poseData: DevicePose): void;
  19772. attachToMesh(mesh: AbstractMesh): void;
  19773. attachToPoseControlledCamera(camera: TargetCamera): void;
  19774. dispose(): void;
  19775. readonly mesh: Nullable<AbstractMesh>;
  19776. getForwardRay(length?: number): Ray;
  19777. }
  19778. }
  19779. declare module BABYLON {
  19780. class ViveController extends WebVRController {
  19781. static MODEL_BASE_URL: string;
  19782. static MODEL_FILENAME: string;
  19783. constructor(vrGamepad: any);
  19784. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19785. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19786. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19787. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19788. /**
  19789. * Vive mapping:
  19790. * 0: touchpad
  19791. * 1: trigger
  19792. * 2: left AND right buttons
  19793. * 3: menu button
  19794. */
  19795. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19796. }
  19797. }
  19798. declare module BABYLON {
  19799. abstract class WebVRController extends PoseEnabledController {
  19800. protected _defaultModel: AbstractMesh;
  19801. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  19802. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19803. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19804. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  19805. onPadValuesChangedObservable: Observable<StickValues>;
  19806. protected _buttons: Array<MutableGamepadButton>;
  19807. private _onButtonStateChange;
  19808. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  19809. pad: StickValues;
  19810. hand: string;
  19811. readonly defaultModel: AbstractMesh;
  19812. constructor(vrGamepad: any);
  19813. update(): void;
  19814. protected abstract handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19815. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  19816. private _setButtonValue(newState, currentState, buttonIndex);
  19817. private _changes;
  19818. private _checkChanges(newState, currentState);
  19819. dispose(): void;
  19820. }
  19821. }
  19822. declare module BABYLON {
  19823. class WindowsMotionController extends WebVRController {
  19824. static MODEL_BASE_URL: string;
  19825. static MODEL_LEFT_FILENAME: string;
  19826. static MODEL_RIGHT_FILENAME: string;
  19827. static readonly GAMEPAD_ID_PREFIX: string;
  19828. private static readonly GAMEPAD_ID_PATTERN;
  19829. private _loadedMeshInfo;
  19830. private readonly _mapping;
  19831. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  19832. onTrackpadValuesChangedObservable: Observable<StickValues>;
  19833. trackpad: StickValues;
  19834. constructor(vrGamepad: any);
  19835. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19836. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19837. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19838. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19839. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  19840. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  19841. /**
  19842. * Called once per frame by the engine.
  19843. */
  19844. update(): void;
  19845. /**
  19846. * Called once for each button that changed state since the last frame
  19847. * @param buttonIdx Which button index changed
  19848. * @param state New state of the button
  19849. * @param changes Which properties on the state changed since last frame
  19850. */
  19851. protected handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  19852. protected lerpButtonTransform(buttonName: string, buttonValue: number): void;
  19853. protected lerpAxisTransform(axis: number, axisValue: number): void;
  19854. /**
  19855. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  19856. * @param scene scene in which to add meshes
  19857. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  19858. */
  19859. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  19860. /**
  19861. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  19862. * can be transformed by button presses and axes values, based on this._mapping.
  19863. *
  19864. * @param scene scene in which the meshes exist
  19865. * @param meshes list of meshes that make up the controller model to process
  19866. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  19867. */
  19868. private processModel(scene, meshes);
  19869. private createMeshInfo(rootNode);
  19870. getForwardRay(length?: number): Ray;
  19871. dispose(): void;
  19872. }
  19873. }
  19874. declare module BABYLON {
  19875. /**
  19876. * Interface to implement to create a shadow generator compatible with BJS.
  19877. */
  19878. interface IShadowGenerator {
  19879. getShadowMap(): Nullable<RenderTargetTexture>;
  19880. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  19881. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  19882. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  19883. bindShadowLight(lightIndex: string, effect: Effect): void;
  19884. getTransformMatrix(): Matrix;
  19885. recreateShadowMap(): void;
  19886. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  19887. useInstances: boolean;
  19888. }>): void;
  19889. serialize(): any;
  19890. dispose(): void;
  19891. }
  19892. class ShadowGenerator implements IShadowGenerator {
  19893. private static _FILTER_NONE;
  19894. private static _FILTER_EXPONENTIALSHADOWMAP;
  19895. private static _FILTER_POISSONSAMPLING;
  19896. private static _FILTER_BLUREXPONENTIALSHADOWMAP;
  19897. private static _FILTER_CLOSEEXPONENTIALSHADOWMAP;
  19898. private static _FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  19899. static readonly FILTER_NONE: number;
  19900. static readonly FILTER_POISSONSAMPLING: number;
  19901. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  19902. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  19903. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  19904. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  19905. private _bias;
  19906. bias: number;
  19907. private _blurBoxOffset;
  19908. blurBoxOffset: number;
  19909. private _blurScale;
  19910. blurScale: number;
  19911. private _blurKernel;
  19912. blurKernel: number;
  19913. private _useKernelBlur;
  19914. useKernelBlur: boolean;
  19915. private _depthScale;
  19916. depthScale: number;
  19917. private _filter;
  19918. filter: number;
  19919. usePoissonSampling: boolean;
  19920. useVarianceShadowMap: boolean;
  19921. useBlurVarianceShadowMap: boolean;
  19922. useExponentialShadowMap: boolean;
  19923. useBlurExponentialShadowMap: boolean;
  19924. useCloseExponentialShadowMap: boolean;
  19925. useBlurCloseExponentialShadowMap: boolean;
  19926. private _darkness;
  19927. /**
  19928. * Returns the darkness value (float).
  19929. */
  19930. getDarkness(): number;
  19931. /**
  19932. * Sets the ShadowGenerator darkness value (float <= 1.0).
  19933. * Returns the ShadowGenerator.
  19934. */
  19935. setDarkness(darkness: number): ShadowGenerator;
  19936. private _transparencyShadow;
  19937. /**
  19938. * Sets the ability to have transparent shadow (boolean).
  19939. * Returns the ShadowGenerator.
  19940. */
  19941. setTransparencyShadow(hasShadow: boolean): ShadowGenerator;
  19942. private _shadowMap;
  19943. private _shadowMap2;
  19944. /**
  19945. * Returns a RenderTargetTexture object : the shadow map texture.
  19946. */
  19947. getShadowMap(): Nullable<RenderTargetTexture>;
  19948. /**
  19949. * Returns the most ready computed shadow map as a RenderTargetTexture object.
  19950. */
  19951. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  19952. /**
  19953. * Helper function to add a mesh and its descendants to the list of shadow casters
  19954. * @param mesh Mesh to add
  19955. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  19956. */
  19957. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  19958. /**
  19959. * Helper function to remove a mesh and its descendants from the list of shadow casters
  19960. * @param mesh Mesh to remove
  19961. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  19962. */
  19963. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  19964. /**
  19965. * Controls the extent to which the shadows fade out at the edge of the frustum
  19966. * Used only by directionals and spots
  19967. */
  19968. frustumEdgeFalloff: number;
  19969. private _light;
  19970. /**
  19971. * Returns the associated light object.
  19972. */
  19973. getLight(): IShadowLight;
  19974. forceBackFacesOnly: boolean;
  19975. private _scene;
  19976. private _lightDirection;
  19977. private _effect;
  19978. private _viewMatrix;
  19979. private _projectionMatrix;
  19980. private _transformMatrix;
  19981. private _cachedPosition;
  19982. private _cachedDirection;
  19983. private _cachedDefines;
  19984. private _currentRenderID;
  19985. private _boxBlurPostprocess;
  19986. private _kernelBlurXPostprocess;
  19987. private _kernelBlurYPostprocess;
  19988. private _blurPostProcesses;
  19989. private _mapSize;
  19990. private _currentFaceIndex;
  19991. private _currentFaceIndexCache;
  19992. private _textureType;
  19993. private _defaultTextureMatrix;
  19994. /**
  19995. * Creates a ShadowGenerator object.
  19996. * A ShadowGenerator is the required tool to use the shadows.
  19997. * Each light casting shadows needs to use its own ShadowGenerator.
  19998. * Required parameters :
  19999. * - `mapSize` (integer): the size of the texture what stores the shadows. Example : 1024.
  20000. * - `light`: the light object generating the shadows.
  20001. * - `useFullFloatFirst`: 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.
  20002. * Documentation : http://doc.babylonjs.com/tutorials/shadows
  20003. */
  20004. constructor(mapSize: number, light: IShadowLight, useFullFloatFirst?: boolean);
  20005. private _initializeGenerator();
  20006. private _initializeShadowMap();
  20007. private _initializeBlurRTTAndPostProcesses();
  20008. private _renderForShadowMap(opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes);
  20009. private _renderSubMeshForShadowMap(subMesh);
  20010. private _applyFilterValues();
  20011. /**
  20012. * Force shader compilation including textures ready check
  20013. */
  20014. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  20015. useInstances: boolean;
  20016. }>): void;
  20017. /**
  20018. * Boolean : true when the ShadowGenerator is finally computed.
  20019. */
  20020. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  20021. /**
  20022. * This creates the defines related to the standard BJS materials.
  20023. */
  20024. prepareDefines(defines: any, lightIndex: number): void;
  20025. /**
  20026. * This binds shadow lights related to the standard BJS materials.
  20027. * It implies the unifroms available on the materials are the standard BJS ones.
  20028. */
  20029. bindShadowLight(lightIndex: string, effect: Effect): void;
  20030. /**
  20031. * Returns a Matrix object : the updated transformation matrix.
  20032. */
  20033. getTransformMatrix(): Matrix;
  20034. recreateShadowMap(): void;
  20035. private _disposeBlurPostProcesses();
  20036. private _disposeRTTandPostProcesses();
  20037. /**
  20038. * Disposes the ShadowGenerator.
  20039. * Returns nothing.
  20040. */
  20041. dispose(): void;
  20042. /**
  20043. * Serializes the ShadowGenerator and returns a serializationObject.
  20044. */
  20045. serialize(): any;
  20046. /**
  20047. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  20048. */
  20049. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  20050. }
  20051. }
  20052. declare module BABYLON {
  20053. }
  20054. declare module BABYLON {
  20055. /**
  20056. * Background material used to create an efficient environement around your scene.
  20057. */
  20058. class BackgroundMaterial extends PushMaterial {
  20059. /**
  20060. * Standard reflectance value at parallel view angle.
  20061. */
  20062. static standardReflectance0: number;
  20063. /**
  20064. * Standard reflectance value at grazing angle.
  20065. */
  20066. static standardReflectance90: number;
  20067. /**
  20068. * Key light Color (multiply against the R channel of the environement texture)
  20069. */
  20070. protected _primaryColor: Color3;
  20071. primaryColor: Color3;
  20072. /**
  20073. * Key light Level (allowing HDR output of the background)
  20074. */
  20075. protected _primaryLevel: float;
  20076. primaryLevel: float;
  20077. /**
  20078. * Secondary light Color (multiply against the G channel of the environement texture)
  20079. */
  20080. protected _secondaryColor: Color3;
  20081. secondaryColor: Color3;
  20082. /**
  20083. * Secondary light Level (allowing HDR output of the background)
  20084. */
  20085. protected _secondaryLevel: float;
  20086. secondaryLevel: float;
  20087. /**
  20088. * Tertiary light Color (multiply against the B channel of the environement texture)
  20089. */
  20090. protected _tertiaryColor: Color3;
  20091. tertiaryColor: Color3;
  20092. /**
  20093. * Tertiary light Level (allowing HDR output of the background)
  20094. */
  20095. protected _tertiaryLevel: float;
  20096. tertiaryLevel: float;
  20097. /**
  20098. * Reflection Texture used in the material.
  20099. * Should be author in a specific way for the best result (refer to the documentation).
  20100. */
  20101. protected _reflectionTexture: Nullable<BaseTexture>;
  20102. reflectionTexture: Nullable<BaseTexture>;
  20103. /**
  20104. * Reflection Texture level of blur.
  20105. *
  20106. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  20107. * texture twice.
  20108. */
  20109. protected _reflectionBlur: float;
  20110. reflectionBlur: float;
  20111. /**
  20112. * Diffuse Texture used in the material.
  20113. * Should be author in a specific way for the best result (refer to the documentation).
  20114. */
  20115. protected _diffuseTexture: Nullable<BaseTexture>;
  20116. diffuseTexture: Nullable<BaseTexture>;
  20117. /**
  20118. * Specify the list of lights casting shadow on the material.
  20119. * All scene shadow lights will be included if null.
  20120. */
  20121. protected _shadowLights: Nullable<IShadowLight[]>;
  20122. shadowLights: Nullable<IShadowLight[]>;
  20123. /**
  20124. * For the lights having a blurred shadow generator, this can add a second blur pass in order to reach
  20125. * soft lighting on the background.
  20126. */
  20127. protected _shadowBlurScale: int;
  20128. shadowBlurScale: int;
  20129. /**
  20130. * Helps adjusting the shadow to a softer level if required.
  20131. * 0 means black shadows and 1 means no shadows.
  20132. */
  20133. protected _shadowLevel: float;
  20134. shadowLevel: float;
  20135. /**
  20136. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  20137. * It is usually zero but might be interesting to modify according to your setup.
  20138. */
  20139. protected _sceneCenter: Vector3;
  20140. sceneCenter: Vector3;
  20141. /**
  20142. * This helps specifying that the material is falling off to the sky box at grazing angle.
  20143. * This helps ensuring a nice transition when the camera goes under the ground.
  20144. */
  20145. protected _opacityFresnel: boolean;
  20146. opacityFresnel: boolean;
  20147. /**
  20148. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  20149. * This helps adding a mirror texture on the ground.
  20150. */
  20151. protected _reflectionFresnel: boolean;
  20152. reflectionFresnel: boolean;
  20153. /**
  20154. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  20155. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  20156. */
  20157. protected _reflectionFalloffDistance: number;
  20158. reflectionFalloffDistance: number;
  20159. /**
  20160. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  20161. */
  20162. protected _reflectionAmount: number;
  20163. reflectionAmount: number;
  20164. /**
  20165. * This specifies the weight of the reflection at grazing angle.
  20166. */
  20167. protected _reflectionReflectance0: number;
  20168. reflectionReflectance0: number;
  20169. /**
  20170. * This specifies the weight of the reflection at a perpendicular point of view.
  20171. */
  20172. protected _reflectionReflectance90: number;
  20173. reflectionReflectance90: number;
  20174. /**
  20175. * Sets the reflection reflectance fresnel values according to the default standard
  20176. * empirically know to work well :-)
  20177. */
  20178. reflectionStandardFresnelWeight: number;
  20179. /**
  20180. * Helps to directly use the maps channels instead of their level.
  20181. */
  20182. protected _useRGBColor: boolean;
  20183. useRGBColor: boolean;
  20184. /**
  20185. * This helps reducing the banding effect that could occur on the background.
  20186. */
  20187. protected _enableNoise: boolean;
  20188. enableNoise: boolean;
  20189. /**
  20190. * Number of Simultaneous lights allowed on the material.
  20191. */
  20192. private _maxSimultaneousLights;
  20193. maxSimultaneousLights: int;
  20194. /**
  20195. * Default configuration related to image processing available in the Background Material.
  20196. */
  20197. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20198. /**
  20199. * Keep track of the image processing observer to allow dispose and replace.
  20200. */
  20201. private _imageProcessingObserver;
  20202. /**
  20203. * Attaches a new image processing configuration to the PBR Material.
  20204. * @param configuration (if null the scene configuration will be use)
  20205. */
  20206. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20207. /**
  20208. * Gets the image processing configuration used either in this material.
  20209. */
  20210. /**
  20211. * Sets the Default image processing configuration used either in the this material.
  20212. *
  20213. * If sets to null, the scene one is in use.
  20214. */
  20215. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  20216. /**
  20217. * Gets wether the color curves effect is enabled.
  20218. */
  20219. /**
  20220. * Sets wether the color curves effect is enabled.
  20221. */
  20222. cameraColorCurvesEnabled: boolean;
  20223. /**
  20224. * Gets wether the color grading effect is enabled.
  20225. */
  20226. /**
  20227. * Gets wether the color grading effect is enabled.
  20228. */
  20229. cameraColorGradingEnabled: boolean;
  20230. /**
  20231. * Gets wether tonemapping is enabled or not.
  20232. */
  20233. /**
  20234. * Sets wether tonemapping is enabled or not
  20235. */
  20236. cameraToneMappingEnabled: boolean;
  20237. /**
  20238. * The camera exposure used on this material.
  20239. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20240. * This corresponds to a photographic exposure.
  20241. */
  20242. /**
  20243. * The camera exposure used on this material.
  20244. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  20245. * This corresponds to a photographic exposure.
  20246. */
  20247. cameraExposure: float;
  20248. /**
  20249. * Gets The camera contrast used on this material.
  20250. */
  20251. /**
  20252. * Sets The camera contrast used on this material.
  20253. */
  20254. cameraContrast: float;
  20255. /**
  20256. * Gets the Color Grading 2D Lookup Texture.
  20257. */
  20258. /**
  20259. * Sets the Color Grading 2D Lookup Texture.
  20260. */
  20261. cameraColorGradingTexture: Nullable<BaseTexture>;
  20262. /**
  20263. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20264. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20265. * 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;
  20266. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20267. */
  20268. /**
  20269. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  20270. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  20271. * 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;
  20272. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  20273. */
  20274. cameraColorCurves: Nullable<ColorCurves>;
  20275. private _renderTargets;
  20276. private _reflectionControls;
  20277. /**
  20278. * constructor
  20279. * @param name The name of the material
  20280. * @param scene The scene to add the material to
  20281. */
  20282. constructor(name: string, scene: Scene);
  20283. /**
  20284. * The entire material has been created in order to prevent overdraw.
  20285. * @returns false
  20286. */
  20287. needAlphaTesting(): boolean;
  20288. /**
  20289. * The entire material has been created in order to prevent overdraw.
  20290. * @returns true if blending is enable
  20291. */
  20292. needAlphaBlending(): boolean;
  20293. /**
  20294. * Checks wether the material is ready to be rendered for a given mesh.
  20295. * @param mesh The mesh to render
  20296. * @param subMesh The submesh to check against
  20297. * @param useInstances Specify wether or not the material is used with instances
  20298. */
  20299. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20300. /**
  20301. * Build the uniform buffer used in the material.
  20302. */
  20303. buildUniformLayout(): void;
  20304. /**
  20305. * Unbind the material.
  20306. */
  20307. unbind(): void;
  20308. /**
  20309. * Bind only the world matrix to the material.
  20310. * @param world The world matrix to bind.
  20311. */
  20312. bindOnlyWorldMatrix(world: Matrix): void;
  20313. /**
  20314. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  20315. * @param world The world matrix to bind.
  20316. * @param subMesh The submesh to bind for.
  20317. */
  20318. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20319. /**
  20320. * Dispose the material.
  20321. * @forceDisposeEffect Force disposal of the associated effect.
  20322. * @forceDisposeTextures Force disposal of the associated textures.
  20323. */
  20324. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20325. /**
  20326. * Clones the material.
  20327. * @name The cloned name.
  20328. * @returns The cloned material.
  20329. */
  20330. clone(name: string): BackgroundMaterial;
  20331. /**
  20332. * Serializes the current material to its JSON representation.
  20333. * @returns The JSON representation.
  20334. */
  20335. serialize(): any;
  20336. /**
  20337. * Gets the class name of the material
  20338. * @returns "BackgroundMaterial"
  20339. */
  20340. getClassName(): string;
  20341. /**
  20342. * Parse a JSON input to create back a background material.
  20343. * @param source
  20344. * @param scene
  20345. * @param rootUrl
  20346. * @returns the instantiated BackgroundMaterial.
  20347. */
  20348. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  20349. }
  20350. }
  20351. declare module BABYLON {
  20352. /**
  20353. * The Physically based material base class of BJS.
  20354. *
  20355. * This offers the main features of a standard PBR material.
  20356. * For more information, please refer to the documentation :
  20357. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  20358. */
  20359. abstract class PBRBaseMaterial extends PushMaterial {
  20360. /**
  20361. * Intensity of the direct lights e.g. the four lights available in your scene.
  20362. * This impacts both the direct diffuse and specular highlights.
  20363. */
  20364. protected _directIntensity: number;
  20365. /**
  20366. * Intensity of the emissive part of the material.
  20367. * This helps controlling the emissive effect without modifying the emissive color.
  20368. */
  20369. protected _emissiveIntensity: number;
  20370. /**
  20371. * Intensity of the environment e.g. how much the environment will light the object
  20372. * either through harmonics for rough material or through the refelction for shiny ones.
  20373. */
  20374. protected _environmentIntensity: number;
  20375. /**
  20376. * This is a special control allowing the reduction of the specular highlights coming from the
  20377. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  20378. */
  20379. protected _specularIntensity: number;
  20380. private _lightingInfos;
  20381. /**
  20382. * Debug Control allowing disabling the bump map on this material.
  20383. */
  20384. protected _disableBumpMap: boolean;
  20385. /**
  20386. * AKA Diffuse Texture in standard nomenclature.
  20387. */
  20388. protected _albedoTexture: BaseTexture;
  20389. /**
  20390. * AKA Occlusion Texture in other nomenclature.
  20391. */
  20392. protected _ambientTexture: BaseTexture;
  20393. /**
  20394. * AKA Occlusion Texture Intensity in other nomenclature.
  20395. */
  20396. protected _ambientTextureStrength: number;
  20397. protected _opacityTexture: BaseTexture;
  20398. protected _reflectionTexture: BaseTexture;
  20399. protected _refractionTexture: BaseTexture;
  20400. protected _emissiveTexture: BaseTexture;
  20401. /**
  20402. * AKA Specular texture in other nomenclature.
  20403. */
  20404. protected _reflectivityTexture: BaseTexture;
  20405. /**
  20406. * Used to switch from specular/glossiness to metallic/roughness workflow.
  20407. */
  20408. protected _metallicTexture: BaseTexture;
  20409. /**
  20410. * Specifies the metallic scalar of the metallic/roughness workflow.
  20411. * Can also be used to scale the metalness values of the metallic texture.
  20412. */
  20413. protected _metallic: number;
  20414. /**
  20415. * Specifies the roughness scalar of the metallic/roughness workflow.
  20416. * Can also be used to scale the roughness values of the metallic texture.
  20417. */
  20418. protected _roughness: number;
  20419. /**
  20420. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  20421. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  20422. */
  20423. protected _microSurfaceTexture: BaseTexture;
  20424. protected _bumpTexture: BaseTexture;
  20425. protected _lightmapTexture: BaseTexture;
  20426. protected _ambientColor: Color3;
  20427. /**
  20428. * AKA Diffuse Color in other nomenclature.
  20429. */
  20430. protected _albedoColor: Color3;
  20431. /**
  20432. * AKA Specular Color in other nomenclature.
  20433. */
  20434. protected _reflectivityColor: Color3;
  20435. protected _reflectionColor: Color3;
  20436. protected _emissiveColor: Color3;
  20437. /**
  20438. * AKA Glossiness in other nomenclature.
  20439. */
  20440. protected _microSurface: number;
  20441. /**
  20442. * source material index of refraction (IOR)' / 'destination material IOR.
  20443. */
  20444. protected _indexOfRefraction: number;
  20445. /**
  20446. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  20447. */
  20448. protected _invertRefractionY: boolean;
  20449. /**
  20450. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20451. * Materials half opaque for instance using refraction could benefit from this control.
  20452. */
  20453. protected _linkRefractionWithTransparency: boolean;
  20454. protected _useLightmapAsShadowmap: boolean;
  20455. /**
  20456. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  20457. * makes the reflect vector face the model (under horizon).
  20458. */
  20459. protected _useHorizonOcclusion: boolean;
  20460. /**
  20461. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  20462. * too much the area relying on ambient texture to define their ambient occlusion.
  20463. */
  20464. protected _useRadianceOcclusion: boolean;
  20465. /**
  20466. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  20467. */
  20468. protected _useAlphaFromAlbedoTexture: boolean;
  20469. /**
  20470. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  20471. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20472. */
  20473. protected _useSpecularOverAlpha: boolean;
  20474. /**
  20475. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  20476. */
  20477. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  20478. /**
  20479. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  20480. */
  20481. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  20482. /**
  20483. * Specifies if the metallic texture contains the roughness information in its green channel.
  20484. */
  20485. protected _useRoughnessFromMetallicTextureGreen: boolean;
  20486. /**
  20487. * Specifies if the metallic texture contains the metallness information in its blue channel.
  20488. */
  20489. protected _useMetallnessFromMetallicTextureBlue: boolean;
  20490. /**
  20491. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  20492. */
  20493. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  20494. /**
  20495. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  20496. */
  20497. protected _useAmbientInGrayScale: boolean;
  20498. /**
  20499. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  20500. * The material will try to infer what glossiness each pixel should be.
  20501. */
  20502. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  20503. /**
  20504. * BJS is using an harcoded light falloff based on a manually sets up range.
  20505. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  20506. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  20507. */
  20508. protected _usePhysicalLightFalloff: boolean;
  20509. /**
  20510. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  20511. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20512. */
  20513. protected _useRadianceOverAlpha: boolean;
  20514. /**
  20515. * Allows using the bump map in parallax mode.
  20516. */
  20517. protected _useParallax: boolean;
  20518. /**
  20519. * Allows using the bump map in parallax occlusion mode.
  20520. */
  20521. protected _useParallaxOcclusion: boolean;
  20522. /**
  20523. * Controls the scale bias of the parallax mode.
  20524. */
  20525. protected _parallaxScaleBias: number;
  20526. /**
  20527. * If sets to true, disables all the lights affecting the material.
  20528. */
  20529. protected _disableLighting: boolean;
  20530. /**
  20531. * Number of Simultaneous lights allowed on the material.
  20532. */
  20533. protected _maxSimultaneousLights: number;
  20534. /**
  20535. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  20536. */
  20537. protected _invertNormalMapX: boolean;
  20538. /**
  20539. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  20540. */
  20541. protected _invertNormalMapY: boolean;
  20542. /**
  20543. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20544. */
  20545. protected _twoSidedLighting: boolean;
  20546. /**
  20547. * Defines the alpha limits in alpha test mode.
  20548. */
  20549. protected _alphaCutOff: number;
  20550. /**
  20551. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  20552. */
  20553. protected _forceAlphaTest: boolean;
  20554. /**
  20555. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  20556. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  20557. */
  20558. protected _useAlphaFresnel: boolean;
  20559. /**
  20560. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  20561. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  20562. */
  20563. protected _useLinearAlphaFresnel: boolean;
  20564. /**
  20565. * The transparency mode of the material.
  20566. */
  20567. protected _transparencyMode: Nullable<number>;
  20568. /**
  20569. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  20570. * from cos thetav and roughness:
  20571. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  20572. */
  20573. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  20574. /**
  20575. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  20576. */
  20577. protected _forceIrradianceInFragment: boolean;
  20578. /**
  20579. * Force normal to face away from face.
  20580. */
  20581. protected _forceNormalForward: boolean;
  20582. /**
  20583. * Force metallic workflow.
  20584. */
  20585. protected _forceMetallicWorkflow: boolean;
  20586. /**
  20587. * Default configuration related to image processing available in the PBR Material.
  20588. */
  20589. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  20590. /**
  20591. * Keep track of the image processing observer to allow dispose and replace.
  20592. */
  20593. private _imageProcessingObserver;
  20594. /**
  20595. * Attaches a new image processing configuration to the PBR Material.
  20596. * @param configuration
  20597. */
  20598. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  20599. private _renderTargets;
  20600. private _globalAmbientColor;
  20601. private _useLogarithmicDepth;
  20602. /**
  20603. * Instantiates a new PBRMaterial instance.
  20604. *
  20605. * @param name The material name
  20606. * @param scene The scene the material will be use in.
  20607. */
  20608. constructor(name: string, scene: Scene);
  20609. getClassName(): string;
  20610. useLogarithmicDepth: boolean;
  20611. /**
  20612. * Gets the current transparency mode.
  20613. */
  20614. /**
  20615. * Sets the transparency mode of the material.
  20616. */
  20617. transparencyMode: Nullable<number>;
  20618. /**
  20619. * Returns true if alpha blending should be disabled.
  20620. */
  20621. private readonly _disableAlphaBlending;
  20622. /**
  20623. * Specifies whether or not this material should be rendered in alpha blend mode.
  20624. */
  20625. needAlphaBlending(): boolean;
  20626. /**
  20627. * Specifies whether or not this material should be rendered in alpha blend mode for the given mesh.
  20628. */
  20629. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  20630. /**
  20631. * Specifies whether or not this material should be rendered in alpha test mode.
  20632. */
  20633. needAlphaTesting(): boolean;
  20634. /**
  20635. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  20636. */
  20637. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  20638. getAlphaTestTexture(): BaseTexture;
  20639. private static _scaledReflectivity;
  20640. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  20641. buildUniformLayout(): void;
  20642. unbind(): void;
  20643. bindOnlyWorldMatrix(world: Matrix): void;
  20644. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  20645. getAnimatables(): IAnimatable[];
  20646. private _getReflectionTexture();
  20647. private _getRefractionTexture();
  20648. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  20649. }
  20650. }
  20651. declare module BABYLON {
  20652. /**
  20653. * The Physically based simple base material of BJS.
  20654. *
  20655. * This enables better naming and convention enforcements on top of the pbrMaterial.
  20656. * It is used as the base class for both the specGloss and metalRough conventions.
  20657. */
  20658. abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  20659. /**
  20660. * Number of Simultaneous lights allowed on the material.
  20661. */
  20662. maxSimultaneousLights: number;
  20663. /**
  20664. * If sets to true, disables all the lights affecting the material.
  20665. */
  20666. disableLighting: boolean;
  20667. /**
  20668. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  20669. */
  20670. environmentTexture: BaseTexture;
  20671. /**
  20672. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20673. */
  20674. invertNormalMapX: boolean;
  20675. /**
  20676. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20677. */
  20678. invertNormalMapY: boolean;
  20679. /**
  20680. * Normal map used in the model.
  20681. */
  20682. normalTexture: BaseTexture;
  20683. /**
  20684. * Emissivie color used to self-illuminate the model.
  20685. */
  20686. emissiveColor: Color3;
  20687. /**
  20688. * Emissivie texture used to self-illuminate the model.
  20689. */
  20690. emissiveTexture: BaseTexture;
  20691. /**
  20692. * Occlusion Channel Strenght.
  20693. */
  20694. occlusionStrength: number;
  20695. /**
  20696. * Occlusion Texture of the material (adding extra occlusion effects).
  20697. */
  20698. occlusionTexture: BaseTexture;
  20699. /**
  20700. * Defines the alpha limits in alpha test mode.
  20701. */
  20702. alphaCutOff: number;
  20703. /**
  20704. * Gets the current double sided mode.
  20705. */
  20706. /**
  20707. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20708. */
  20709. doubleSided: boolean;
  20710. lightmapTexture: BaseTexture;
  20711. useLightmapAsShadowmap: boolean;
  20712. /**
  20713. * Return the active textures of the material.
  20714. */
  20715. getActiveTextures(): BaseTexture[];
  20716. hasTexture(texture: BaseTexture): boolean;
  20717. /**
  20718. * Instantiates a new PBRMaterial instance.
  20719. *
  20720. * @param name The material name
  20721. * @param scene The scene the material will be use in.
  20722. */
  20723. constructor(name: string, scene: Scene);
  20724. getClassName(): string;
  20725. }
  20726. }
  20727. declare module BABYLON {
  20728. /**
  20729. * The Physically based material of BJS.
  20730. *
  20731. * This offers the main features of a standard PBR material.
  20732. * For more information, please refer to the documentation :
  20733. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  20734. */
  20735. class PBRMaterial extends PBRBaseMaterial {
  20736. private static _PBRMATERIAL_OPAQUE;
  20737. /**
  20738. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  20739. */
  20740. static readonly PBRMATERIAL_OPAQUE: number;
  20741. private static _PBRMATERIAL_ALPHATEST;
  20742. /**
  20743. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  20744. */
  20745. static readonly PBRMATERIAL_ALPHATEST: number;
  20746. private static _PBRMATERIAL_ALPHABLEND;
  20747. /**
  20748. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20749. */
  20750. static readonly PBRMATERIAL_ALPHABLEND: number;
  20751. private static _PBRMATERIAL_ALPHATESTANDBLEND;
  20752. /**
  20753. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  20754. * They are also discarded below the alpha cutoff threshold to improve performances.
  20755. */
  20756. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  20757. /**
  20758. * Intensity of the direct lights e.g. the four lights available in your scene.
  20759. * This impacts both the direct diffuse and specular highlights.
  20760. */
  20761. directIntensity: number;
  20762. /**
  20763. * Intensity of the emissive part of the material.
  20764. * This helps controlling the emissive effect without modifying the emissive color.
  20765. */
  20766. emissiveIntensity: number;
  20767. /**
  20768. * Intensity of the environment e.g. how much the environment will light the object
  20769. * either through harmonics for rough material or through the refelction for shiny ones.
  20770. */
  20771. environmentIntensity: number;
  20772. /**
  20773. * This is a special control allowing the reduction of the specular highlights coming from the
  20774. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  20775. */
  20776. specularIntensity: number;
  20777. /**
  20778. * Debug Control allowing disabling the bump map on this material.
  20779. */
  20780. disableBumpMap: boolean;
  20781. /**
  20782. * AKA Diffuse Texture in standard nomenclature.
  20783. */
  20784. albedoTexture: BaseTexture;
  20785. /**
  20786. * AKA Occlusion Texture in other nomenclature.
  20787. */
  20788. ambientTexture: BaseTexture;
  20789. /**
  20790. * AKA Occlusion Texture Intensity in other nomenclature.
  20791. */
  20792. ambientTextureStrength: number;
  20793. opacityTexture: BaseTexture;
  20794. reflectionTexture: Nullable<BaseTexture>;
  20795. emissiveTexture: BaseTexture;
  20796. /**
  20797. * AKA Specular texture in other nomenclature.
  20798. */
  20799. reflectivityTexture: BaseTexture;
  20800. /**
  20801. * Used to switch from specular/glossiness to metallic/roughness workflow.
  20802. */
  20803. metallicTexture: BaseTexture;
  20804. /**
  20805. * Specifies the metallic scalar of the metallic/roughness workflow.
  20806. * Can also be used to scale the metalness values of the metallic texture.
  20807. */
  20808. metallic: number;
  20809. /**
  20810. * Specifies the roughness scalar of the metallic/roughness workflow.
  20811. * Can also be used to scale the roughness values of the metallic texture.
  20812. */
  20813. roughness: number;
  20814. /**
  20815. * Used to enable roughness/glossiness fetch from a separate chanel depending on the current mode.
  20816. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  20817. */
  20818. microSurfaceTexture: BaseTexture;
  20819. bumpTexture: BaseTexture;
  20820. lightmapTexture: BaseTexture;
  20821. refractionTexture: BaseTexture;
  20822. ambientColor: Color3;
  20823. /**
  20824. * AKA Diffuse Color in other nomenclature.
  20825. */
  20826. albedoColor: Color3;
  20827. /**
  20828. * AKA Specular Color in other nomenclature.
  20829. */
  20830. reflectivityColor: Color3;
  20831. reflectionColor: Color3;
  20832. emissiveColor: Color3;
  20833. /**
  20834. * AKA Glossiness in other nomenclature.
  20835. */
  20836. microSurface: number;
  20837. /**
  20838. * source material index of refraction (IOR)' / 'destination material IOR.
  20839. */
  20840. indexOfRefraction: number;
  20841. /**
  20842. * Controls if refraction needs to be inverted on Y. This could be usefull for procedural texture.
  20843. */
  20844. invertRefractionY: boolean;
  20845. /**
  20846. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  20847. * Materials half opaque for instance using refraction could benefit from this control.
  20848. */
  20849. linkRefractionWithTransparency: boolean;
  20850. useLightmapAsShadowmap: boolean;
  20851. /**
  20852. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  20853. */
  20854. useAlphaFromAlbedoTexture: boolean;
  20855. /**
  20856. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  20857. */
  20858. forceAlphaTest: boolean;
  20859. /**
  20860. * Defines the alpha limits in alpha test mode.
  20861. */
  20862. alphaCutOff: number;
  20863. /**
  20864. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  20865. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  20866. */
  20867. useSpecularOverAlpha: boolean;
  20868. /**
  20869. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  20870. */
  20871. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  20872. /**
  20873. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  20874. */
  20875. useRoughnessFromMetallicTextureAlpha: boolean;
  20876. /**
  20877. * Specifies if the metallic texture contains the roughness information in its green channel.
  20878. */
  20879. useRoughnessFromMetallicTextureGreen: boolean;
  20880. /**
  20881. * Specifies if the metallic texture contains the metallness information in its blue channel.
  20882. */
  20883. useMetallnessFromMetallicTextureBlue: boolean;
  20884. /**
  20885. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  20886. */
  20887. useAmbientOcclusionFromMetallicTextureRed: boolean;
  20888. /**
  20889. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  20890. */
  20891. useAmbientInGrayScale: boolean;
  20892. /**
  20893. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  20894. * The material will try to infer what glossiness each pixel should be.
  20895. */
  20896. useAutoMicroSurfaceFromReflectivityMap: boolean;
  20897. /**
  20898. * BJS is using an harcoded light falloff based on a manually sets up range.
  20899. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  20900. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  20901. */
  20902. usePhysicalLightFalloff: boolean;
  20903. /**
  20904. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  20905. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  20906. */
  20907. useRadianceOverAlpha: boolean;
  20908. /**
  20909. * Allows using the bump map in parallax mode.
  20910. */
  20911. useParallax: boolean;
  20912. /**
  20913. * Allows using the bump map in parallax occlusion mode.
  20914. */
  20915. useParallaxOcclusion: boolean;
  20916. /**
  20917. * Controls the scale bias of the parallax mode.
  20918. */
  20919. parallaxScaleBias: number;
  20920. /**
  20921. * If sets to true, disables all the lights affecting the material.
  20922. */
  20923. disableLighting: boolean;
  20924. /**
  20925. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  20926. */
  20927. forceIrradianceInFragment: boolean;
  20928. /**
  20929. * Number of Simultaneous lights allowed on the material.
  20930. */
  20931. maxSimultaneousLights: number;
  20932. /**
  20933. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  20934. */
  20935. invertNormalMapX: boolean;
  20936. /**
  20937. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  20938. */
  20939. invertNormalMapY: boolean;
  20940. /**
  20941. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  20942. */
  20943. twoSidedLighting: boolean;
  20944. /**
  20945. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  20946. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  20947. */
  20948. useAlphaFresnel: boolean;
  20949. /**
  20950. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  20951. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  20952. */
  20953. useLinearAlphaFresnel: boolean;
  20954. /**
  20955. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  20956. * And/Or occlude the blended part.
  20957. */
  20958. environmentBRDFTexture: Nullable<BaseTexture>;
  20959. /**
  20960. * Force normal to face away from face.
  20961. */
  20962. forceNormalForward: boolean;
  20963. /**
  20964. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  20965. * makes the reflect vector face the model (under horizon).
  20966. */
  20967. useHorizonOcclusion: boolean;
  20968. /**
  20969. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  20970. * too much the area relying on ambient texture to define their ambient occlusion.
  20971. */
  20972. useRadianceOcclusion: boolean;
  20973. /**
  20974. * Gets the image processing configuration used either in this material.
  20975. */
  20976. /**
  20977. * Sets the Default image processing configuration used either in the this material.
  20978. *
  20979. * If sets to null, the scene one is in use.
  20980. */
  20981. imageProcessingConfiguration: ImageProcessingConfiguration;
  20982. /**
  20983. * Gets wether the color curves effect is enabled.
  20984. */
  20985. /**
  20986. * Sets wether the color curves effect is enabled.
  20987. */
  20988. cameraColorCurvesEnabled: boolean;
  20989. /**
  20990. * Gets wether the color grading effect is enabled.
  20991. */
  20992. /**
  20993. * Gets wether the color grading effect is enabled.
  20994. */
  20995. cameraColorGradingEnabled: boolean;
  20996. /**
  20997. * Gets wether tonemapping is enabled or not.
  20998. */
  20999. /**
  21000. * Sets wether tonemapping is enabled or not
  21001. */
  21002. cameraToneMappingEnabled: boolean;
  21003. /**
  21004. * The camera exposure used on this material.
  21005. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21006. * This corresponds to a photographic exposure.
  21007. */
  21008. /**
  21009. * The camera exposure used on this material.
  21010. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  21011. * This corresponds to a photographic exposure.
  21012. */
  21013. cameraExposure: number;
  21014. /**
  21015. * Gets The camera contrast used on this material.
  21016. */
  21017. /**
  21018. * Sets The camera contrast used on this material.
  21019. */
  21020. cameraContrast: number;
  21021. /**
  21022. * Gets the Color Grading 2D Lookup Texture.
  21023. */
  21024. /**
  21025. * Sets the Color Grading 2D Lookup Texture.
  21026. */
  21027. cameraColorGradingTexture: Nullable<BaseTexture>;
  21028. /**
  21029. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21030. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21031. * 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;
  21032. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21033. */
  21034. /**
  21035. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  21036. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  21037. * 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;
  21038. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  21039. */
  21040. cameraColorCurves: Nullable<ColorCurves>;
  21041. /**
  21042. * Instantiates a new PBRMaterial instance.
  21043. *
  21044. * @param name The material name
  21045. * @param scene The scene the material will be use in.
  21046. */
  21047. constructor(name: string, scene: Scene);
  21048. getClassName(): string;
  21049. getActiveTextures(): BaseTexture[];
  21050. hasTexture(texture: BaseTexture): boolean;
  21051. clone(name: string): PBRMaterial;
  21052. serialize(): any;
  21053. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  21054. }
  21055. }
  21056. declare module BABYLON {
  21057. /**
  21058. * The PBR material of BJS following the metal roughness convention.
  21059. *
  21060. * This fits to the PBR convention in the GLTF definition:
  21061. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  21062. */
  21063. class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  21064. /**
  21065. * The base color has two different interpretations depending on the value of metalness.
  21066. * When the material is a metal, the base color is the specific measured reflectance value
  21067. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  21068. * of the material.
  21069. */
  21070. baseColor: Color3;
  21071. /**
  21072. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  21073. * well as opacity information in the alpha channel.
  21074. */
  21075. baseTexture: BaseTexture;
  21076. /**
  21077. * Specifies the metallic scalar value of the material.
  21078. * Can also be used to scale the metalness values of the metallic texture.
  21079. */
  21080. metallic: number;
  21081. /**
  21082. * Specifies the roughness scalar value of the material.
  21083. * Can also be used to scale the roughness values of the metallic texture.
  21084. */
  21085. roughness: number;
  21086. /**
  21087. * Texture containing both the metallic value in the B channel and the
  21088. * roughness value in the G channel to keep better precision.
  21089. */
  21090. metallicRoughnessTexture: BaseTexture;
  21091. /**
  21092. * Instantiates a new PBRMetalRoughnessMaterial instance.
  21093. *
  21094. * @param name The material name
  21095. * @param scene The scene the material will be use in.
  21096. */
  21097. constructor(name: string, scene: Scene);
  21098. /**
  21099. * Return the currrent class name of the material.
  21100. */
  21101. getClassName(): string;
  21102. /**
  21103. * Return the active textures of the material.
  21104. */
  21105. getActiveTextures(): BaseTexture[];
  21106. hasTexture(texture: BaseTexture): boolean;
  21107. clone(name: string): PBRMetallicRoughnessMaterial;
  21108. /**
  21109. * Serialize the material to a parsable JSON object.
  21110. */
  21111. serialize(): any;
  21112. /**
  21113. * Parses a JSON object correponding to the serialize function.
  21114. */
  21115. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  21116. }
  21117. }
  21118. declare module BABYLON {
  21119. /**
  21120. * The PBR material of BJS following the specular glossiness convention.
  21121. *
  21122. * This fits to the PBR convention in the GLTF definition:
  21123. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  21124. */
  21125. class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  21126. /**
  21127. * Specifies the diffuse color of the material.
  21128. */
  21129. diffuseColor: Color3;
  21130. /**
  21131. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  21132. * channel.
  21133. */
  21134. diffuseTexture: BaseTexture;
  21135. /**
  21136. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  21137. */
  21138. specularColor: Color3;
  21139. /**
  21140. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  21141. */
  21142. glossiness: number;
  21143. /**
  21144. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  21145. */
  21146. specularGlossinessTexture: BaseTexture;
  21147. /**
  21148. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  21149. *
  21150. * @param name The material name
  21151. * @param scene The scene the material will be use in.
  21152. */
  21153. constructor(name: string, scene: Scene);
  21154. /**
  21155. * Return the currrent class name of the material.
  21156. */
  21157. getClassName(): string;
  21158. /**
  21159. * Return the active textures of the material.
  21160. */
  21161. getActiveTextures(): BaseTexture[];
  21162. hasTexture(texture: BaseTexture): boolean;
  21163. clone(name: string): PBRSpecularGlossinessMaterial;
  21164. /**
  21165. * Serialize the material to a parsable JSON object.
  21166. */
  21167. serialize(): any;
  21168. /**
  21169. * Parses a JSON object correponding to the serialize function.
  21170. */
  21171. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  21172. }
  21173. }
  21174. declare module BABYLON {
  21175. class BaseTexture {
  21176. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  21177. name: string;
  21178. private _hasAlpha;
  21179. hasAlpha: boolean;
  21180. getAlphaFromRGB: boolean;
  21181. level: number;
  21182. coordinatesIndex: number;
  21183. private _coordinatesMode;
  21184. coordinatesMode: number;
  21185. wrapU: number;
  21186. wrapV: number;
  21187. wrapR: number;
  21188. anisotropicFilteringLevel: number;
  21189. isCube: boolean;
  21190. is3D: boolean;
  21191. gammaSpace: boolean;
  21192. invertZ: boolean;
  21193. lodLevelInAlpha: boolean;
  21194. lodGenerationOffset: number;
  21195. lodGenerationScale: number;
  21196. isRenderTarget: boolean;
  21197. readonly uid: string;
  21198. toString(): string;
  21199. getClassName(): string;
  21200. animations: Animation[];
  21201. /**
  21202. * An event triggered when the texture is disposed.
  21203. * @type {BABYLON.Observable}
  21204. */
  21205. onDisposeObservable: Observable<BaseTexture>;
  21206. private _onDisposeObserver;
  21207. onDispose: () => void;
  21208. delayLoadState: number;
  21209. private _scene;
  21210. _texture: Nullable<InternalTexture>;
  21211. private _uid;
  21212. readonly isBlocking: boolean;
  21213. constructor(scene: Nullable<Scene>);
  21214. getScene(): Nullable<Scene>;
  21215. getTextureMatrix(): Matrix;
  21216. getReflectionTextureMatrix(): Matrix;
  21217. getInternalTexture(): Nullable<InternalTexture>;
  21218. isReadyOrNotBlocking(): boolean;
  21219. isReady(): boolean;
  21220. getSize(): ISize;
  21221. getBaseSize(): ISize;
  21222. scale(ratio: number): void;
  21223. readonly canRescale: boolean;
  21224. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number): Nullable<InternalTexture>;
  21225. _rebuild(): void;
  21226. delayLoad(): void;
  21227. clone(): Nullable<BaseTexture>;
  21228. readonly textureType: number;
  21229. readonly textureFormat: number;
  21230. readPixels(faceIndex?: number): Nullable<ArrayBufferView>;
  21231. releaseInternalTexture(): void;
  21232. sphericalPolynomial: Nullable<SphericalPolynomial>;
  21233. readonly _lodTextureHigh: Nullable<BaseTexture>;
  21234. readonly _lodTextureMid: Nullable<BaseTexture>;
  21235. readonly _lodTextureLow: Nullable<BaseTexture>;
  21236. dispose(): void;
  21237. serialize(): any;
  21238. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  21239. }
  21240. }
  21241. declare module BABYLON {
  21242. /**
  21243. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  21244. * It can help converting any input color in a desired output one. This can then be used to create effects
  21245. * from sepia, black and white to sixties or futuristic rendering...
  21246. *
  21247. * The only supported format is currently 3dl.
  21248. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table/
  21249. */
  21250. class ColorGradingTexture extends BaseTexture {
  21251. /**
  21252. * The current texture matrix. (will always be identity in color grading texture)
  21253. */
  21254. private _textureMatrix;
  21255. /**
  21256. * The texture URL.
  21257. */
  21258. url: string;
  21259. /**
  21260. * Empty line regex stored for GC.
  21261. */
  21262. private static _noneEmptyLineRegex;
  21263. private _engine;
  21264. /**
  21265. * Instantiates a ColorGradingTexture from the following parameters.
  21266. *
  21267. * @param url The location of the color gradind data (currently only supporting 3dl)
  21268. * @param scene The scene the texture will be used in
  21269. */
  21270. constructor(url: string, scene: Scene);
  21271. /**
  21272. * Returns the texture matrix used in most of the material.
  21273. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  21274. */
  21275. getTextureMatrix(): Matrix;
  21276. /**
  21277. * Occurs when the file being loaded is a .3dl LUT file.
  21278. */
  21279. private load3dlTexture();
  21280. /**
  21281. * Starts the loading process of the texture.
  21282. */
  21283. private loadTexture();
  21284. /**
  21285. * Clones the color gradind texture.
  21286. */
  21287. clone(): ColorGradingTexture;
  21288. /**
  21289. * Called during delayed load for textures.
  21290. */
  21291. delayLoad(): void;
  21292. /**
  21293. * Parses a color grading texture serialized by Babylon.
  21294. * @param parsedTexture The texture information being parsedTexture
  21295. * @param scene The scene to load the texture in
  21296. * @param rootUrl The root url of the data assets to load
  21297. * @return A color gradind texture
  21298. */
  21299. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<ColorGradingTexture>;
  21300. /**
  21301. * Serializes the LUT texture to json format.
  21302. */
  21303. serialize(): any;
  21304. }
  21305. }
  21306. declare module BABYLON {
  21307. class CubeTexture extends BaseTexture {
  21308. url: string;
  21309. coordinatesMode: number;
  21310. private _noMipmap;
  21311. private _files;
  21312. private _extensions;
  21313. private _textureMatrix;
  21314. private _format;
  21315. private _prefiltered;
  21316. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  21317. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any): CubeTexture;
  21318. 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);
  21319. delayLoad(): void;
  21320. getReflectionTextureMatrix(): Matrix;
  21321. setReflectionTextureMatrix(value: Matrix): void;
  21322. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  21323. clone(): CubeTexture;
  21324. }
  21325. }
  21326. declare module BABYLON {
  21327. class DynamicTexture extends Texture {
  21328. private _generateMipMaps;
  21329. private _canvas;
  21330. private _context;
  21331. private _engine;
  21332. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  21333. readonly canRescale: boolean;
  21334. private _recreate(textureSize);
  21335. scale(ratio: number): void;
  21336. scaleTo(width: number, height: number): void;
  21337. getContext(): CanvasRenderingContext2D;
  21338. clear(): void;
  21339. update(invertY?: boolean): void;
  21340. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  21341. clone(): DynamicTexture;
  21342. _rebuild(): void;
  21343. }
  21344. }
  21345. declare module BABYLON {
  21346. /**
  21347. * This represents a texture coming from an HDR input.
  21348. *
  21349. * The only supported format is currently panorama picture stored in RGBE format.
  21350. * Example of such files can be found on HDRLib: http://hdrlib.com/
  21351. */
  21352. class HDRCubeTexture extends BaseTexture {
  21353. private static _facesMapping;
  21354. private _useInGammaSpace;
  21355. private _generateHarmonics;
  21356. private _noMipmap;
  21357. private _textureMatrix;
  21358. private _size;
  21359. private _usePMREMGenerator;
  21360. private _isBABYLONPreprocessed;
  21361. private _onLoad;
  21362. private _onError;
  21363. /**
  21364. * The texture URL.
  21365. */
  21366. url: string;
  21367. /**
  21368. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  21369. */
  21370. coordinatesMode: number;
  21371. /**
  21372. * Specifies wether the texture has been generated through the PMREMGenerator tool.
  21373. * This is usefull at run time to apply the good shader.
  21374. */
  21375. isPMREM: boolean;
  21376. protected _isBlocking: boolean;
  21377. /**
  21378. * Gets wether or not the texture is blocking during loading.
  21379. */
  21380. /**
  21381. * Sets wether or not the texture is blocking during loading.
  21382. */
  21383. isBlocking: boolean;
  21384. /**
  21385. * Instantiates an HDRTexture from the following parameters.
  21386. *
  21387. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  21388. * @param scene The scene the texture will be used in
  21389. * @param size The cubemap 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.
  21390. * @param noMipmap Forces to not generate the mipmap if true
  21391. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  21392. * @param useInGammaSpace 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)
  21393. * @param usePMREMGenerator Specifies whether or not to generate the CubeMap through CubeMapGen to avoid seams issue at run time.
  21394. */
  21395. constructor(url: string, scene: Scene, size?: number, noMipmap?: boolean, generateHarmonics?: boolean, useInGammaSpace?: boolean, usePMREMGenerator?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  21396. /**
  21397. * Occurs when the file is a preprocessed .babylon.hdr file.
  21398. */
  21399. private loadBabylonTexture();
  21400. /**
  21401. * Occurs when the file is raw .hdr file.
  21402. */
  21403. private loadHDRTexture();
  21404. /**
  21405. * Starts the loading process of the texture.
  21406. */
  21407. private loadTexture();
  21408. clone(): HDRCubeTexture;
  21409. delayLoad(): void;
  21410. getReflectionTextureMatrix(): Matrix;
  21411. setReflectionTextureMatrix(value: Matrix): void;
  21412. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  21413. serialize(): any;
  21414. /**
  21415. * Saves as a file the data contained in the texture in a binary format.
  21416. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  21417. * as the spherical used in the lighting.
  21418. * @param url The HDR file url.
  21419. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  21420. * @param onError Method called if any error happens during download.
  21421. * @return The packed binary data.
  21422. */
  21423. static generateBabylonHDROnDisk(url: string, size: number, onError?: Nullable<(() => void)>): void;
  21424. /**
  21425. * Serializes the data contained in the texture in a binary format.
  21426. * This can be used to prevent the long loading tie associated with creating the seamless texture as well
  21427. * as the spherical used in the lighting.
  21428. * @param url The HDR file url.
  21429. * @param size The size of the texture data to generate (one of the cubemap face desired width).
  21430. * @param onError Method called if any error happens during download.
  21431. * @return The packed binary data.
  21432. */
  21433. static generateBabylonHDR(url: string, size: number, callback: ((ArrayBuffer: ArrayBuffer) => void), onError?: Nullable<(() => void)>): void;
  21434. }
  21435. }
  21436. declare module BABYLON {
  21437. /**
  21438. * Class used to store data associated with WebGL texture data for the engine
  21439. * This class should not be used directly
  21440. */
  21441. class InternalTexture implements IInternalTextureTracker {
  21442. /**
  21443. * The source of the texture data is unknown
  21444. */
  21445. static DATASOURCE_UNKNOWN: number;
  21446. /**
  21447. * Texture data comes from an URL
  21448. */
  21449. static DATASOURCE_URL: number;
  21450. /**
  21451. * Texture data is only used for temporary storage
  21452. */
  21453. static DATASOURCE_TEMP: number;
  21454. /**
  21455. * Texture data comes from raw data (ArrayBuffer)
  21456. */
  21457. static DATASOURCE_RAW: number;
  21458. /**
  21459. * Texture content is dynamic (video or dynamic texture)
  21460. */
  21461. static DATASOURCE_DYNAMIC: number;
  21462. /**
  21463. * Texture content is generated by rendering to it
  21464. */
  21465. static DATASOURCE_RENDERTARGET: number;
  21466. /**
  21467. * Texture content is part of a multi render target process
  21468. */
  21469. static DATASOURCE_MULTIRENDERTARGET: number;
  21470. /**
  21471. * Texture data comes from a cube data file
  21472. */
  21473. static DATASOURCE_CUBE: number;
  21474. /**
  21475. * Texture data comes from a raw cube data
  21476. */
  21477. static DATASOURCE_CUBERAW: number;
  21478. /**
  21479. * Texture data come from a prefiltered cube data file
  21480. */
  21481. static DATASOURCE_CUBEPREFILTERED: number;
  21482. /**
  21483. * Texture content is raw 3D data
  21484. */
  21485. static DATASOURCE_RAW3D: number;
  21486. /**
  21487. * Defines if the texture is ready
  21488. */
  21489. isReady: boolean;
  21490. /**
  21491. * Defines if the texture is a cube texture
  21492. */
  21493. isCube: boolean;
  21494. /**
  21495. * Defines if the texture contains 3D data
  21496. */
  21497. is3D: boolean;
  21498. /**
  21499. * Gets the URL used to load this texture
  21500. */
  21501. url: string;
  21502. /**
  21503. * Gets the sampling mode of the texture
  21504. */
  21505. samplingMode: number;
  21506. /**
  21507. * Gets a boolean indicating if the texture needs mipmaps generation
  21508. */
  21509. generateMipMaps: boolean;
  21510. /**
  21511. * Gets the number of samples used by the texture (WebGL2+ only)
  21512. */
  21513. samples: number;
  21514. /**
  21515. * Gets the type of the texture
  21516. */
  21517. type: number;
  21518. /**
  21519. * Gets the format of the texture
  21520. */
  21521. format: number;
  21522. /**
  21523. * Observable called when the texture is loaded
  21524. */
  21525. onLoadedObservable: Observable<InternalTexture>;
  21526. /**
  21527. * Gets the width of the texture
  21528. */
  21529. width: number;
  21530. /**
  21531. * Gets the height of the texture
  21532. */
  21533. height: number;
  21534. /**
  21535. * Gets the depth of the texture
  21536. */
  21537. depth: number;
  21538. /**
  21539. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  21540. */
  21541. baseWidth: number;
  21542. /**
  21543. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  21544. */
  21545. baseHeight: number;
  21546. /**
  21547. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  21548. */
  21549. baseDepth: number;
  21550. /**
  21551. * Gets a boolean indicating if the texture is inverted on Y axis
  21552. */
  21553. invertY: boolean;
  21554. /**
  21555. * Gets or set the previous tracker in the list
  21556. */
  21557. previous: Nullable<IInternalTextureTracker>;
  21558. /**
  21559. * Gets or set the next tracker in the list
  21560. */
  21561. next: Nullable<IInternalTextureTracker>;
  21562. /** @ignore */
  21563. _initialSlot: number;
  21564. /** @ignore */
  21565. _designatedSlot: number;
  21566. /** @ignore */
  21567. _dataSource: number;
  21568. /** @ignore */
  21569. _buffer: Nullable<ArrayBuffer | HTMLImageElement>;
  21570. /** @ignore */
  21571. _bufferView: Nullable<ArrayBufferView>;
  21572. /** @ignore */
  21573. _bufferViewArray: Nullable<ArrayBufferView[]>;
  21574. /** @ignore */
  21575. _size: number;
  21576. /** @ignore */
  21577. _extension: string;
  21578. /** @ignore */
  21579. _files: Nullable<string[]>;
  21580. /** @ignore */
  21581. _workingCanvas: HTMLCanvasElement;
  21582. /** @ignore */
  21583. _workingContext: CanvasRenderingContext2D;
  21584. /** @ignore */
  21585. _framebuffer: Nullable<WebGLFramebuffer>;
  21586. /** @ignore */
  21587. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  21588. /** @ignore */
  21589. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  21590. /** @ignore */
  21591. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  21592. /** @ignore */
  21593. _attachments: Nullable<number[]>;
  21594. /** @ignore */
  21595. _cachedCoordinatesMode: Nullable<number>;
  21596. /** @ignore */
  21597. _cachedWrapU: Nullable<number>;
  21598. /** @ignore */
  21599. _cachedWrapV: Nullable<number>;
  21600. /** @ignore */
  21601. _cachedWrapR: Nullable<number>;
  21602. /** @ignore */
  21603. _cachedAnisotropicFilteringLevel: Nullable<number>;
  21604. /** @ignore */
  21605. _isDisabled: boolean;
  21606. /** @ignore */
  21607. _compression: Nullable<string>;
  21608. /** @ignore */
  21609. _generateStencilBuffer: boolean;
  21610. /** @ignore */
  21611. _generateDepthBuffer: boolean;
  21612. /** @ignore */
  21613. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  21614. /** @ignore */
  21615. _lodGenerationScale: number;
  21616. /** @ignore */
  21617. _lodGenerationOffset: number;
  21618. /** @ignore */
  21619. _lodTextureHigh: BaseTexture;
  21620. /** @ignore */
  21621. _lodTextureMid: BaseTexture;
  21622. /** @ignore */
  21623. _lodTextureLow: BaseTexture;
  21624. /** @ignore */
  21625. _webGLTexture: Nullable<WebGLTexture>;
  21626. /** @ignore */
  21627. _references: number;
  21628. private _engine;
  21629. /**
  21630. * Gets the data source type of the texture (can be one of the BABYLON.InternalTexture.DATASOURCE_XXXX)
  21631. */
  21632. readonly dataSource: number;
  21633. /**
  21634. * Creates a new InternalTexture
  21635. * @param engine defines the engine to use
  21636. * @param dataSource defines the type of data that will be used
  21637. */
  21638. constructor(engine: Engine, dataSource: number);
  21639. /**
  21640. * Increments the number of references (ie. the number of {BABYLON.Texture} that point to it)
  21641. */
  21642. incrementReferences(): void;
  21643. /**
  21644. * Change the size of the texture (not the size of the content)
  21645. * @param width defines the new width
  21646. * @param height defines the new height
  21647. * @param depth defines the new depth (1 by default)
  21648. */
  21649. updateSize(width: int, height: int, depth?: int): void;
  21650. /** @ignore */
  21651. _rebuild(): void;
  21652. private _swapAndDie(target);
  21653. /**
  21654. * Dispose the current allocated resources
  21655. */
  21656. dispose(): void;
  21657. }
  21658. }
  21659. declare module BABYLON {
  21660. /**
  21661. * Internal interface used to track {BABYLON.InternalTexture} already bound to the GL context
  21662. */
  21663. interface IInternalTextureTracker {
  21664. /**
  21665. * Gets or set the previous tracker in the list
  21666. */
  21667. previous: Nullable<IInternalTextureTracker>;
  21668. /**
  21669. * Gets or set the next tracker in the list
  21670. */
  21671. next: Nullable<IInternalTextureTracker>;
  21672. }
  21673. /**
  21674. * Internal class used by the engine to get list of {BABYLON.InternalTexture} already bound to the GL context
  21675. */
  21676. class DummyInternalTextureTracker {
  21677. /**
  21678. * Gets or set the previous tracker in the list
  21679. */
  21680. previous: Nullable<IInternalTextureTracker>;
  21681. /**
  21682. * Gets or set the next tracker in the list
  21683. */
  21684. next: Nullable<IInternalTextureTracker>;
  21685. }
  21686. }
  21687. declare module BABYLON {
  21688. class MirrorTexture extends RenderTargetTexture {
  21689. mirrorPlane: Plane;
  21690. private _transformMatrix;
  21691. private _mirrorMatrix;
  21692. private _savedViewMatrix;
  21693. private _blurX;
  21694. private _blurY;
  21695. private _adaptiveBlurKernel;
  21696. private _blurKernelX;
  21697. private _blurKernelY;
  21698. private _blurRatio;
  21699. blurRatio: number;
  21700. adaptiveBlurKernel: number;
  21701. blurKernel: number;
  21702. blurKernelX: number;
  21703. blurKernelY: number;
  21704. private _autoComputeBlurKernel();
  21705. protected _onRatioRescale(): void;
  21706. constructor(name: string, size: number | {
  21707. width: number;
  21708. height: number;
  21709. } | {
  21710. ratio: number;
  21711. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  21712. private _preparePostProcesses();
  21713. clone(): MirrorTexture;
  21714. serialize(): any;
  21715. }
  21716. }
  21717. declare module BABYLON {
  21718. interface IMultiRenderTargetOptions {
  21719. generateMipMaps?: boolean;
  21720. types?: number[];
  21721. samplingModes?: number[];
  21722. generateDepthBuffer?: boolean;
  21723. generateStencilBuffer?: boolean;
  21724. generateDepthTexture?: boolean;
  21725. textureCount?: number;
  21726. doNotChangeAspectRatio?: boolean;
  21727. defaultType?: number;
  21728. }
  21729. class MultiRenderTarget extends RenderTargetTexture {
  21730. private _internalTextures;
  21731. private _textures;
  21732. readonly isSupported: boolean;
  21733. private _multiRenderTargetOptions;
  21734. readonly textures: Texture[];
  21735. readonly depthTexture: Texture;
  21736. wrapU: number;
  21737. wrapV: number;
  21738. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  21739. _rebuild(): void;
  21740. private _createInternalTextures();
  21741. private _createTextures();
  21742. samples: number;
  21743. resize(size: any): void;
  21744. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21745. dispose(): void;
  21746. releaseInternalTextures(): void;
  21747. }
  21748. }
  21749. declare module BABYLON {
  21750. class RawTexture extends Texture {
  21751. format: number;
  21752. private _engine;
  21753. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  21754. update(data: ArrayBufferView): void;
  21755. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  21756. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  21757. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  21758. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  21759. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  21760. }
  21761. }
  21762. declare module BABYLON {
  21763. /**
  21764. * Creates a refraction texture used by refraction channel of the standard material.
  21765. * @param name the texture name
  21766. * @param size size of the underlying texture
  21767. * @param scene root scene
  21768. */
  21769. class RefractionTexture extends RenderTargetTexture {
  21770. refractionPlane: Plane;
  21771. depth: number;
  21772. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  21773. clone(): RefractionTexture;
  21774. serialize(): any;
  21775. }
  21776. }
  21777. declare module BABYLON {
  21778. class RenderTargetTexture extends Texture {
  21779. isCube: boolean;
  21780. static _REFRESHRATE_RENDER_ONCE: number;
  21781. static _REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21782. static _REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21783. static readonly REFRESHRATE_RENDER_ONCE: number;
  21784. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  21785. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  21786. /**
  21787. * Use this predicate to dynamically define the list of mesh you want to render.
  21788. * If set, the renderList property will be overwritten.
  21789. */
  21790. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  21791. /**
  21792. * Use this list to define the list of mesh you want to render.
  21793. */
  21794. renderList: Nullable<Array<AbstractMesh>>;
  21795. renderParticles: boolean;
  21796. renderSprites: boolean;
  21797. coordinatesMode: number;
  21798. activeCamera: Nullable<Camera>;
  21799. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  21800. useCameraPostProcesses: boolean;
  21801. ignoreCameraViewport: boolean;
  21802. private _postProcessManager;
  21803. private _postProcesses;
  21804. private _resizeObserver;
  21805. /**
  21806. * An event triggered when the texture is unbind.
  21807. * @type {BABYLON.Observable}
  21808. */
  21809. onBeforeBindObservable: Observable<RenderTargetTexture>;
  21810. /**
  21811. * An event triggered when the texture is unbind.
  21812. * @type {BABYLON.Observable}
  21813. */
  21814. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  21815. private _onAfterUnbindObserver;
  21816. onAfterUnbind: () => void;
  21817. /**
  21818. * An event triggered before rendering the texture
  21819. * @type {BABYLON.Observable}
  21820. */
  21821. onBeforeRenderObservable: Observable<number>;
  21822. private _onBeforeRenderObserver;
  21823. onBeforeRender: (faceIndex: number) => void;
  21824. /**
  21825. * An event triggered after rendering the texture
  21826. * @type {BABYLON.Observable}
  21827. */
  21828. onAfterRenderObservable: Observable<number>;
  21829. private _onAfterRenderObserver;
  21830. onAfterRender: (faceIndex: number) => void;
  21831. /**
  21832. * An event triggered after the texture clear
  21833. * @type {BABYLON.Observable}
  21834. */
  21835. onClearObservable: Observable<Engine>;
  21836. private _onClearObserver;
  21837. onClear: (Engine: Engine) => void;
  21838. clearColor: Color4;
  21839. protected _size: number | {
  21840. width: number;
  21841. height: number;
  21842. };
  21843. protected _initialSizeParameter: number | {
  21844. width: number;
  21845. height: number;
  21846. } | {
  21847. ratio: number;
  21848. };
  21849. protected _sizeRatio: Nullable<number>;
  21850. _generateMipMaps: boolean;
  21851. protected _renderingManager: RenderingManager;
  21852. _waitingRenderList: string[];
  21853. protected _doNotChangeAspectRatio: boolean;
  21854. protected _currentRefreshId: number;
  21855. protected _refreshRate: number;
  21856. protected _textureMatrix: Matrix;
  21857. protected _samples: number;
  21858. protected _renderTargetOptions: RenderTargetCreationOptions;
  21859. readonly renderTargetOptions: RenderTargetCreationOptions;
  21860. protected _engine: Engine;
  21861. protected _onRatioRescale(): void;
  21862. constructor(name: string, size: number | {
  21863. width: number;
  21864. height: number;
  21865. } | {
  21866. ratio: number;
  21867. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean);
  21868. private _processSizeParameter(size);
  21869. samples: number;
  21870. resetRefreshCounter(): void;
  21871. refreshRate: number;
  21872. addPostProcess(postProcess: PostProcess): void;
  21873. clearPostProcesses(dispose?: boolean): void;
  21874. removePostProcess(postProcess: PostProcess): void;
  21875. _shouldRender(): boolean;
  21876. getRenderSize(): number;
  21877. getRenderWidth(): number;
  21878. getRenderHeight(): number;
  21879. readonly canRescale: boolean;
  21880. scale(ratio: number): void;
  21881. getReflectionTextureMatrix(): Matrix;
  21882. resize(size: number | {
  21883. width: number;
  21884. height: number;
  21885. } | {
  21886. ratio: number;
  21887. }): void;
  21888. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  21889. private _bestReflectionRenderTargetDimension(renderDimension, scale);
  21890. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  21891. private renderToTarget(faceIndex, currentRenderList, currentRenderListLength, useCameraPostProcess, dumpForDebug);
  21892. /**
  21893. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  21894. * This allowed control for front to back rendering or reversly depending of the special needs.
  21895. *
  21896. * @param renderingGroupId The rendering group id corresponding to its index
  21897. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  21898. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  21899. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  21900. */
  21901. 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;
  21902. /**
  21903. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  21904. *
  21905. * @param renderingGroupId The rendering group id corresponding to its index
  21906. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  21907. */
  21908. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  21909. clone(): RenderTargetTexture;
  21910. serialize(): any;
  21911. disposeFramebufferObjects(): void;
  21912. dispose(): void;
  21913. _rebuild(): void;
  21914. }
  21915. }
  21916. declare module BABYLON {
  21917. class Texture extends BaseTexture {
  21918. static NEAREST_SAMPLINGMODE: number;
  21919. static NEAREST_NEAREST_MIPLINEAR: number;
  21920. static BILINEAR_SAMPLINGMODE: number;
  21921. static LINEAR_LINEAR_MIPNEAREST: number;
  21922. static TRILINEAR_SAMPLINGMODE: number;
  21923. static LINEAR_LINEAR_MIPLINEAR: number;
  21924. static NEAREST_NEAREST_MIPNEAREST: number;
  21925. static NEAREST_LINEAR_MIPNEAREST: number;
  21926. static NEAREST_LINEAR_MIPLINEAR: number;
  21927. static NEAREST_LINEAR: number;
  21928. static NEAREST_NEAREST: number;
  21929. static LINEAR_NEAREST_MIPNEAREST: number;
  21930. static LINEAR_NEAREST_MIPLINEAR: number;
  21931. static LINEAR_LINEAR: number;
  21932. static LINEAR_NEAREST: number;
  21933. static EXPLICIT_MODE: number;
  21934. static SPHERICAL_MODE: number;
  21935. static PLANAR_MODE: number;
  21936. static CUBIC_MODE: number;
  21937. static PROJECTION_MODE: number;
  21938. static SKYBOX_MODE: number;
  21939. static INVCUBIC_MODE: number;
  21940. static EQUIRECTANGULAR_MODE: number;
  21941. static FIXED_EQUIRECTANGULAR_MODE: number;
  21942. static FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  21943. static CLAMP_ADDRESSMODE: number;
  21944. static WRAP_ADDRESSMODE: number;
  21945. static MIRROR_ADDRESSMODE: number;
  21946. url: Nullable<string>;
  21947. uOffset: number;
  21948. vOffset: number;
  21949. uScale: number;
  21950. vScale: number;
  21951. uAng: number;
  21952. vAng: number;
  21953. wAng: number;
  21954. readonly noMipmap: boolean;
  21955. private _noMipmap;
  21956. _invertY: boolean;
  21957. private _rowGenerationMatrix;
  21958. private _cachedTextureMatrix;
  21959. private _projectionModeMatrix;
  21960. private _t0;
  21961. private _t1;
  21962. private _t2;
  21963. private _cachedUOffset;
  21964. private _cachedVOffset;
  21965. private _cachedUScale;
  21966. private _cachedVScale;
  21967. private _cachedUAng;
  21968. private _cachedVAng;
  21969. private _cachedWAng;
  21970. private _cachedProjectionMatrixId;
  21971. private _cachedCoordinatesMode;
  21972. _samplingMode: number;
  21973. private _buffer;
  21974. private _deleteBuffer;
  21975. protected _format: Nullable<number>;
  21976. private _delayedOnLoad;
  21977. private _delayedOnError;
  21978. private _onLoadObservable;
  21979. protected _isBlocking: boolean;
  21980. isBlocking: boolean;
  21981. readonly samplingMode: number;
  21982. constructor(url: Nullable<string>, scene: Nullable<Scene>, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>, buffer?: any, deleteBuffer?: boolean, format?: number);
  21983. updateURL(url: string): void;
  21984. delayLoad(): void;
  21985. updateSamplingMode(samplingMode: number): void;
  21986. private _prepareRowForTextureGeneration(x, y, z, t);
  21987. getTextureMatrix(): Matrix;
  21988. getReflectionTextureMatrix(): Matrix;
  21989. clone(): Texture;
  21990. readonly onLoadObservable: Observable<Texture>;
  21991. serialize(): any;
  21992. getClassName(): string;
  21993. dispose(): void;
  21994. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  21995. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  21996. 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;
  21997. }
  21998. }
  21999. declare module BABYLON {
  22000. class VideoTexture extends Texture {
  22001. video: HTMLVideoElement;
  22002. private _autoLaunch;
  22003. private _lastUpdate;
  22004. private _generateMipMaps;
  22005. private _setTextureReady;
  22006. private _engine;
  22007. /**
  22008. * Creates a video texture.
  22009. * Sample : https://doc.babylonjs.com/tutorials/01._Advanced_Texturing
  22010. * @param {Array} urlsOrVideo can be used to provide an array of urls or an already setup HTML video element.
  22011. * @param {BABYLON.Scene} scene is obviously the current scene.
  22012. * @param {boolean} generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  22013. * @param {boolean} invertY is false by default but can be used to invert video on Y axis
  22014. * @param {number} samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  22015. */
  22016. constructor(name: string, urlsOrVideo: string[] | HTMLVideoElement, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  22017. private __setTextureReady();
  22018. private _createTexture();
  22019. _rebuild(): void;
  22020. update(): boolean;
  22021. dispose(): void;
  22022. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  22023. minWidth: number;
  22024. maxWidth: number;
  22025. minHeight: number;
  22026. maxHeight: number;
  22027. deviceId: string;
  22028. }): void;
  22029. }
  22030. }
  22031. declare module BABYLON {
  22032. class CannonJSPlugin implements IPhysicsEnginePlugin {
  22033. private _useDeltaForWorldStep;
  22034. world: any;
  22035. name: string;
  22036. private _physicsMaterials;
  22037. private _fixedTimeStep;
  22038. BJSCANNON: any;
  22039. constructor(_useDeltaForWorldStep?: boolean, iterations?: number);
  22040. setGravity(gravity: Vector3): void;
  22041. setTimeStep(timeStep: number): void;
  22042. getTimeStep(): number;
  22043. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22044. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22045. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22046. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22047. private _processChildMeshes(mainImpostor);
  22048. removePhysicsBody(impostor: PhysicsImpostor): void;
  22049. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  22050. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  22051. private _addMaterial(name, friction, restitution);
  22052. private _checkWithEpsilon(value);
  22053. private _createShape(impostor);
  22054. private _createHeightmap(object, pointDepth?);
  22055. private _minus90X;
  22056. private _plus90X;
  22057. private _tmpPosition;
  22058. private _tmpDeltaPosition;
  22059. private _tmpUnityRotation;
  22060. private _updatePhysicsBodyTransformation(impostor);
  22061. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22062. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22063. isSupported(): boolean;
  22064. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  22065. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  22066. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22067. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22068. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22069. getBodyMass(impostor: PhysicsImpostor): number;
  22070. getBodyFriction(impostor: PhysicsImpostor): number;
  22071. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22072. getBodyRestitution(impostor: PhysicsImpostor): number;
  22073. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22074. sleepBody(impostor: PhysicsImpostor): void;
  22075. wakeUpBody(impostor: PhysicsImpostor): void;
  22076. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22077. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  22078. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  22079. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22080. getRadius(impostor: PhysicsImpostor): number;
  22081. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22082. dispose(): void;
  22083. private _extendNamespace();
  22084. }
  22085. }
  22086. declare module BABYLON {
  22087. class OimoJSPlugin implements IPhysicsEnginePlugin {
  22088. world: any;
  22089. name: string;
  22090. BJSOIMO: any;
  22091. constructor(iterations?: number);
  22092. setGravity(gravity: Vector3): void;
  22093. setTimeStep(timeStep: number): void;
  22094. getTimeStep(): number;
  22095. private _tmpImpostorsArray;
  22096. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  22097. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22098. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  22099. generatePhysicsBody(impostor: PhysicsImpostor): void;
  22100. private _tmpPositionVector;
  22101. removePhysicsBody(impostor: PhysicsImpostor): void;
  22102. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  22103. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  22104. isSupported(): boolean;
  22105. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  22106. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  22107. private _getLastShape(body);
  22108. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  22109. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  22110. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22111. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  22112. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  22113. getBodyMass(impostor: PhysicsImpostor): number;
  22114. getBodyFriction(impostor: PhysicsImpostor): number;
  22115. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  22116. getBodyRestitution(impostor: PhysicsImpostor): number;
  22117. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  22118. sleepBody(impostor: PhysicsImpostor): void;
  22119. wakeUpBody(impostor: PhysicsImpostor): void;
  22120. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  22121. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  22122. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  22123. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  22124. getRadius(impostor: PhysicsImpostor): number;
  22125. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  22126. dispose(): void;
  22127. }
  22128. }
  22129. declare module BABYLON {
  22130. class PostProcessRenderEffect {
  22131. private _postProcesses;
  22132. private _getPostProcess;
  22133. private _singleInstance;
  22134. private _cameras;
  22135. private _indicesForCamera;
  22136. private _renderPasses;
  22137. private _renderEffectAsPasses;
  22138. _name: string;
  22139. applyParameters: (postProcess: PostProcess) => void;
  22140. constructor(engine: Engine, name: string, getPostProcess: () => Nullable<PostProcess>, singleInstance?: boolean);
  22141. readonly isSupported: boolean;
  22142. _update(): void;
  22143. addPass(renderPass: PostProcessRenderPass): void;
  22144. removePass(renderPass: PostProcessRenderPass): void;
  22145. addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void;
  22146. getPass(passName: string): Nullable<PostProcessRenderPass>;
  22147. emptyPasses(): void;
  22148. _attachCameras(cameras: Camera): void;
  22149. _attachCameras(cameras: Camera[]): void;
  22150. _detachCameras(cameras: Camera): void;
  22151. _detachCameras(cameras: Camera[]): void;
  22152. _enable(cameras: Camera): void;
  22153. _enable(cameras: Nullable<Camera[]>): void;
  22154. _disable(cameras: Camera): void;
  22155. _disable(cameras: Nullable<Camera[]>): void;
  22156. getPostProcess(camera?: Camera): Nullable<PostProcess>;
  22157. private _linkParameters();
  22158. private _linkTextures(effect);
  22159. }
  22160. }
  22161. declare module BABYLON {
  22162. class PostProcessRenderPass {
  22163. private _renderList;
  22164. private _renderTexture;
  22165. private _scene;
  22166. private _refCount;
  22167. _name: string;
  22168. constructor(scene: Scene, name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void);
  22169. _incRefCount(): number;
  22170. _decRefCount(): number;
  22171. _update(): void;
  22172. setRenderList(renderList: Mesh[]): void;
  22173. getRenderTexture(): RenderTargetTexture;
  22174. }
  22175. }
  22176. declare module BABYLON {
  22177. class PostProcessRenderPipeline {
  22178. private _engine;
  22179. private _renderEffects;
  22180. private _renderEffectsForIsolatedPass;
  22181. protected _cameras: Camera[];
  22182. _name: string;
  22183. private static PASS_EFFECT_NAME;
  22184. private static PASS_SAMPLER_NAME;
  22185. constructor(engine: Engine, name: string);
  22186. getClassName(): string;
  22187. readonly isSupported: boolean;
  22188. addEffect(renderEffect: PostProcessRenderEffect): void;
  22189. _rebuild(): void;
  22190. _enableEffect(renderEffectName: string, cameras: Camera): void;
  22191. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  22192. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  22193. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  22194. _attachCameras(cameras: Camera, unique: boolean): void;
  22195. _attachCameras(cameras: Camera[], unique: boolean): void;
  22196. _detachCameras(cameras: Camera): void;
  22197. _detachCameras(cameras: Nullable<Camera[]>): void;
  22198. _enableDisplayOnlyPass(passName: string, cameras: Camera): void;
  22199. _enableDisplayOnlyPass(passName: string, cameras: Nullable<Camera[]>): void;
  22200. _disableDisplayOnlyPass(cameras: Camera): void;
  22201. _disableDisplayOnlyPass(cameras: Camera[]): void;
  22202. _update(): void;
  22203. _reset(): void;
  22204. dispose(): void;
  22205. }
  22206. }
  22207. declare module BABYLON {
  22208. class PostProcessRenderPipelineManager {
  22209. private _renderPipelines;
  22210. constructor();
  22211. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  22212. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): void;
  22213. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): void;
  22214. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): void;
  22215. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): void;
  22216. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  22217. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  22218. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): void;
  22219. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): void;
  22220. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera): void;
  22221. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera[]): void;
  22222. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera): void;
  22223. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera[]): void;
  22224. update(): void;
  22225. _rebuild(): void;
  22226. dispose(): void;
  22227. }
  22228. }
  22229. declare module BABYLON {
  22230. /**
  22231. * Helper class dealing with the extraction of spherical polynomial dataArray
  22232. * from a cube map.
  22233. */
  22234. class CubeMapToSphericalPolynomialTools {
  22235. private static FileFaces;
  22236. /**
  22237. * Converts a texture to the according Spherical Polynomial data.
  22238. * This extracts the first 3 orders only as they are the only one used in the lighting.
  22239. *
  22240. * @param texture The texture to extract the information from.
  22241. * @return The Spherical Polynomial data.
  22242. */
  22243. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  22244. /**
  22245. * Converts a cubemap to the according Spherical Polynomial data.
  22246. * This extracts the first 3 orders only as they are the only one used in the lighting.
  22247. *
  22248. * @param cubeInfo The Cube map to extract the information from.
  22249. * @return The Spherical Polynomial data.
  22250. */
  22251. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  22252. }
  22253. }
  22254. declare module BABYLON {
  22255. /**
  22256. * Header information of HDR texture files.
  22257. */
  22258. interface HDRInfo {
  22259. /**
  22260. * The height of the texture in pixels.
  22261. */
  22262. height: number;
  22263. /**
  22264. * The width of the texture in pixels.
  22265. */
  22266. width: number;
  22267. /**
  22268. * The index of the beginning of the data in the binary file.
  22269. */
  22270. dataPosition: number;
  22271. }
  22272. /**
  22273. * This groups tools to convert HDR texture to native colors array.
  22274. */
  22275. class HDRTools {
  22276. private static Ldexp(mantissa, exponent);
  22277. private static Rgbe2float(float32array, red, green, blue, exponent, index);
  22278. private static readStringLine(uint8array, startIndex);
  22279. /**
  22280. * Reads header information from an RGBE texture stored in a native array.
  22281. * More information on this format are available here:
  22282. * https://en.wikipedia.org/wiki/RGBE_image_format
  22283. *
  22284. * @param uint8array The binary file stored in native array.
  22285. * @return The header information.
  22286. */
  22287. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  22288. /**
  22289. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  22290. * This RGBE texture needs to store the information as a panorama.
  22291. *
  22292. * More information on this format are available here:
  22293. * https://en.wikipedia.org/wiki/RGBE_image_format
  22294. *
  22295. * @param buffer The binary file stored in an array buffer.
  22296. * @param size The expected size of the extracted cubemap.
  22297. * @return The Cube Map information.
  22298. */
  22299. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  22300. /**
  22301. * Returns the pixels data extracted from an RGBE texture.
  22302. * This pixels will be stored left to right up to down in the R G B order in one array.
  22303. *
  22304. * More information on this format are available here:
  22305. * https://en.wikipedia.org/wiki/RGBE_image_format
  22306. *
  22307. * @param uint8array The binary file stored in an array buffer.
  22308. * @param hdrInfo The header information of the file.
  22309. * @return The pixels data in RGB right to left up to down order.
  22310. */
  22311. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  22312. private static RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  22313. }
  22314. }
  22315. declare module BABYLON {
  22316. /**
  22317. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  22318. */
  22319. interface CubeMapInfo {
  22320. /**
  22321. * The pixel array for the front face.
  22322. * This is stored in format, left to right, up to down format.
  22323. */
  22324. front: Nullable<ArrayBufferView>;
  22325. /**
  22326. * The pixel array for the back face.
  22327. * This is stored in format, left to right, up to down format.
  22328. */
  22329. back: Nullable<ArrayBufferView>;
  22330. /**
  22331. * The pixel array for the left face.
  22332. * This is stored in format, left to right, up to down format.
  22333. */
  22334. left: Nullable<ArrayBufferView>;
  22335. /**
  22336. * The pixel array for the right face.
  22337. * This is stored in format, left to right, up to down format.
  22338. */
  22339. right: Nullable<ArrayBufferView>;
  22340. /**
  22341. * The pixel array for the up face.
  22342. * This is stored in format, left to right, up to down format.
  22343. */
  22344. up: Nullable<ArrayBufferView>;
  22345. /**
  22346. * The pixel array for the down face.
  22347. * This is stored in format, left to right, up to down format.
  22348. */
  22349. down: Nullable<ArrayBufferView>;
  22350. /**
  22351. * The size of the cubemap stored.
  22352. *
  22353. * Each faces will be size * size pixels.
  22354. */
  22355. size: number;
  22356. /**
  22357. * The format of the texture.
  22358. *
  22359. * RGBA, RGB.
  22360. */
  22361. format: number;
  22362. /**
  22363. * The type of the texture data.
  22364. *
  22365. * UNSIGNED_INT, FLOAT.
  22366. */
  22367. type: number;
  22368. /**
  22369. * Specifies whether the texture is in gamma space.
  22370. */
  22371. gammaSpace: boolean;
  22372. }
  22373. /**
  22374. * Helper class usefull to convert panorama picture to their cubemap representation in 6 faces.
  22375. */
  22376. class PanoramaToCubeMapTools {
  22377. private static FACE_FRONT;
  22378. private static FACE_BACK;
  22379. private static FACE_RIGHT;
  22380. private static FACE_LEFT;
  22381. private static FACE_DOWN;
  22382. private static FACE_UP;
  22383. /**
  22384. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  22385. *
  22386. * @param float32Array The source data.
  22387. * @param inputWidth The width of the input panorama.
  22388. * @param inputhHeight The height of the input panorama.
  22389. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  22390. * @return The cubemap data
  22391. */
  22392. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  22393. private static CreateCubemapTexture(texSize, faceData, float32Array, inputWidth, inputHeight);
  22394. private static CalcProjectionSpherical(vDir, float32Array, inputWidth, inputHeight);
  22395. }
  22396. }
  22397. declare module BABYLON {
  22398. class CustomProceduralTexture extends ProceduralTexture {
  22399. private _animate;
  22400. private _time;
  22401. private _config;
  22402. private _texturePath;
  22403. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  22404. private loadJson(jsonUrl);
  22405. isReady(): boolean;
  22406. render(useCameraPostProcess?: boolean): void;
  22407. updateTextures(): void;
  22408. updateShaderUniforms(): void;
  22409. animate: boolean;
  22410. }
  22411. }
  22412. declare module BABYLON {
  22413. class ProceduralTexture extends Texture {
  22414. isCube: boolean;
  22415. private _size;
  22416. _generateMipMaps: boolean;
  22417. isEnabled: boolean;
  22418. private _currentRefreshId;
  22419. private _refreshRate;
  22420. onGenerated: () => void;
  22421. private _vertexBuffers;
  22422. private _indexBuffer;
  22423. private _effect;
  22424. private _uniforms;
  22425. private _samplers;
  22426. private _fragment;
  22427. _textures: {
  22428. [key: string]: Texture;
  22429. };
  22430. private _floats;
  22431. private _floatsArrays;
  22432. private _colors3;
  22433. private _colors4;
  22434. private _vectors2;
  22435. private _vectors3;
  22436. private _matrices;
  22437. private _fallbackTexture;
  22438. private _fallbackTextureUsed;
  22439. private _engine;
  22440. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  22441. private _createIndexBuffer();
  22442. _rebuild(): void;
  22443. reset(): void;
  22444. isReady(): boolean;
  22445. resetRefreshCounter(): void;
  22446. setFragment(fragment: any): void;
  22447. refreshRate: number;
  22448. _shouldRender(): boolean;
  22449. getRenderSize(): number;
  22450. resize(size: number, generateMipMaps: boolean): void;
  22451. private _checkUniform(uniformName);
  22452. setTexture(name: string, texture: Texture): ProceduralTexture;
  22453. setFloat(name: string, value: number): ProceduralTexture;
  22454. setFloats(name: string, value: number[]): ProceduralTexture;
  22455. setColor3(name: string, value: Color3): ProceduralTexture;
  22456. setColor4(name: string, value: Color4): ProceduralTexture;
  22457. setVector2(name: string, value: Vector2): ProceduralTexture;
  22458. setVector3(name: string, value: Vector3): ProceduralTexture;
  22459. setMatrix(name: string, value: Matrix): ProceduralTexture;
  22460. render(useCameraPostProcess?: boolean): void;
  22461. clone(): ProceduralTexture;
  22462. dispose(): void;
  22463. }
  22464. }
  22465. declare module BABYLON {
  22466. class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  22467. private _scene;
  22468. readonly PassPostProcessId: string;
  22469. readonly HighLightsPostProcessId: string;
  22470. readonly BlurXPostProcessId: string;
  22471. readonly BlurYPostProcessId: string;
  22472. readonly CopyBackPostProcessId: string;
  22473. readonly ImageProcessingPostProcessId: string;
  22474. readonly FxaaPostProcessId: string;
  22475. readonly FinalMergePostProcessId: string;
  22476. pass: PassPostProcess;
  22477. highlights: HighlightsPostProcess;
  22478. blurX: BlurPostProcess;
  22479. blurY: BlurPostProcess;
  22480. copyBack: PassPostProcess;
  22481. fxaa: FxaaPostProcess;
  22482. imageProcessing: ImageProcessingPostProcess;
  22483. finalMerge: PassPostProcess;
  22484. animations: Animation[];
  22485. private _bloomEnabled;
  22486. private _fxaaEnabled;
  22487. private _imageProcessingEnabled;
  22488. private _defaultPipelineTextureType;
  22489. private _bloomScale;
  22490. private _buildAllowed;
  22491. /**
  22492. * Specifies the size of the bloom blur kernel, relative to the final output size
  22493. */
  22494. bloomKernel: number;
  22495. /**
  22496. * Specifies the weight of the bloom in the final rendering
  22497. */
  22498. private _bloomWeight;
  22499. private _hdr;
  22500. bloomWeight: number;
  22501. bloomScale: number;
  22502. bloomEnabled: boolean;
  22503. fxaaEnabled: boolean;
  22504. imageProcessingEnabled: boolean;
  22505. /**
  22506. * @constructor
  22507. * @param {string} name - The rendering pipeline name
  22508. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  22509. * @param {any} 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)
  22510. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  22511. * @param {boolean} automaticBuild - if false, you will have to manually call prepare() to update the pipeline
  22512. */
  22513. constructor(name: string, hdr: boolean, scene: Scene, cameras?: Camera[], automaticBuild?: boolean);
  22514. /**
  22515. * Force the compilation of the entire pipeline.
  22516. */
  22517. prepare(): void;
  22518. private _buildPipeline();
  22519. private _disposePostProcesses();
  22520. dispose(): void;
  22521. serialize(): any;
  22522. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  22523. }
  22524. }
  22525. declare module BABYLON {
  22526. class LensRenderingPipeline extends PostProcessRenderPipeline {
  22527. /**
  22528. * The chromatic aberration PostProcess id in the pipeline
  22529. * @type {string}
  22530. */
  22531. LensChromaticAberrationEffect: string;
  22532. /**
  22533. * The highlights enhancing PostProcess id in the pipeline
  22534. * @type {string}
  22535. */
  22536. HighlightsEnhancingEffect: string;
  22537. /**
  22538. * The depth-of-field PostProcess id in the pipeline
  22539. * @type {string}
  22540. */
  22541. LensDepthOfFieldEffect: string;
  22542. private _scene;
  22543. private _depthTexture;
  22544. private _grainTexture;
  22545. private _chromaticAberrationPostProcess;
  22546. private _highlightsPostProcess;
  22547. private _depthOfFieldPostProcess;
  22548. private _edgeBlur;
  22549. private _grainAmount;
  22550. private _chromaticAberration;
  22551. private _distortion;
  22552. private _highlightsGain;
  22553. private _highlightsThreshold;
  22554. private _dofDistance;
  22555. private _dofAperture;
  22556. private _dofDarken;
  22557. private _dofPentagon;
  22558. private _blurNoise;
  22559. /**
  22560. * @constructor
  22561. *
  22562. * Effect parameters are as follow:
  22563. * {
  22564. * chromatic_aberration: number; // from 0 to x (1 for realism)
  22565. * edge_blur: number; // from 0 to x (1 for realism)
  22566. * distortion: number; // from 0 to x (1 for realism)
  22567. * grain_amount: number; // from 0 to 1
  22568. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  22569. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  22570. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  22571. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  22572. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  22573. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  22574. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  22575. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  22576. * }
  22577. * Note: if an effect parameter is unset, effect is disabled
  22578. *
  22579. * @param {string} name - The rendering pipeline name
  22580. * @param {object} parameters - An object containing all parameters (see above)
  22581. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  22582. * @param {number} 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)
  22583. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  22584. */
  22585. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  22586. setEdgeBlur(amount: number): void;
  22587. disableEdgeBlur(): void;
  22588. setGrainAmount(amount: number): void;
  22589. disableGrain(): void;
  22590. setChromaticAberration(amount: number): void;
  22591. disableChromaticAberration(): void;
  22592. setEdgeDistortion(amount: number): void;
  22593. disableEdgeDistortion(): void;
  22594. setFocusDistance(amount: number): void;
  22595. disableDepthOfField(): void;
  22596. setAperture(amount: number): void;
  22597. setDarkenOutOfFocus(amount: number): void;
  22598. enablePentagonBokeh(): void;
  22599. disablePentagonBokeh(): void;
  22600. enableNoiseBlur(): void;
  22601. disableNoiseBlur(): void;
  22602. setHighlightsGain(amount: number): void;
  22603. setHighlightsThreshold(amount: number): void;
  22604. disableHighlights(): void;
  22605. /**
  22606. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  22607. */
  22608. dispose(disableDepthRender?: boolean): void;
  22609. private _createChromaticAberrationPostProcess(ratio);
  22610. private _createHighlightsPostProcess(ratio);
  22611. private _createDepthOfFieldPostProcess(ratio);
  22612. private _createGrainTexture();
  22613. }
  22614. }
  22615. declare module BABYLON {
  22616. class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  22617. /**
  22618. * The PassPostProcess id in the pipeline that contains the original scene color
  22619. * @type {string}
  22620. */
  22621. SSAOOriginalSceneColorEffect: string;
  22622. /**
  22623. * The SSAO PostProcess id in the pipeline
  22624. * @type {string}
  22625. */
  22626. SSAORenderEffect: string;
  22627. /**
  22628. * The horizontal blur PostProcess id in the pipeline
  22629. * @type {string}
  22630. */
  22631. SSAOBlurHRenderEffect: string;
  22632. /**
  22633. * The vertical blur PostProcess id in the pipeline
  22634. * @type {string}
  22635. */
  22636. SSAOBlurVRenderEffect: string;
  22637. /**
  22638. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  22639. * @type {string}
  22640. */
  22641. SSAOCombineRenderEffect: string;
  22642. /**
  22643. * The output strength of the SSAO post-process. Default value is 1.0.
  22644. * @type {number}
  22645. */
  22646. totalStrength: number;
  22647. /**
  22648. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  22649. * @type {number}
  22650. */
  22651. maxZ: number;
  22652. /**
  22653. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  22654. * @type {number}
  22655. */
  22656. minZAspect: number;
  22657. /**
  22658. * Number of samples used for the SSAO calculations. Default value is 8
  22659. * @type {number}
  22660. */
  22661. private _samples;
  22662. /**
  22663. * Dynamically generated sphere sampler.
  22664. * @type {number[]}
  22665. */
  22666. private _sampleSphere;
  22667. /**
  22668. * Blur filter offsets
  22669. * @type {number[]}
  22670. */
  22671. private _samplerOffsets;
  22672. samples: number;
  22673. /**
  22674. * Are we using bilateral blur ?
  22675. * @type {boolean}
  22676. */
  22677. private _expensiveBlur;
  22678. expensiveBlur: boolean;
  22679. /**
  22680. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  22681. * @type {number}
  22682. */
  22683. radius: number;
  22684. /**
  22685. * The base color of the SSAO post-process
  22686. * The final result is "base + ssao" between [0, 1]
  22687. * @type {number}
  22688. */
  22689. base: number;
  22690. /**
  22691. * Support test.
  22692. * @type {boolean}
  22693. */
  22694. static readonly IsSupported: boolean;
  22695. private _scene;
  22696. private _depthTexture;
  22697. private _normalTexture;
  22698. private _randomTexture;
  22699. private _originalColorPostProcess;
  22700. private _ssaoPostProcess;
  22701. private _blurHPostProcess;
  22702. private _blurVPostProcess;
  22703. private _ssaoCombinePostProcess;
  22704. private _firstUpdate;
  22705. /**
  22706. * @constructor
  22707. * @param {string} name - The rendering pipeline name
  22708. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  22709. * @param {any} 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 }
  22710. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  22711. */
  22712. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  22713. /**
  22714. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  22715. */
  22716. dispose(disableGeometryBufferRenderer?: boolean): void;
  22717. private _createBlurPostProcess(ssaoRatio, blurRatio);
  22718. _rebuild(): void;
  22719. private _generateHemisphere();
  22720. private _createSSAOPostProcess(ratio);
  22721. private _createSSAOCombinePostProcess(ratio);
  22722. private _createRandomTexture();
  22723. }
  22724. }
  22725. declare module BABYLON {
  22726. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  22727. /**
  22728. * The PassPostProcess id in the pipeline that contains the original scene color
  22729. * @type {string}
  22730. */
  22731. SSAOOriginalSceneColorEffect: string;
  22732. /**
  22733. * The SSAO PostProcess id in the pipeline
  22734. * @type {string}
  22735. */
  22736. SSAORenderEffect: string;
  22737. /**
  22738. * The horizontal blur PostProcess id in the pipeline
  22739. * @type {string}
  22740. */
  22741. SSAOBlurHRenderEffect: string;
  22742. /**
  22743. * The vertical blur PostProcess id in the pipeline
  22744. * @type {string}
  22745. */
  22746. SSAOBlurVRenderEffect: string;
  22747. /**
  22748. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  22749. * @type {string}
  22750. */
  22751. SSAOCombineRenderEffect: string;
  22752. /**
  22753. * The output strength of the SSAO post-process. Default value is 1.0.
  22754. * @type {number}
  22755. */
  22756. totalStrength: number;
  22757. /**
  22758. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  22759. * @type {number}
  22760. */
  22761. radius: number;
  22762. /**
  22763. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  22764. * Must not be equal to fallOff and superior to fallOff.
  22765. * Default value is 0.975
  22766. * @type {number}
  22767. */
  22768. area: number;
  22769. /**
  22770. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  22771. * Must not be equal to area and inferior to area.
  22772. * Default value is 0.0
  22773. * @type {number}
  22774. */
  22775. fallOff: number;
  22776. /**
  22777. * The base color of the SSAO post-process
  22778. * The final result is "base + ssao" between [0, 1]
  22779. * @type {number}
  22780. */
  22781. base: number;
  22782. private _scene;
  22783. private _depthTexture;
  22784. private _randomTexture;
  22785. private _originalColorPostProcess;
  22786. private _ssaoPostProcess;
  22787. private _blurHPostProcess;
  22788. private _blurVPostProcess;
  22789. private _ssaoCombinePostProcess;
  22790. private _firstUpdate;
  22791. /**
  22792. * @constructor
  22793. * @param {string} name - The rendering pipeline name
  22794. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  22795. * @param {any} 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 }
  22796. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  22797. */
  22798. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  22799. /**
  22800. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  22801. */
  22802. dispose(disableDepthRender?: boolean): void;
  22803. private _createBlurPostProcess(ratio);
  22804. _rebuild(): void;
  22805. private _createSSAOPostProcess(ratio);
  22806. private _createSSAOCombinePostProcess(ratio);
  22807. private _createRandomTexture();
  22808. }
  22809. }
  22810. declare module BABYLON {
  22811. class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  22812. /**
  22813. * Public members
  22814. */
  22815. originalPostProcess: Nullable<PostProcess>;
  22816. downSampleX4PostProcess: Nullable<PostProcess>;
  22817. brightPassPostProcess: Nullable<PostProcess>;
  22818. blurHPostProcesses: PostProcess[];
  22819. blurVPostProcesses: PostProcess[];
  22820. textureAdderPostProcess: Nullable<PostProcess>;
  22821. volumetricLightPostProcess: Nullable<PostProcess>;
  22822. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  22823. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  22824. volumetricLightMergePostProces: Nullable<PostProcess>;
  22825. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  22826. luminancePostProcess: Nullable<PostProcess>;
  22827. luminanceDownSamplePostProcesses: PostProcess[];
  22828. hdrPostProcess: Nullable<PostProcess>;
  22829. textureAdderFinalPostProcess: Nullable<PostProcess>;
  22830. lensFlareFinalPostProcess: Nullable<PostProcess>;
  22831. hdrFinalPostProcess: Nullable<PostProcess>;
  22832. lensFlarePostProcess: Nullable<PostProcess>;
  22833. lensFlareComposePostProcess: Nullable<PostProcess>;
  22834. motionBlurPostProcess: Nullable<PostProcess>;
  22835. depthOfFieldPostProcess: Nullable<PostProcess>;
  22836. brightThreshold: number;
  22837. blurWidth: number;
  22838. horizontalBlur: boolean;
  22839. exposure: number;
  22840. lensTexture: Nullable<Texture>;
  22841. volumetricLightCoefficient: number;
  22842. volumetricLightPower: number;
  22843. volumetricLightBlurScale: number;
  22844. sourceLight: Nullable<SpotLight | DirectionalLight>;
  22845. hdrMinimumLuminance: number;
  22846. hdrDecreaseRate: number;
  22847. hdrIncreaseRate: number;
  22848. lensColorTexture: Nullable<Texture>;
  22849. lensFlareStrength: number;
  22850. lensFlareGhostDispersal: number;
  22851. lensFlareHaloWidth: number;
  22852. lensFlareDistortionStrength: number;
  22853. lensStarTexture: Nullable<Texture>;
  22854. lensFlareDirtTexture: Nullable<Texture>;
  22855. depthOfFieldDistance: number;
  22856. depthOfFieldBlurWidth: number;
  22857. motionStrength: number;
  22858. animations: Animation[];
  22859. /**
  22860. * Private members
  22861. */
  22862. private _scene;
  22863. private _currentDepthOfFieldSource;
  22864. private _basePostProcess;
  22865. private _hdrCurrentLuminance;
  22866. private _floatTextureType;
  22867. private _ratio;
  22868. private _bloomEnabled;
  22869. private _depthOfFieldEnabled;
  22870. private _vlsEnabled;
  22871. private _lensFlareEnabled;
  22872. private _hdrEnabled;
  22873. private _motionBlurEnabled;
  22874. private _motionBlurSamples;
  22875. private _volumetricLightStepsCount;
  22876. BloomEnabled: boolean;
  22877. DepthOfFieldEnabled: boolean;
  22878. LensFlareEnabled: boolean;
  22879. HDREnabled: boolean;
  22880. VLSEnabled: boolean;
  22881. MotionBlurEnabled: boolean;
  22882. volumetricLightStepsCount: number;
  22883. motionBlurSamples: number;
  22884. /**
  22885. * @constructor
  22886. * @param {string} name - The rendering pipeline name
  22887. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  22888. * @param {any} 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)
  22889. * @param {BABYLON.PostProcess} originalPostProcess - the custom original color post-process. Must be "reusable". Can be null.
  22890. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  22891. */
  22892. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  22893. private _buildPipeline();
  22894. private _createDownSampleX4PostProcess(scene, ratio);
  22895. private _createBrightPassPostProcess(scene, ratio);
  22896. private _createBlurPostProcesses(scene, ratio, indice, blurWidthKey?);
  22897. private _createTextureAdderPostProcess(scene, ratio);
  22898. private _createVolumetricLightPostProcess(scene, ratio);
  22899. private _createLuminancePostProcesses(scene, textureType);
  22900. private _createHdrPostProcess(scene, ratio);
  22901. private _createLensFlarePostProcess(scene, ratio);
  22902. private _createDepthOfFieldPostProcess(scene, ratio);
  22903. private _createMotionBlurPostProcess(scene, ratio);
  22904. private _getDepthTexture();
  22905. private _disposePostProcesses();
  22906. dispose(): void;
  22907. serialize(): any;
  22908. /**
  22909. * Static members
  22910. */
  22911. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  22912. static LuminanceSteps: number;
  22913. }
  22914. }