babylon.2.1.d.ts 238 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772
  1. declare module BABYLON {
  2. class _DepthCullingState {
  3. private _isDepthTestDirty;
  4. private _isDepthMaskDirty;
  5. private _isDepthFuncDirty;
  6. private _isCullFaceDirty;
  7. private _isCullDirty;
  8. private _isZOffsetDirty;
  9. private _depthTest;
  10. private _depthMask;
  11. private _depthFunc;
  12. private _cull;
  13. private _cullFace;
  14. private _zOffset;
  15. isDirty: boolean;
  16. zOffset: number;
  17. cullFace: number;
  18. cull: boolean;
  19. depthFunc: number;
  20. depthMask: boolean;
  21. depthTest: boolean;
  22. reset(): void;
  23. apply(gl: WebGLRenderingContext): void;
  24. }
  25. class _AlphaState {
  26. private _isAlphaBlendDirty;
  27. private _isBlendFunctionParametersDirty;
  28. private _alphaBlend;
  29. private _blendFunctionParameters;
  30. isDirty: boolean;
  31. alphaBlend: boolean;
  32. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  33. reset(): void;
  34. apply(gl: WebGLRenderingContext): void;
  35. }
  36. class EngineCapabilities {
  37. maxTexturesImageUnits: number;
  38. maxTextureSize: number;
  39. maxCubemapTextureSize: number;
  40. maxRenderTextureSize: number;
  41. standardDerivatives: boolean;
  42. s3tc: any;
  43. textureFloat: boolean;
  44. textureAnisotropicFilterExtension: any;
  45. maxAnisotropy: number;
  46. instancedArrays: any;
  47. uintIndices: boolean;
  48. highPrecisionShaderSupported: boolean;
  49. }
  50. /**
  51. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio.
  52. */
  53. class Engine {
  54. private static _ALPHA_DISABLE;
  55. private static _ALPHA_ADD;
  56. private static _ALPHA_COMBINE;
  57. private static _DELAYLOADSTATE_NONE;
  58. private static _DELAYLOADSTATE_LOADED;
  59. private static _DELAYLOADSTATE_LOADING;
  60. private static _DELAYLOADSTATE_NOTLOADED;
  61. private static _TEXTUREFORMAT_ALPHA;
  62. private static _TEXTUREFORMAT_LUMINANCE;
  63. private static _TEXTUREFORMAT_LUMINANCE_ALPHA;
  64. private static _TEXTUREFORMAT_RGB;
  65. private static _TEXTUREFORMAT_RGBA;
  66. private static _TEXTURETYPE_UNSIGNED_INT;
  67. private static _TEXTURETYPE_FLOAT;
  68. static ALPHA_DISABLE: number;
  69. static ALPHA_ADD: number;
  70. static ALPHA_COMBINE: number;
  71. static DELAYLOADSTATE_NONE: number;
  72. static DELAYLOADSTATE_LOADED: number;
  73. static DELAYLOADSTATE_LOADING: number;
  74. static DELAYLOADSTATE_NOTLOADED: number;
  75. static TEXTUREFORMAT_ALPHA: number;
  76. static TEXTUREFORMAT_LUMINANCE: number;
  77. static TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  78. static TEXTUREFORMAT_RGB: number;
  79. static TEXTUREFORMAT_RGBA: number;
  80. static TEXTURETYPE_UNSIGNED_INT: number;
  81. static TEXTURETYPE_FLOAT: number;
  82. static Version: string;
  83. static Epsilon: number;
  84. static CollisionsEpsilon: number;
  85. static CodeRepository: string;
  86. static ShadersRepository: string;
  87. isFullscreen: boolean;
  88. isPointerLock: boolean;
  89. cullBackFaces: boolean;
  90. renderEvenInBackground: boolean;
  91. scenes: Scene[];
  92. _gl: WebGLRenderingContext;
  93. private _renderingCanvas;
  94. private _windowIsBackground;
  95. static audioEngine: AudioEngine;
  96. private _onBlur;
  97. private _onFocus;
  98. private _onFullscreenChange;
  99. private _onPointerLockChange;
  100. private _hardwareScalingLevel;
  101. private _caps;
  102. private _pointerLockRequested;
  103. private _alphaTest;
  104. private _resizeLoadingUI;
  105. private _loadingDiv;
  106. private _loadingTextDiv;
  107. private _loadingDivBackgroundColor;
  108. private _drawCalls;
  109. private _glVersion;
  110. private _glRenderer;
  111. private _glVendor;
  112. private _renderingQueueLaunched;
  113. private _activeRenderLoops;
  114. private fpsRange;
  115. private previousFramesDuration;
  116. private fps;
  117. private deltaTime;
  118. private _depthCullingState;
  119. private _alphaState;
  120. private _alphaMode;
  121. private _loadedTexturesCache;
  122. _activeTexturesCache: BaseTexture[];
  123. private _currentEffect;
  124. private _compiledEffects;
  125. private _vertexAttribArrays;
  126. private _cachedViewport;
  127. private _cachedVertexBuffers;
  128. private _cachedIndexBuffer;
  129. private _cachedEffectForVertexBuffers;
  130. private _currentRenderTarget;
  131. private _canvasClientRect;
  132. private _uintIndicesCurrentlySet;
  133. private _workingCanvas;
  134. private _workingContext;
  135. /**
  136. * @constructor
  137. * @param {HTMLCanvasElement} canvas - the canvas to be used for rendering
  138. * @param {boolean} [antialias] - enable antialias
  139. * @param options - further options to be sent to the getContext function
  140. */
  141. constructor(canvas: HTMLCanvasElement, antialias?: boolean, options?: any);
  142. private _prepareWorkingCanvas();
  143. getGlInfo(): {
  144. vendor: string;
  145. renderer: string;
  146. version: string;
  147. };
  148. getAspectRatio(camera: Camera): number;
  149. getRenderWidth(): number;
  150. getRenderHeight(): number;
  151. getRenderingCanvas(): HTMLCanvasElement;
  152. getRenderingCanvasClientRect(): ClientRect;
  153. setHardwareScalingLevel(level: number): void;
  154. getHardwareScalingLevel(): number;
  155. getLoadedTexturesCache(): WebGLTexture[];
  156. getCaps(): EngineCapabilities;
  157. drawCalls: number;
  158. resetDrawCalls(): void;
  159. setDepthFunctionToGreater(): void;
  160. setDepthFunctionToGreaterOrEqual(): void;
  161. setDepthFunctionToLess(): void;
  162. setDepthFunctionToLessOrEqual(): void;
  163. /**
  164. * stop executing a render loop function and remove it from the execution array
  165. * @param {Function} [renderFunction] the function to be removed. If not provided all functions will be removed.
  166. */
  167. stopRenderLoop(renderFunction?: () => void): void;
  168. _renderLoop(): void;
  169. /**
  170. * Register and execute a render loop. The engine can have more than one render function.
  171. * @param {Function} renderFunction - the function to continuesly execute starting the next render loop.
  172. * @example
  173. * engine.runRenderLoop(function () {
  174. * scene.render()
  175. * })
  176. */
  177. runRenderLoop(renderFunction: () => void): void;
  178. /**
  179. * Toggle full screen mode.
  180. * @param {boolean} requestPointerLock - should a pointer lock be requested from the user
  181. */
  182. switchFullscreen(requestPointerLock: boolean): void;
  183. clear(color: any, backBuffer: boolean, depthStencil: boolean): void;
  184. /**
  185. * Set the WebGL's viewport
  186. * @param {BABYLON.Viewport} viewport - the viewport element to be used.
  187. * @param {number} [requiredWidth] - the width required for rendering. If not provided the rendering canvas' width is used.
  188. * @param {number} [requiredHeight] - the height required for rendering. If not provided the rendering canvas' height is used.
  189. */
  190. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  191. setDirectViewport(x: number, y: number, width: number, height: number): void;
  192. beginFrame(): void;
  193. endFrame(): void;
  194. /**
  195. * resize the view according to the canvas' size.
  196. * @example
  197. * window.addEventListener("resize", function () {
  198. * engine.resize();
  199. * });
  200. */
  201. resize(): void;
  202. /**
  203. * force a specific size of the canvas
  204. * @param {number} width - the new canvas' width
  205. * @param {number} height - the new canvas' height
  206. */
  207. setSize(width: number, height: number): void;
  208. bindFramebuffer(texture: WebGLTexture): void;
  209. unBindFramebuffer(texture: WebGLTexture): void;
  210. flushFramebuffer(): void;
  211. restoreDefaultFramebuffer(): void;
  212. private _resetVertexBufferBinding();
  213. createVertexBuffer(vertices: number[]): WebGLBuffer;
  214. createDynamicVertexBuffer(capacity: number): WebGLBuffer;
  215. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: any, offset?: number): void;
  216. private _resetIndexBufferBinding();
  217. createIndexBuffer(indices: number[]): WebGLBuffer;
  218. bindBuffers(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  219. bindMultiBuffers(vertexBuffers: VertexBuffer[], indexBuffer: WebGLBuffer, effect: Effect): void;
  220. _releaseBuffer(buffer: WebGLBuffer): boolean;
  221. createInstancesBuffer(capacity: number): WebGLBuffer;
  222. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  223. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[]): void;
  224. unBindInstancesBuffer(instancesBuffer: WebGLBuffer, offsetLocations: number[]): void;
  225. applyStates(): void;
  226. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  227. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  228. _releaseEffect(effect: Effect): void;
  229. createEffect(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  230. createEffectForParticles(fragmentName: string, uniformsNames?: string[], samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  231. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string): WebGLProgram;
  232. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  233. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  234. enableEffect(effect: Effect): void;
  235. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  236. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  237. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  238. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  239. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  240. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  241. setFloat(uniform: WebGLUniformLocation, value: number): void;
  242. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  243. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  244. setBool(uniform: WebGLUniformLocation, bool: number): void;
  245. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  246. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  247. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  248. setState(culling: boolean, zOffset?: number, force?: boolean): void;
  249. setDepthBuffer(enable: boolean): void;
  250. getDepthWrite(): boolean;
  251. setDepthWrite(enable: boolean): void;
  252. setColorWrite(enable: boolean): void;
  253. setAlphaMode(mode: number): void;
  254. getAlphaMode(): number;
  255. setAlphaTesting(enable: boolean): void;
  256. getAlphaTesting(): boolean;
  257. wipeCaches(): void;
  258. setSamplingMode(texture: WebGLTexture, samplingMode: number): void;
  259. createTexture(url: string, noMipmap: boolean, invertY: boolean, scene: Scene, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any): WebGLTexture;
  260. createRawTexture(data: ArrayBufferView, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number): WebGLTexture;
  261. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): WebGLTexture;
  262. updateTextureSamplingMode(samplingMode: number, texture: WebGLTexture): void;
  263. updateDynamicTexture(texture: WebGLTexture, canvas: HTMLCanvasElement, invertY: boolean): void;
  264. updateVideoTexture(texture: WebGLTexture, video: HTMLVideoElement, invertY: boolean): void;
  265. createRenderTargetTexture(size: any, options: any): WebGLTexture;
  266. createCubeTexture(rootUrl: string, scene: Scene, extensions: string[], noMipmap?: boolean): WebGLTexture;
  267. _releaseTexture(texture: WebGLTexture): void;
  268. bindSamplers(effect: Effect): void;
  269. _bindTexture(channel: number, texture: WebGLTexture): void;
  270. setTextureFromPostProcess(channel: number, postProcess: PostProcess): void;
  271. setTexture(channel: number, texture: BaseTexture): void;
  272. _setAnisotropicLevel(key: number, texture: BaseTexture): void;
  273. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  274. dispose(): void;
  275. displayLoadingUI(): void;
  276. loadingUIText: string;
  277. loadingUIBackgroundColor: string;
  278. hideLoadingUI(): void;
  279. getFps(): number;
  280. getDeltaTime(): number;
  281. private _measureFps();
  282. static isSupported(): boolean;
  283. }
  284. }
  285. interface Window {
  286. mozIndexedDB(func: any): any;
  287. webkitIndexedDB(func: any): any;
  288. IDBTransaction(func: any): any;
  289. webkitIDBTransaction(func: any): any;
  290. msIDBTransaction(func: any): any;
  291. IDBKeyRange(func: any): any;
  292. webkitIDBKeyRange(func: any): any;
  293. msIDBKeyRange(func: any): any;
  294. URL: HTMLURL;
  295. webkitURL: HTMLURL;
  296. webkitRequestAnimationFrame(func: any): any;
  297. mozRequestAnimationFrame(func: any): any;
  298. oRequestAnimationFrame(func: any): any;
  299. WebGLRenderingContext: WebGLRenderingContext;
  300. MSGesture: MSGesture;
  301. CANNON: any;
  302. SIMD: any;
  303. AudioContext: AudioContext;
  304. webkitAudioContext: AudioContext;
  305. }
  306. interface HTMLURL {
  307. createObjectURL(param1: any, param2?: any): any;
  308. }
  309. interface Document {
  310. exitFullscreen(): void;
  311. webkitCancelFullScreen(): void;
  312. mozCancelFullScreen(): void;
  313. msCancelFullScreen(): void;
  314. webkitIsFullScreen: boolean;
  315. mozFullScreen: boolean;
  316. msIsFullScreen: boolean;
  317. fullscreen: boolean;
  318. mozPointerLockElement: HTMLElement;
  319. msPointerLockElement: HTMLElement;
  320. webkitPointerLockElement: HTMLElement;
  321. pointerLockElement: HTMLElement;
  322. }
  323. interface HTMLCanvasElement {
  324. requestPointerLock(): void;
  325. msRequestPointerLock(): void;
  326. mozRequestPointerLock(): void;
  327. webkitRequestPointerLock(): void;
  328. }
  329. interface CanvasRenderingContext2D {
  330. imageSmoothingEnabled: boolean;
  331. mozImageSmoothingEnabled: boolean;
  332. oImageSmoothingEnabled: boolean;
  333. webkitImageSmoothingEnabled: boolean;
  334. }
  335. interface WebGLTexture {
  336. isReady: boolean;
  337. isCube: boolean;
  338. url: string;
  339. noMipmap: boolean;
  340. samplingMode: number;
  341. references: number;
  342. generateMipMaps: boolean;
  343. _size: number;
  344. _baseWidth: number;
  345. _baseHeight: number;
  346. _width: number;
  347. _height: number;
  348. _workingCanvas: HTMLCanvasElement;
  349. _workingContext: CanvasRenderingContext2D;
  350. _framebuffer: WebGLFramebuffer;
  351. _depthBuffer: WebGLRenderbuffer;
  352. _cachedCoordinatesMode: number;
  353. _cachedWrapU: number;
  354. _cachedWrapV: number;
  355. }
  356. interface WebGLBuffer {
  357. references: number;
  358. capacity: number;
  359. is32Bits: boolean;
  360. }
  361. interface MouseEvent {
  362. movementX: number;
  363. movementY: number;
  364. mozMovementX: number;
  365. mozMovementY: number;
  366. webkitMovementX: number;
  367. webkitMovementY: number;
  368. msMovementX: number;
  369. msMovementY: number;
  370. }
  371. interface MSStyleCSSProperties {
  372. webkitTransform: string;
  373. webkitTransition: string;
  374. }
  375. interface Navigator {
  376. getVRDevices: () => any;
  377. mozGetVRDevices: (any) => any;
  378. isCocoonJS: boolean;
  379. }
  380. declare module BABYLON {
  381. /**
  382. * Node is the basic class for all scene objects (Mesh, Light Camera).
  383. */
  384. class Node {
  385. parent: Node;
  386. name: string;
  387. id: string;
  388. uniqueId: number;
  389. state: string;
  390. animations: Animation[];
  391. onReady: (node: Node) => void;
  392. private _childrenFlag;
  393. private _isEnabled;
  394. private _isReady;
  395. _currentRenderId: number;
  396. private _parentRenderId;
  397. _waitingParentId: string;
  398. private _scene;
  399. _cache: any;
  400. /**
  401. * @constructor
  402. * @param {string} name - the name and id to be given to this node
  403. * @param {BABYLON.Scene} the scene this node will be added to
  404. */
  405. constructor(name: string, scene: Scene);
  406. getScene(): Scene;
  407. getEngine(): Engine;
  408. getWorldMatrix(): Matrix;
  409. _initCache(): void;
  410. updateCache(force?: boolean): void;
  411. _updateCache(ignoreParentClass?: boolean): void;
  412. _isSynchronized(): boolean;
  413. _markSyncedWithParent(): void;
  414. isSynchronizedWithParent(): boolean;
  415. isSynchronized(updateCache?: boolean): boolean;
  416. hasNewParent(update?: boolean): boolean;
  417. /**
  418. * Is this node ready to be used/rendered
  419. * @return {boolean} is it ready
  420. */
  421. isReady(): boolean;
  422. /**
  423. * Is this node enabled.
  424. * If the node has a parent and is enabled, the parent will be inspected as well.
  425. * @return {boolean} whether this node (and its parent) is enabled.
  426. * @see setEnabled
  427. */
  428. isEnabled(): boolean;
  429. /**
  430. * Set the enabled state of this node.
  431. * @param {boolean} value - the new enabled state
  432. * @see isEnabled
  433. */
  434. setEnabled(value: boolean): void;
  435. /**
  436. * Is this node a descendant of the given node.
  437. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined.
  438. * @param {BABYLON.Node} ancestor - The parent node to inspect
  439. * @see parent
  440. */
  441. isDescendantOf(ancestor: Node): boolean;
  442. _getDescendants(list: Node[], results: Node[]): void;
  443. /**
  444. * Will return all nodes that have this node as parent.
  445. * @return {BABYLON.Node[]} all children nodes of all types.
  446. */
  447. getDescendants(): Node[];
  448. _setReady(state: boolean): void;
  449. }
  450. }
  451. declare module BABYLON {
  452. interface IDisposable {
  453. dispose(): void;
  454. }
  455. /**
  456. * Represents a scene to be rendered by the engine.
  457. * @see http://doc.babylonjs.com/page.php?p=21911
  458. */
  459. class Scene {
  460. private static _FOGMODE_NONE;
  461. private static _FOGMODE_EXP;
  462. private static _FOGMODE_EXP2;
  463. private static _FOGMODE_LINEAR;
  464. static MinDeltaTime: number;
  465. static MaxDeltaTime: number;
  466. static FOGMODE_NONE: number;
  467. static FOGMODE_EXP: number;
  468. static FOGMODE_EXP2: number;
  469. static FOGMODE_LINEAR: number;
  470. autoClear: boolean;
  471. clearColor: any;
  472. ambientColor: Color3;
  473. /**
  474. * A function to be executed before rendering this scene
  475. * @type {Function}
  476. */
  477. beforeRender: () => void;
  478. /**
  479. * A function to be executed after rendering this scene
  480. * @type {Function}
  481. */
  482. afterRender: () => void;
  483. /**
  484. * A function to be executed when this scene is disposed.
  485. * @type {Function}
  486. */
  487. onDispose: () => void;
  488. beforeCameraRender: (camera: Camera) => void;
  489. afterCameraRender: (camera: Camera) => void;
  490. forceWireframe: boolean;
  491. forcePointsCloud: boolean;
  492. forceShowBoundingBoxes: boolean;
  493. clipPlane: Plane;
  494. animationsEnabled: boolean;
  495. private _onPointerMove;
  496. private _onPointerDown;
  497. private _onPointerUp;
  498. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  499. onPointerUp: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  500. cameraToUseForPointers: Camera;
  501. private _pointerX;
  502. private _pointerY;
  503. private _meshUnderPointer;
  504. private _onKeyDown;
  505. private _onKeyUp;
  506. /**
  507. * is fog enabled on this scene.
  508. * @type {boolean}
  509. */
  510. fogEnabled: boolean;
  511. fogMode: number;
  512. fogColor: Color3;
  513. fogDensity: number;
  514. fogStart: number;
  515. fogEnd: number;
  516. /**
  517. * is shadow enabled on this scene.
  518. * @type {boolean}
  519. */
  520. shadowsEnabled: boolean;
  521. /**
  522. * is light enabled on this scene.
  523. * @type {boolean}
  524. */
  525. lightsEnabled: boolean;
  526. /**
  527. * All of the lights added to this scene.
  528. * @see BABYLON.Light
  529. * @type {BABYLON.Light[]}
  530. */
  531. lights: Light[];
  532. onNewLightAdded: (newLight?: Light, positionInArray?: number, scene?: Scene) => void;
  533. onLightRemoved: (removedLight?: Light) => void;
  534. /**
  535. * All of the cameras added to this scene.
  536. * @see BABYLON.Camera
  537. * @type {BABYLON.Camera[]}
  538. */
  539. cameras: Camera[];
  540. onNewCameraAdded: (newCamera?: Camera, positionInArray?: number, scene?: Scene) => void;
  541. onCameraRemoved: (removedCamera?: Camera) => void;
  542. activeCameras: Camera[];
  543. activeCamera: Camera;
  544. /**
  545. * All of the (abstract) meshes added to this scene.
  546. * @see BABYLON.AbstractMesh
  547. * @type {BABYLON.AbstractMesh[]}
  548. */
  549. meshes: AbstractMesh[];
  550. onNewMeshAdded: (newMesh?: AbstractMesh, positionInArray?: number, scene?: Scene) => void;
  551. onMeshRemoved: (removedMesh?: AbstractMesh) => void;
  552. private _geometries;
  553. onGeometryAdded: (newGeometry?: Geometry) => void;
  554. onGeometryRemoved: (removedGeometry?: Geometry) => void;
  555. materials: Material[];
  556. multiMaterials: MultiMaterial[];
  557. defaultMaterial: StandardMaterial;
  558. texturesEnabled: boolean;
  559. textures: BaseTexture[];
  560. particlesEnabled: boolean;
  561. particleSystems: ParticleSystem[];
  562. spritesEnabled: boolean;
  563. spriteManagers: SpriteManager[];
  564. layers: Layer[];
  565. skeletonsEnabled: boolean;
  566. skeletons: Skeleton[];
  567. lensFlaresEnabled: boolean;
  568. lensFlareSystems: LensFlareSystem[];
  569. collisionsEnabled: boolean;
  570. private _workerCollisions;
  571. collisionCoordinator: ICollisionCoordinator;
  572. gravity: Vector3;
  573. postProcessesEnabled: boolean;
  574. postProcessManager: PostProcessManager;
  575. postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  576. renderTargetsEnabled: boolean;
  577. dumpNextRenderTargets: boolean;
  578. customRenderTargets: RenderTargetTexture[];
  579. useDelayedTextureLoading: boolean;
  580. importedMeshesFiles: String[];
  581. database: any;
  582. /**
  583. * This scene's action manager
  584. * @type {BABYLON.ActionManager}
  585. */
  586. actionManager: ActionManager;
  587. _actionManagers: ActionManager[];
  588. private _meshesForIntersections;
  589. proceduralTexturesEnabled: boolean;
  590. _proceduralTextures: ProceduralTexture[];
  591. mainSoundTrack: SoundTrack;
  592. soundTracks: SoundTrack[];
  593. private _audioEnabled;
  594. private _headphone;
  595. simplificationQueue: SimplificationQueue;
  596. private _engine;
  597. private _totalVertices;
  598. _activeIndices: number;
  599. _activeParticles: number;
  600. private _lastFrameDuration;
  601. private _evaluateActiveMeshesDuration;
  602. private _renderTargetsDuration;
  603. _particlesDuration: number;
  604. private _renderDuration;
  605. _spritesDuration: number;
  606. private _animationRatio;
  607. private _animationStartDate;
  608. _cachedMaterial: Material;
  609. private _renderId;
  610. private _executeWhenReadyTimeoutId;
  611. _toBeDisposed: SmartArray<IDisposable>;
  612. private _onReadyCallbacks;
  613. private _pendingData;
  614. private _onBeforeRenderCallbacks;
  615. private _onAfterRenderCallbacks;
  616. private _activeMeshes;
  617. private _processedMaterials;
  618. private _renderTargets;
  619. _activeParticleSystems: SmartArray<ParticleSystem>;
  620. private _activeSkeletons;
  621. _activeBones: number;
  622. private _renderingManager;
  623. private _physicsEngine;
  624. _activeAnimatables: Animatable[];
  625. private _transformMatrix;
  626. private _pickWithRayInverseMatrix;
  627. private _boundingBoxRenderer;
  628. private _outlineRenderer;
  629. private _viewMatrix;
  630. private _projectionMatrix;
  631. private _frustumPlanes;
  632. private _selectionOctree;
  633. private _pointerOverMesh;
  634. private _debugLayer;
  635. private _depthRenderer;
  636. private _uniqueIdCounter;
  637. /**
  638. * @constructor
  639. * @param {BABYLON.Engine} engine - the engine to be used to render this scene.
  640. */
  641. constructor(engine: Engine);
  642. debugLayer: DebugLayer;
  643. workerCollisions: boolean;
  644. /**
  645. * The mesh that is currently under the pointer.
  646. * @return {BABYLON.AbstractMesh} mesh under the pointer/mouse cursor or null if none.
  647. */
  648. meshUnderPointer: AbstractMesh;
  649. /**
  650. * Current on-screen X position of the pointer
  651. * @return {number} X position of the pointer
  652. */
  653. pointerX: number;
  654. /**
  655. * Current on-screen Y position of the pointer
  656. * @return {number} Y position of the pointer
  657. */
  658. pointerY: number;
  659. getCachedMaterial(): Material;
  660. getBoundingBoxRenderer(): BoundingBoxRenderer;
  661. getOutlineRenderer(): OutlineRenderer;
  662. getEngine(): Engine;
  663. getTotalVertices(): number;
  664. getActiveIndices(): number;
  665. getActiveParticles(): number;
  666. getActiveBones(): number;
  667. getLastFrameDuration(): number;
  668. getEvaluateActiveMeshesDuration(): number;
  669. getActiveMeshes(): SmartArray<Mesh>;
  670. getRenderTargetsDuration(): number;
  671. getRenderDuration(): number;
  672. getParticlesDuration(): number;
  673. getSpritesDuration(): number;
  674. getAnimationRatio(): number;
  675. getRenderId(): number;
  676. incrementRenderId(): void;
  677. private _updatePointerPosition(evt);
  678. attachControl(): void;
  679. detachControl(): void;
  680. isReady(): boolean;
  681. resetCachedMaterial(): void;
  682. registerBeforeRender(func: () => void): void;
  683. unregisterBeforeRender(func: () => void): void;
  684. registerAfterRender(func: () => void): void;
  685. unregisterAfterRender(func: () => void): void;
  686. _addPendingData(data: any): void;
  687. _removePendingData(data: any): void;
  688. getWaitingItemsCount(): number;
  689. /**
  690. * Registers a function to be executed when the scene is ready.
  691. * @param {Function} func - the function to be executed.
  692. */
  693. executeWhenReady(func: () => void): void;
  694. _checkIsReady(): void;
  695. /**
  696. * Will start the animation sequence of a given target
  697. * @param target - the target
  698. * @param {number} from - from which frame should animation start
  699. * @param {number} to - till which frame should animation run.
  700. * @param {boolean} [loop] - should the animation loop
  701. * @param {number} [speedRatio] - the speed in which to run the animation
  702. * @param {Function} [onAnimationEnd] function to be executed when the animation ended.
  703. * @param {BABYLON.Animatable} [animatable] an animatable object. If not provided a new one will be created from the given params.
  704. * @return {BABYLON.Animatable} the animatable object created for this animation
  705. * @see BABYLON.Animatable
  706. * @see http://doc.babylonjs.com/page.php?p=22081
  707. */
  708. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable): Animatable;
  709. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Animatable;
  710. getAnimatableByTarget(target: any): Animatable;
  711. /**
  712. * Will stop the animation of the given target
  713. * @param target - the target
  714. * @see beginAnimation
  715. */
  716. stopAnimation(target: any): void;
  717. private _animate();
  718. getViewMatrix(): Matrix;
  719. getProjectionMatrix(): Matrix;
  720. getTransformMatrix(): Matrix;
  721. setTransformMatrix(view: Matrix, projection: Matrix): void;
  722. addMesh(newMesh: AbstractMesh): void;
  723. removeMesh(toRemove: AbstractMesh): number;
  724. removeLight(toRemove: Light): number;
  725. removeCamera(toRemove: Camera): number;
  726. addLight(newLight: Light): void;
  727. addCamera(newCamera: Camera): void;
  728. /**
  729. * sets the active camera of the scene using its ID
  730. * @param {string} id - the camera's ID
  731. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  732. * @see activeCamera
  733. */
  734. setActiveCameraByID(id: string): Camera;
  735. /**
  736. * sets the active camera of the scene using its name
  737. * @param {string} name - the camera's name
  738. * @return {BABYLON.Camera|null} the new active camera or null if none found.
  739. * @see activeCamera
  740. */
  741. setActiveCameraByName(name: string): Camera;
  742. /**
  743. * get a material using its id
  744. * @param {string} the material's ID
  745. * @return {BABYLON.Material|null} the material or null if none found.
  746. */
  747. getMaterialByID(id: string): Material;
  748. /**
  749. * get a material using its name
  750. * @param {string} the material's name
  751. * @return {BABYLON.Material|null} the material or null if none found.
  752. */
  753. getMaterialByName(name: string): Material;
  754. getCameraByID(id: string): Camera;
  755. getCameraByUniqueID(uniqueId: number): Camera;
  756. /**
  757. * get a camera using its name
  758. * @param {string} the camera's name
  759. * @return {BABYLON.Camera|null} the camera or null if none found.
  760. */
  761. getCameraByName(name: string): Camera;
  762. /**
  763. * get a light node using its name
  764. * @param {string} the light's name
  765. * @return {BABYLON.Light|null} the light or null if none found.
  766. */
  767. getLightByName(name: string): Light;
  768. /**
  769. * get a light node using its ID
  770. * @param {string} the light's id
  771. * @return {BABYLON.Light|null} the light or null if none found.
  772. */
  773. getLightByID(id: string): Light;
  774. /**
  775. * get a light node using its scene-generated unique ID
  776. * @param {number} the light's unique id
  777. * @return {BABYLON.Light|null} the light or null if none found.
  778. */
  779. getLightByUniqueID(uniqueId: number): Light;
  780. /**
  781. * get a geometry using its ID
  782. * @param {string} the geometry's id
  783. * @return {BABYLON.Geometry|null} the geometry or null if none found.
  784. */
  785. getGeometryByID(id: string): Geometry;
  786. /**
  787. * add a new geometry to this scene.
  788. * @param {BABYLON.Geometry} geometry - the geometry to be added to the scene.
  789. * @param {boolean} [force] - force addition, even if a geometry with this ID already exists
  790. * @return {boolean} was the geometry added or not
  791. */
  792. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  793. /**
  794. * Removes an existing geometry
  795. * @param {BABYLON.Geometry} geometry - the geometry to be removed from the scene.
  796. * @return {boolean} was the geometry removed or not
  797. */
  798. removeGeometry(geometry: Geometry): boolean;
  799. getGeometries(): Geometry[];
  800. /**
  801. * Get the first added mesh found of a given ID
  802. * @param {string} id - the id to search for
  803. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  804. */
  805. getMeshByID(id: string): AbstractMesh;
  806. /**
  807. * Get a mesh with its auto-generated unique id
  808. * @param {number} uniqueId - the unique id to search for
  809. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  810. */
  811. getMeshByUniqueID(uniqueId: number): AbstractMesh;
  812. /**
  813. * Get a the last added mesh found of a given ID
  814. * @param {string} id - the id to search for
  815. * @return {BABYLON.AbstractMesh|null} the mesh found or null if not found at all.
  816. */
  817. getLastMeshByID(id: string): AbstractMesh;
  818. /**
  819. * Get a the last added node (Mesh, Camera, Light) found of a given ID
  820. * @param {string} id - the id to search for
  821. * @return {BABYLON.Node|null} the node found or null if not found at all.
  822. */
  823. getLastEntryByID(id: string): Node;
  824. getNodeByName(name: string): Node;
  825. getMeshByName(name: string): AbstractMesh;
  826. getSoundByName(name: string): Sound;
  827. getLastSkeletonByID(id: string): Skeleton;
  828. getSkeletonById(id: string): Skeleton;
  829. getSkeletonByName(name: string): Skeleton;
  830. isActiveMesh(mesh: Mesh): boolean;
  831. private _evaluateSubMesh(subMesh, mesh);
  832. private _evaluateActiveMeshes();
  833. private _activeMesh(mesh);
  834. updateTransformMatrix(force?: boolean): void;
  835. private _renderForCamera(camera);
  836. private _processSubCameras(camera);
  837. private _checkIntersections();
  838. render(): void;
  839. private _updateAudioParameters();
  840. audioEnabled: boolean;
  841. private _disableAudio();
  842. private _enableAudio();
  843. headphone: boolean;
  844. private _switchAudioModeForHeadphones();
  845. private _switchAudioModeForNormalSpeakers();
  846. enableDepthRenderer(): DepthRenderer;
  847. disableDepthRenderer(): void;
  848. dispose(): void;
  849. disposeSounds(): void;
  850. getWorldExtends(): {
  851. min: Vector3;
  852. max: Vector3;
  853. };
  854. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  855. createPickingRay(x: number, y: number, world: Matrix, camera: Camera): Ray;
  856. private _internalPick(rayFunction, predicate, fastCheck?);
  857. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Camera): PickingInfo;
  858. pickWithRay(ray: Ray, predicate: (mesh: Mesh) => boolean, fastCheck?: boolean): PickingInfo;
  859. setPointerOverMesh(mesh: AbstractMesh): void;
  860. getPointerOverMesh(): AbstractMesh;
  861. getPhysicsEngine(): PhysicsEngine;
  862. enablePhysics(gravity: Vector3, plugin?: IPhysicsEnginePlugin): boolean;
  863. disablePhysicsEngine(): void;
  864. isPhysicsEnabled(): boolean;
  865. setGravity(gravity: Vector3): void;
  866. createCompoundImpostor(parts: any, options: PhysicsBodyCreationOptions): any;
  867. deleteCompoundImpostor(compound: any): void;
  868. createDefaultCameraOrLight(): void;
  869. private _getByTags(list, tagsQuery, forEach?);
  870. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  871. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  872. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  873. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  874. }
  875. }
  876. declare module BABYLON {
  877. class Action {
  878. triggerOptions: any;
  879. trigger: number;
  880. _actionManager: ActionManager;
  881. private _nextActiveAction;
  882. private _child;
  883. private _condition;
  884. private _triggerParameter;
  885. constructor(triggerOptions: any, condition?: Condition);
  886. _prepare(): void;
  887. getTriggerParameter(): any;
  888. _executeCurrent(evt: ActionEvent): void;
  889. execute(evt: ActionEvent): void;
  890. then(action: Action): Action;
  891. _getProperty(propertyPath: string): string;
  892. _getEffectiveTarget(target: any, propertyPath: string): any;
  893. }
  894. }
  895. declare module BABYLON {
  896. /**
  897. * ActionEvent is the event beint sent when an action is triggered.
  898. */
  899. class ActionEvent {
  900. source: AbstractMesh;
  901. pointerX: number;
  902. pointerY: number;
  903. meshUnderPointer: AbstractMesh;
  904. sourceEvent: any;
  905. /**
  906. * @constructor
  907. * @param source The mesh that triggered the action.
  908. * @param pointerX the X mouse cursor position at the time of the event
  909. * @param pointerY the Y mouse cursor position at the time of the event
  910. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  911. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  912. */
  913. constructor(source: AbstractMesh, pointerX: number, pointerY: number, meshUnderPointer: AbstractMesh, sourceEvent?: any);
  914. /**
  915. * Helper function to auto-create an ActionEvent from a source mesh.
  916. * @param source the source mesh that triggered the event
  917. * @param evt {Event} The original (browser) event
  918. */
  919. static CreateNew(source: AbstractMesh, evt?: Event): ActionEvent;
  920. /**
  921. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  922. * @param scene the scene where the event occurred
  923. * @param evt {Event} The original (browser) event
  924. */
  925. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  926. }
  927. /**
  928. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  929. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  930. */
  931. class ActionManager {
  932. private static _NothingTrigger;
  933. private static _OnPickTrigger;
  934. private static _OnLeftPickTrigger;
  935. private static _OnRightPickTrigger;
  936. private static _OnCenterPickTrigger;
  937. private static _OnPointerOverTrigger;
  938. private static _OnPointerOutTrigger;
  939. private static _OnEveryFrameTrigger;
  940. private static _OnIntersectionEnterTrigger;
  941. private static _OnIntersectionExitTrigger;
  942. private static _OnKeyDownTrigger;
  943. private static _OnKeyUpTrigger;
  944. private static _OnPickUpTrigger;
  945. static NothingTrigger: number;
  946. static OnPickTrigger: number;
  947. static OnLeftPickTrigger: number;
  948. static OnRightPickTrigger: number;
  949. static OnCenterPickTrigger: number;
  950. static OnPointerOverTrigger: number;
  951. static OnPointerOutTrigger: number;
  952. static OnEveryFrameTrigger: number;
  953. static OnIntersectionEnterTrigger: number;
  954. static OnIntersectionExitTrigger: number;
  955. static OnKeyDownTrigger: number;
  956. static OnKeyUpTrigger: number;
  957. static OnPickUpTrigger: number;
  958. actions: Action[];
  959. private _scene;
  960. constructor(scene: Scene);
  961. dispose(): void;
  962. getScene(): Scene;
  963. /**
  964. * Does this action manager handles actions of any of the given triggers
  965. * @param {number[]} triggers - the triggers to be tested
  966. * @return {boolean} whether one (or more) of the triggers is handeled
  967. */
  968. hasSpecificTriggers(triggers: number[]): boolean;
  969. /**
  970. * Does this action manager handles actions of a given trigger
  971. * @param {number} trigger - the trigger to be tested
  972. * @return {boolean} whether the trigger is handeled
  973. */
  974. hasSpecificTrigger(trigger: number): boolean;
  975. /**
  976. * Does this action manager has pointer triggers
  977. * @return {boolean} whether or not it has pointer triggers
  978. */
  979. hasPointerTriggers: boolean;
  980. /**
  981. * Does this action manager has pick triggers
  982. * @return {boolean} whether or not it has pick triggers
  983. */
  984. hasPickTriggers: boolean;
  985. /**
  986. * Registers an action to this action manager
  987. * @param {BABYLON.Action} action - the action to be registered
  988. * @return {BABYLON.Action} the action amended (prepared) after registration
  989. */
  990. registerAction(action: Action): Action;
  991. /**
  992. * Process a specific trigger
  993. * @param {number} trigger - the trigger to process
  994. * @param evt {BABYLON.ActionEvent} the event details to be processed
  995. */
  996. processTrigger(trigger: number, evt: ActionEvent): void;
  997. _getEffectiveTarget(target: any, propertyPath: string): any;
  998. _getProperty(propertyPath: string): string;
  999. }
  1000. }
  1001. declare module BABYLON {
  1002. class Condition {
  1003. _actionManager: ActionManager;
  1004. _evaluationId: number;
  1005. _currentResult: boolean;
  1006. constructor(actionManager: ActionManager);
  1007. isValid(): boolean;
  1008. _getProperty(propertyPath: string): string;
  1009. _getEffectiveTarget(target: any, propertyPath: string): any;
  1010. }
  1011. class ValueCondition extends Condition {
  1012. propertyPath: string;
  1013. value: any;
  1014. operator: number;
  1015. private static _IsEqual;
  1016. private static _IsDifferent;
  1017. private static _IsGreater;
  1018. private static _IsLesser;
  1019. static IsEqual: number;
  1020. static IsDifferent: number;
  1021. static IsGreater: number;
  1022. static IsLesser: number;
  1023. _actionManager: ActionManager;
  1024. private _target;
  1025. private _property;
  1026. constructor(actionManager: ActionManager, target: any, propertyPath: string, value: any, operator?: number);
  1027. isValid(): boolean;
  1028. }
  1029. class PredicateCondition extends Condition {
  1030. predicate: () => boolean;
  1031. _actionManager: ActionManager;
  1032. constructor(actionManager: ActionManager, predicate: () => boolean);
  1033. isValid(): boolean;
  1034. }
  1035. class StateCondition extends Condition {
  1036. value: string;
  1037. _actionManager: ActionManager;
  1038. private _target;
  1039. constructor(actionManager: ActionManager, target: any, value: string);
  1040. isValid(): boolean;
  1041. }
  1042. }
  1043. declare module BABYLON {
  1044. class SwitchBooleanAction extends Action {
  1045. propertyPath: string;
  1046. private _target;
  1047. private _property;
  1048. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  1049. _prepare(): void;
  1050. execute(): void;
  1051. }
  1052. class SetStateAction extends Action {
  1053. value: string;
  1054. private _target;
  1055. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  1056. execute(): void;
  1057. }
  1058. class SetValueAction extends Action {
  1059. propertyPath: string;
  1060. value: any;
  1061. private _target;
  1062. private _property;
  1063. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1064. _prepare(): void;
  1065. execute(): void;
  1066. }
  1067. class IncrementValueAction extends Action {
  1068. propertyPath: string;
  1069. value: any;
  1070. private _target;
  1071. private _property;
  1072. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  1073. _prepare(): void;
  1074. execute(): void;
  1075. }
  1076. class PlayAnimationAction extends Action {
  1077. from: number;
  1078. to: number;
  1079. loop: boolean;
  1080. private _target;
  1081. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  1082. _prepare(): void;
  1083. execute(): void;
  1084. }
  1085. class StopAnimationAction extends Action {
  1086. private _target;
  1087. constructor(triggerOptions: any, target: any, condition?: Condition);
  1088. _prepare(): void;
  1089. execute(): void;
  1090. }
  1091. class DoNothingAction extends Action {
  1092. constructor(triggerOptions?: any, condition?: Condition);
  1093. execute(): void;
  1094. }
  1095. class CombineAction extends Action {
  1096. children: Action[];
  1097. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  1098. _prepare(): void;
  1099. execute(evt: ActionEvent): void;
  1100. }
  1101. class ExecuteCodeAction extends Action {
  1102. func: (evt: ActionEvent) => void;
  1103. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  1104. execute(evt: ActionEvent): void;
  1105. }
  1106. class SetParentAction extends Action {
  1107. private _parent;
  1108. private _target;
  1109. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  1110. _prepare(): void;
  1111. execute(): void;
  1112. }
  1113. class PlaySoundAction extends Action {
  1114. private _sound;
  1115. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1116. _prepare(): void;
  1117. execute(): void;
  1118. }
  1119. class StopSoundAction extends Action {
  1120. private _sound;
  1121. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  1122. _prepare(): void;
  1123. execute(): void;
  1124. }
  1125. }
  1126. declare module BABYLON {
  1127. class InterpolateValueAction extends Action {
  1128. propertyPath: string;
  1129. value: any;
  1130. duration: number;
  1131. stopOtherAnimations: boolean;
  1132. private _target;
  1133. private _property;
  1134. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean);
  1135. _prepare(): void;
  1136. execute(): void;
  1137. }
  1138. }
  1139. declare module BABYLON {
  1140. class Animatable {
  1141. target: any;
  1142. fromFrame: number;
  1143. toFrame: number;
  1144. loopAnimation: boolean;
  1145. speedRatio: number;
  1146. onAnimationEnd: any;
  1147. private _localDelayOffset;
  1148. private _pausedDelay;
  1149. private _animations;
  1150. private _paused;
  1151. private _scene;
  1152. animationStarted: boolean;
  1153. constructor(scene: Scene, target: any, fromFrame?: number, toFrame?: number, loopAnimation?: boolean, speedRatio?: number, onAnimationEnd?: any, animations?: any);
  1154. appendAnimations(target: any, animations: Animation[]): void;
  1155. getAnimationByTargetProperty(property: string): Animation;
  1156. pause(): void;
  1157. restart(): void;
  1158. stop(): void;
  1159. _animate(delay: number): boolean;
  1160. }
  1161. }
  1162. declare module BABYLON {
  1163. class Animation {
  1164. name: string;
  1165. targetProperty: string;
  1166. framePerSecond: number;
  1167. dataType: number;
  1168. loopMode: number;
  1169. private _keys;
  1170. private _offsetsCache;
  1171. private _highLimitsCache;
  1172. private _stopped;
  1173. _target: any;
  1174. private _easingFunction;
  1175. targetPropertyPath: string[];
  1176. currentFrame: number;
  1177. static CreateAndStartAnimation(name: string, mesh: AbstractMesh, tartgetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number): Animatable;
  1178. constructor(name: string, targetProperty: string, framePerSecond: number, dataType: number, loopMode?: number);
  1179. isStopped(): boolean;
  1180. getKeys(): any[];
  1181. getEasingFunction(): IEasingFunction;
  1182. setEasingFunction(easingFunction: EasingFunction): void;
  1183. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  1184. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  1185. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  1186. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  1187. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  1188. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number): Matrix;
  1189. clone(): Animation;
  1190. setKeys(values: Array<any>): void;
  1191. private _getKeyValue(value);
  1192. private _interpolate(currentFrame, repeatCount, loopMode, offsetValue?, highLimitValue?);
  1193. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number): boolean;
  1194. private static _ANIMATIONTYPE_FLOAT;
  1195. private static _ANIMATIONTYPE_VECTOR3;
  1196. private static _ANIMATIONTYPE_QUATERNION;
  1197. private static _ANIMATIONTYPE_MATRIX;
  1198. private static _ANIMATIONTYPE_COLOR3;
  1199. private static _ANIMATIONTYPE_VECTOR2;
  1200. private static _ANIMATIONLOOPMODE_RELATIVE;
  1201. private static _ANIMATIONLOOPMODE_CYCLE;
  1202. private static _ANIMATIONLOOPMODE_CONSTANT;
  1203. static ANIMATIONTYPE_FLOAT: number;
  1204. static ANIMATIONTYPE_VECTOR3: number;
  1205. static ANIMATIONTYPE_VECTOR2: number;
  1206. static ANIMATIONTYPE_QUATERNION: number;
  1207. static ANIMATIONTYPE_MATRIX: number;
  1208. static ANIMATIONTYPE_COLOR3: number;
  1209. static ANIMATIONLOOPMODE_RELATIVE: number;
  1210. static ANIMATIONLOOPMODE_CYCLE: number;
  1211. static ANIMATIONLOOPMODE_CONSTANT: number;
  1212. }
  1213. }
  1214. declare module BABYLON {
  1215. interface IEasingFunction {
  1216. ease(gradient: number): number;
  1217. }
  1218. class EasingFunction implements IEasingFunction {
  1219. private static _EASINGMODE_EASEIN;
  1220. private static _EASINGMODE_EASEOUT;
  1221. private static _EASINGMODE_EASEINOUT;
  1222. static EASINGMODE_EASEIN: number;
  1223. static EASINGMODE_EASEOUT: number;
  1224. static EASINGMODE_EASEINOUT: number;
  1225. private _easingMode;
  1226. setEasingMode(easingMode: number): void;
  1227. getEasingMode(): number;
  1228. easeInCore(gradient: number): number;
  1229. ease(gradient: number): number;
  1230. }
  1231. class CircleEase extends EasingFunction implements IEasingFunction {
  1232. easeInCore(gradient: number): number;
  1233. }
  1234. class BackEase extends EasingFunction implements IEasingFunction {
  1235. amplitude: number;
  1236. constructor(amplitude?: number);
  1237. easeInCore(gradient: number): number;
  1238. }
  1239. class BounceEase extends EasingFunction implements IEasingFunction {
  1240. bounces: number;
  1241. bounciness: number;
  1242. constructor(bounces?: number, bounciness?: number);
  1243. easeInCore(gradient: number): number;
  1244. }
  1245. class CubicEase extends EasingFunction implements IEasingFunction {
  1246. easeInCore(gradient: number): number;
  1247. }
  1248. class ElasticEase extends EasingFunction implements IEasingFunction {
  1249. oscillations: number;
  1250. springiness: number;
  1251. constructor(oscillations?: number, springiness?: number);
  1252. easeInCore(gradient: number): number;
  1253. }
  1254. class ExponentialEase extends EasingFunction implements IEasingFunction {
  1255. exponent: number;
  1256. constructor(exponent?: number);
  1257. easeInCore(gradient: number): number;
  1258. }
  1259. class PowerEase extends EasingFunction implements IEasingFunction {
  1260. power: number;
  1261. constructor(power?: number);
  1262. easeInCore(gradient: number): number;
  1263. }
  1264. class QuadraticEase extends EasingFunction implements IEasingFunction {
  1265. easeInCore(gradient: number): number;
  1266. }
  1267. class QuarticEase extends EasingFunction implements IEasingFunction {
  1268. easeInCore(gradient: number): number;
  1269. }
  1270. class QuinticEase extends EasingFunction implements IEasingFunction {
  1271. easeInCore(gradient: number): number;
  1272. }
  1273. class SineEase extends EasingFunction implements IEasingFunction {
  1274. easeInCore(gradient: number): number;
  1275. }
  1276. class BezierCurveEase extends EasingFunction implements IEasingFunction {
  1277. x1: number;
  1278. y1: number;
  1279. x2: number;
  1280. y2: number;
  1281. constructor(x1?: number, y1?: number, x2?: number, y2?: number);
  1282. easeInCore(gradient: number): number;
  1283. }
  1284. }
  1285. declare module BABYLON {
  1286. class Analyser {
  1287. SMOOTHING: number;
  1288. FFT_SIZE: number;
  1289. BARGRAPHAMPLITUDE: number;
  1290. DEBUGCANVASPOS: {
  1291. x: number;
  1292. y: number;
  1293. };
  1294. DEBUGCANVASSIZE: {
  1295. width: number;
  1296. height: number;
  1297. };
  1298. private _byteFreqs;
  1299. private _byteTime;
  1300. private _floatFreqs;
  1301. private _webAudioAnalyser;
  1302. private _debugCanvas;
  1303. private _debugCanvasContext;
  1304. private _scene;
  1305. private _registerFunc;
  1306. private _audioEngine;
  1307. constructor(scene: BABYLON.Scene);
  1308. getFrequencyBinCount(): number;
  1309. getByteFrequencyData(): Uint8Array;
  1310. getByteTimeDomainData(): Uint8Array;
  1311. getFloatFrequencyData(): Uint8Array;
  1312. drawDebugCanvas(): void;
  1313. stopDebugCanvas(): void;
  1314. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  1315. dispose(): void;
  1316. }
  1317. }
  1318. declare module BABYLON {
  1319. class AudioEngine {
  1320. private _audioContext;
  1321. private _audioContextInitialized;
  1322. canUseWebAudio: boolean;
  1323. masterGain: GainNode;
  1324. private _connectedAnalyser;
  1325. WarnedWebAudioUnsupported: boolean;
  1326. audioContext: AudioContext;
  1327. constructor();
  1328. private _initializeAudioContext();
  1329. dispose(): void;
  1330. getGlobalVolume(): number;
  1331. setGlobalVolume(newVolume: number): void;
  1332. connectToAnalyser(analyser: Analyser): void;
  1333. }
  1334. }
  1335. declare module BABYLON {
  1336. class Sound {
  1337. name: string;
  1338. autoplay: boolean;
  1339. loop: boolean;
  1340. useCustomAttenuation: boolean;
  1341. soundTrackId: number;
  1342. spatialSound: boolean;
  1343. refDistance: number;
  1344. rolloffFactor: number;
  1345. maxDistance: number;
  1346. distanceModel: string;
  1347. private _panningModel;
  1348. onended: () => any;
  1349. private _playbackRate;
  1350. private _startTime;
  1351. private _startOffset;
  1352. private _position;
  1353. private _localDirection;
  1354. private _volume;
  1355. private _isLoaded;
  1356. private _isReadyToPlay;
  1357. isPlaying: boolean;
  1358. isPaused: boolean;
  1359. private _isDirectional;
  1360. private _readyToPlayCallback;
  1361. private _audioBuffer;
  1362. private _soundSource;
  1363. private _soundPanner;
  1364. private _soundGain;
  1365. private _inputAudioNode;
  1366. private _ouputAudioNode;
  1367. private _coneInnerAngle;
  1368. private _coneOuterAngle;
  1369. private _coneOuterGain;
  1370. private _scene;
  1371. private _connectedMesh;
  1372. private _customAttenuationFunction;
  1373. private _registerFunc;
  1374. /**
  1375. * Create a sound and attach it to a scene
  1376. * @param name Name of your sound
  1377. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer
  1378. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  1379. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel
  1380. */
  1381. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: () => void, options?: any);
  1382. dispose(): void;
  1383. private _soundLoaded(audioData);
  1384. setAudioBuffer(audioBuffer: AudioBuffer): void;
  1385. updateOptions(options: any): void;
  1386. private _createSpatialParameters();
  1387. switchPanningModelToHRTF(): void;
  1388. switchPanningModelToEqualPower(): void;
  1389. private _switchPanningModel();
  1390. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  1391. /**
  1392. * Transform this sound into a directional source
  1393. * @param coneInnerAngle Size of the inner cone in degree
  1394. * @param coneOuterAngle Size of the outer cone in degree
  1395. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  1396. */
  1397. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  1398. setPosition(newPosition: Vector3): void;
  1399. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  1400. private _updateDirection();
  1401. updateDistanceFromListener(): void;
  1402. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  1403. /**
  1404. * Play the sound
  1405. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  1406. */
  1407. play(time?: number): void;
  1408. private _onended();
  1409. /**
  1410. * Stop the sound
  1411. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  1412. */
  1413. stop(time?: number): void;
  1414. pause(): void;
  1415. setVolume(newVolume: number, time?: number): void;
  1416. setPlaybackRate(newPlaybackRate: number): void;
  1417. getVolume(): number;
  1418. attachToMesh(meshToConnectTo: AbstractMesh): void;
  1419. private _onRegisterAfterWorldMatrixUpdate(connectedMesh);
  1420. }
  1421. }
  1422. declare module BABYLON {
  1423. class SoundTrack {
  1424. private _audioEngine;
  1425. private _trackGain;
  1426. private _trackConvolver;
  1427. private _scene;
  1428. id: number;
  1429. soundCollection: Array<BABYLON.Sound>;
  1430. private _isMainTrack;
  1431. private _connectedAnalyser;
  1432. constructor(scene: BABYLON.Scene, options?: any);
  1433. dispose(): void;
  1434. AddSound(sound: BABYLON.Sound): void;
  1435. RemoveSound(sound: BABYLON.Sound): void;
  1436. setVolume(newVolume: number): void;
  1437. switchPanningModelToHRTF(): void;
  1438. switchPanningModelToEqualPower(): void;
  1439. connectToAnalyser(analyser: Analyser): void;
  1440. }
  1441. }
  1442. declare module BABYLON {
  1443. class Bone {
  1444. name: string;
  1445. children: Bone[];
  1446. animations: Animation[];
  1447. private _skeleton;
  1448. private _matrix;
  1449. private _baseMatrix;
  1450. private _worldTransform;
  1451. private _absoluteTransform;
  1452. private _invertedAbsoluteTransform;
  1453. private _parent;
  1454. constructor(name: string, skeleton: Skeleton, parentBone: Bone, matrix: Matrix);
  1455. getParent(): Bone;
  1456. getLocalMatrix(): Matrix;
  1457. getBaseMatrix(): Matrix;
  1458. getWorldMatrix(): Matrix;
  1459. getInvertedAbsoluteTransform(): Matrix;
  1460. getAbsoluteMatrix(): Matrix;
  1461. updateMatrix(matrix: Matrix): void;
  1462. private _updateDifferenceMatrix();
  1463. markAsDirty(): void;
  1464. }
  1465. }
  1466. declare module BABYLON {
  1467. class Skeleton {
  1468. name: string;
  1469. id: string;
  1470. bones: Bone[];
  1471. private _scene;
  1472. private _isDirty;
  1473. private _transformMatrices;
  1474. private _animatables;
  1475. private _identity;
  1476. constructor(name: string, id: string, scene: Scene);
  1477. getTransformMatrices(): Float32Array;
  1478. _markAsDirty(): void;
  1479. prepare(): void;
  1480. getAnimatables(): IAnimatable[];
  1481. clone(name: string, id: string): Skeleton;
  1482. }
  1483. }
  1484. declare module BABYLON {
  1485. class AnaglyphArcRotateCamera extends ArcRotateCamera {
  1486. private _eyeSpace;
  1487. private _leftCamera;
  1488. private _rightCamera;
  1489. constructor(name: string, alpha: number, beta: number, radius: number, target: any, eyeSpace: number, scene: any);
  1490. _update(): void;
  1491. _updateCamera(camera: ArcRotateCamera): void;
  1492. }
  1493. class AnaglyphFreeCamera extends FreeCamera {
  1494. private _eyeSpace;
  1495. private _leftCamera;
  1496. private _rightCamera;
  1497. private _transformMatrix;
  1498. constructor(name: string, position: Vector3, eyeSpace: number, scene: Scene);
  1499. _getSubCameraPosition(eyeSpace: any, result: any): void;
  1500. _update(): void;
  1501. _updateCamera(camera: FreeCamera): void;
  1502. }
  1503. }
  1504. declare module BABYLON {
  1505. class ArcRotateCamera extends Camera {
  1506. alpha: number;
  1507. beta: number;
  1508. radius: number;
  1509. target: any;
  1510. inertialAlphaOffset: number;
  1511. inertialBetaOffset: number;
  1512. inertialRadiusOffset: number;
  1513. lowerAlphaLimit: any;
  1514. upperAlphaLimit: any;
  1515. lowerBetaLimit: number;
  1516. upperBetaLimit: number;
  1517. lowerRadiusLimit: any;
  1518. upperRadiusLimit: any;
  1519. angularSensibility: number;
  1520. wheelPrecision: number;
  1521. pinchPrecision: number;
  1522. keysUp: number[];
  1523. keysDown: number[];
  1524. keysLeft: number[];
  1525. keysRight: number[];
  1526. zoomOnFactor: number;
  1527. targetScreenOffset: Vector2;
  1528. pinchInwards: boolean;
  1529. private _keys;
  1530. private _viewMatrix;
  1531. private _attachedElement;
  1532. private _onPointerDown;
  1533. private _onPointerUp;
  1534. private _onPointerMove;
  1535. private _wheel;
  1536. private _onMouseMove;
  1537. private _onKeyDown;
  1538. private _onKeyUp;
  1539. private _onLostFocus;
  1540. private _reset;
  1541. private _onGestureStart;
  1542. private _onGesture;
  1543. private _MSGestureHandler;
  1544. onCollide: (collidedMesh: AbstractMesh) => void;
  1545. checkCollisions: boolean;
  1546. collisionRadius: Vector3;
  1547. private _collider;
  1548. private _previousPosition;
  1549. private _collisionVelocity;
  1550. private _newPosition;
  1551. private _previousAlpha;
  1552. private _previousBeta;
  1553. private _previousRadius;
  1554. private _collisionTriggered;
  1555. constructor(name: string, alpha: number, beta: number, radius: number, target: any, scene: Scene);
  1556. _getTargetPosition(): Vector3;
  1557. _initCache(): void;
  1558. _updateCache(ignoreParentClass?: boolean): void;
  1559. _isSynchronizedViewMatrix(): boolean;
  1560. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1561. detachControl(element: HTMLElement): void;
  1562. _update(): void;
  1563. setPosition(position: Vector3): void;
  1564. _getViewMatrix(): Matrix;
  1565. private _onCollisionPositionChange;
  1566. zoomOn(meshes?: AbstractMesh[]): void;
  1567. focusOn(meshesOrMinMaxVectorAndDistance: any): void;
  1568. }
  1569. }
  1570. declare module BABYLON {
  1571. class Camera extends Node {
  1572. position: Vector3;
  1573. private static _PERSPECTIVE_CAMERA;
  1574. private static _ORTHOGRAPHIC_CAMERA;
  1575. private static _FOVMODE_VERTICAL_FIXED;
  1576. private static _FOVMODE_HORIZONTAL_FIXED;
  1577. static PERSPECTIVE_CAMERA: number;
  1578. static ORTHOGRAPHIC_CAMERA: number;
  1579. static FOVMODE_VERTICAL_FIXED: number;
  1580. static FOVMODE_HORIZONTAL_FIXED: number;
  1581. upVector: Vector3;
  1582. orthoLeft: any;
  1583. orthoRight: any;
  1584. orthoBottom: any;
  1585. orthoTop: any;
  1586. fov: number;
  1587. minZ: number;
  1588. maxZ: number;
  1589. inertia: number;
  1590. mode: number;
  1591. isIntermediate: boolean;
  1592. viewport: Viewport;
  1593. subCameras: any[];
  1594. layerMask: number;
  1595. fovMode: number;
  1596. private _computedViewMatrix;
  1597. _projectionMatrix: Matrix;
  1598. private _worldMatrix;
  1599. _postProcesses: PostProcess[];
  1600. _postProcessesTakenIndices: any[];
  1601. _activeMeshes: SmartArray<Mesh>;
  1602. private _globalPosition;
  1603. constructor(name: string, position: Vector3, scene: Scene);
  1604. globalPosition: Vector3;
  1605. getActiveMeshes(): SmartArray<Mesh>;
  1606. isActiveMesh(mesh: Mesh): boolean;
  1607. _initCache(): void;
  1608. _updateCache(ignoreParentClass?: boolean): void;
  1609. _updateFromScene(): void;
  1610. _isSynchronized(): boolean;
  1611. _isSynchronizedViewMatrix(): boolean;
  1612. _isSynchronizedProjectionMatrix(): boolean;
  1613. attachControl(element: HTMLElement): void;
  1614. detachControl(element: HTMLElement): void;
  1615. _update(): void;
  1616. attachPostProcess(postProcess: PostProcess, insertAt?: number): number;
  1617. detachPostProcess(postProcess: PostProcess, atIndices?: any): number[];
  1618. getWorldMatrix(): Matrix;
  1619. _getViewMatrix(): Matrix;
  1620. getViewMatrix(force?: boolean): Matrix;
  1621. _computeViewMatrix(force?: boolean): Matrix;
  1622. getProjectionMatrix(force?: boolean): Matrix;
  1623. dispose(): void;
  1624. }
  1625. }
  1626. declare module BABYLON {
  1627. class DeviceOrientationCamera extends FreeCamera {
  1628. private _offsetX;
  1629. private _offsetY;
  1630. private _orientationGamma;
  1631. private _orientationBeta;
  1632. private _initialOrientationGamma;
  1633. private _initialOrientationBeta;
  1634. private _attachedCanvas;
  1635. private _orientationChanged;
  1636. angularSensibility: number;
  1637. moveSensibility: number;
  1638. constructor(name: string, position: Vector3, scene: Scene);
  1639. attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void;
  1640. detachControl(canvas: HTMLCanvasElement): void;
  1641. _checkInputs(): void;
  1642. }
  1643. }
  1644. declare module BABYLON {
  1645. class FollowCamera extends TargetCamera {
  1646. radius: number;
  1647. rotationOffset: number;
  1648. heightOffset: number;
  1649. cameraAcceleration: number;
  1650. maxCameraSpeed: number;
  1651. target: AbstractMesh;
  1652. constructor(name: string, position: Vector3, scene: Scene);
  1653. private getRadians(degrees);
  1654. private follow(cameraTarget);
  1655. _update(): void;
  1656. }
  1657. }
  1658. declare module BABYLON {
  1659. class FreeCamera extends TargetCamera {
  1660. ellipsoid: Vector3;
  1661. keysUp: number[];
  1662. keysDown: number[];
  1663. keysLeft: number[];
  1664. keysRight: number[];
  1665. checkCollisions: boolean;
  1666. applyGravity: boolean;
  1667. angularSensibility: number;
  1668. onCollide: (collidedMesh: AbstractMesh) => void;
  1669. private _keys;
  1670. private _collider;
  1671. private _needMoveForGravity;
  1672. private _oldPosition;
  1673. private _diffPosition;
  1674. private _newPosition;
  1675. private _attachedElement;
  1676. private _localDirection;
  1677. private _transformedDirection;
  1678. private _onMouseDown;
  1679. private _onMouseUp;
  1680. private _onMouseOut;
  1681. private _onMouseMove;
  1682. private _onKeyDown;
  1683. private _onKeyUp;
  1684. _onLostFocus: (e: FocusEvent) => any;
  1685. _waitingLockedTargetId: string;
  1686. constructor(name: string, position: Vector3, scene: Scene);
  1687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1688. detachControl(element: HTMLElement): void;
  1689. _collideWithWorld(velocity: Vector3): void;
  1690. private _onCollisionPositionChange;
  1691. _checkInputs(): void;
  1692. _decideIfNeedsToMove(): boolean;
  1693. _updatePosition(): void;
  1694. _update(): void;
  1695. }
  1696. }
  1697. declare module BABYLON {
  1698. class GamepadCamera extends FreeCamera {
  1699. private _gamepad;
  1700. private _gamepads;
  1701. angularSensibility: number;
  1702. moveSensibility: number;
  1703. constructor(name: string, position: Vector3, scene: Scene);
  1704. private _onNewGameConnected(gamepad);
  1705. _checkInputs(): void;
  1706. dispose(): void;
  1707. }
  1708. }
  1709. declare module BABYLON {
  1710. class TargetCamera extends Camera {
  1711. cameraDirection: Vector3;
  1712. cameraRotation: Vector2;
  1713. rotation: Vector3;
  1714. speed: number;
  1715. noRotationConstraint: boolean;
  1716. lockedTarget: any;
  1717. _currentTarget: Vector3;
  1718. _viewMatrix: Matrix;
  1719. _camMatrix: Matrix;
  1720. _cameraTransformMatrix: Matrix;
  1721. _cameraRotationMatrix: Matrix;
  1722. _referencePoint: Vector3;
  1723. _transformedReferencePoint: Vector3;
  1724. _lookAtTemp: Matrix;
  1725. _tempMatrix: Matrix;
  1726. _reset: () => void;
  1727. _waitingLockedTargetId: string;
  1728. constructor(name: string, position: Vector3, scene: Scene);
  1729. _getLockedTargetPosition(): Vector3;
  1730. _initCache(): void;
  1731. _updateCache(ignoreParentClass?: boolean): void;
  1732. _isSynchronizedViewMatrix(): boolean;
  1733. _computeLocalCameraSpeed(): number;
  1734. setTarget(target: Vector3): void;
  1735. getTarget(): Vector3;
  1736. _decideIfNeedsToMove(): boolean;
  1737. _updatePosition(): void;
  1738. _update(): void;
  1739. _getViewMatrix(): Matrix;
  1740. }
  1741. }
  1742. declare module BABYLON {
  1743. class TouchCamera extends FreeCamera {
  1744. private _offsetX;
  1745. private _offsetY;
  1746. private _pointerCount;
  1747. private _pointerPressed;
  1748. private _attachedCanvas;
  1749. private _onPointerDown;
  1750. private _onPointerUp;
  1751. private _onPointerMove;
  1752. angularSensibility: number;
  1753. moveSensibility: number;
  1754. constructor(name: string, position: Vector3, scene: Scene);
  1755. attachControl(canvas: HTMLCanvasElement, noPreventDefault: boolean): void;
  1756. detachControl(canvas: HTMLCanvasElement): void;
  1757. _checkInputs(): void;
  1758. }
  1759. }
  1760. declare module BABYLON {
  1761. class VirtualJoysticksCamera extends FreeCamera {
  1762. private _leftjoystick;
  1763. private _rightjoystick;
  1764. constructor(name: string, position: Vector3, scene: Scene);
  1765. _checkInputs(): void;
  1766. dispose(): void;
  1767. }
  1768. }
  1769. declare module BABYLON {
  1770. class OculusCamera extends FreeCamera {
  1771. private _leftCamera;
  1772. private _rightCamera;
  1773. private _offsetOrientation;
  1774. private _deviceOrientationHandler;
  1775. constructor(name: string, position: Vector3, scene: Scene);
  1776. _update(): void;
  1777. _updateCamera(camera: FreeCamera): void;
  1778. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1779. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1780. detachControl(element: HTMLElement): void;
  1781. }
  1782. }
  1783. declare module BABYLON {
  1784. class OculusGamepadCamera extends FreeCamera {
  1785. private _leftCamera;
  1786. private _rightCamera;
  1787. private _offsetOrientation;
  1788. private _deviceOrientationHandler;
  1789. private _gamepad;
  1790. private _gamepads;
  1791. angularSensibility: number;
  1792. moveSensibility: number;
  1793. constructor(name: string, position: Vector3, scene: Scene);
  1794. private _onNewGameConnected(gamepad);
  1795. _update(): void;
  1796. _checkInputs(): void;
  1797. _updateCamera(camera: FreeCamera): void;
  1798. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1799. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1800. detachControl(element: HTMLElement): void;
  1801. dispose(): void;
  1802. }
  1803. }
  1804. declare module BABYLON {
  1805. class VRCamera extends FreeCamera {
  1806. private _leftCamera;
  1807. private _rightCamera;
  1808. private _offsetOrientation;
  1809. private _deviceOrientationHandler;
  1810. constructor(name: string, position: Vector3, scene: Scene);
  1811. _update(): void;
  1812. _updateCamera(camera: FreeCamera): void;
  1813. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1814. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1815. detachControl(element: HTMLElement): void;
  1816. }
  1817. }
  1818. declare module BABYLON {
  1819. class VRDeviceOrientationCamera extends BABYLON.VRCamera {
  1820. _alpha: number;
  1821. _beta: number;
  1822. _gamma: number;
  1823. constructor(name: string, position: Vector3, scene: Scene);
  1824. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  1825. }
  1826. }
  1827. declare var HMDVRDevice: any;
  1828. declare var PositionSensorVRDevice: any;
  1829. declare module BABYLON {
  1830. class WebVRCamera extends BABYLON.VRCamera {
  1831. _hmdDevice: any;
  1832. _sensorDevice: any;
  1833. _cacheState: any;
  1834. _cacheQuaternion: Quaternion;
  1835. _cacheRotation: Vector3;
  1836. _vrEnabled: boolean;
  1837. constructor(name: string, position: Vector3, scene: Scene);
  1838. private _getWebVRDevices(devices);
  1839. _update(): void;
  1840. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  1841. detachControl(element: HTMLElement): void;
  1842. }
  1843. }
  1844. declare module BABYLON {
  1845. class Collider {
  1846. radius: Vector3;
  1847. retry: number;
  1848. velocity: Vector3;
  1849. basePoint: Vector3;
  1850. epsilon: number;
  1851. collisionFound: boolean;
  1852. velocityWorldLength: number;
  1853. basePointWorld: Vector3;
  1854. velocityWorld: Vector3;
  1855. normalizedVelocity: Vector3;
  1856. initialVelocity: Vector3;
  1857. initialPosition: Vector3;
  1858. nearestDistance: number;
  1859. intersectionPoint: Vector3;
  1860. collidedMesh: AbstractMesh;
  1861. private _collisionPoint;
  1862. private _planeIntersectionPoint;
  1863. private _tempVector;
  1864. private _tempVector2;
  1865. private _tempVector3;
  1866. private _tempVector4;
  1867. private _edge;
  1868. private _baseToVertex;
  1869. private _destinationPoint;
  1870. private _slidePlaneNormal;
  1871. private _displacementVector;
  1872. _initialize(source: Vector3, dir: Vector3, e: number): void;
  1873. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  1874. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  1875. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  1876. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: number[], indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  1877. _getResponse(pos: Vector3, vel: Vector3): void;
  1878. }
  1879. }
  1880. declare module BABYLON {
  1881. var CollisionWorker: string;
  1882. interface ICollisionCoordinator {
  1883. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: BABYLON.Vector3, collidedMesh?: BABYLON.AbstractMesh) => void, collisionIndex: number): void;
  1884. init(scene: Scene): void;
  1885. destroy(): void;
  1886. onMeshAdded(mesh: AbstractMesh): any;
  1887. onMeshUpdated(mesh: AbstractMesh): any;
  1888. onMeshRemoved(mesh: AbstractMesh): any;
  1889. onGeometryAdded(geometry: Geometry): any;
  1890. onGeometryUpdated(geometry: Geometry): any;
  1891. onGeometryDeleted(geometry: Geometry): any;
  1892. }
  1893. interface SerializedMesh {
  1894. id: string;
  1895. name: string;
  1896. uniqueId: number;
  1897. geometryId: string;
  1898. sphereCenter: Array<number>;
  1899. sphereRadius: number;
  1900. boxMinimum: Array<number>;
  1901. boxMaximum: Array<number>;
  1902. worldMatrixFromCache: any;
  1903. subMeshes: Array<SerializedSubMesh>;
  1904. checkCollisions: boolean;
  1905. }
  1906. interface SerializedSubMesh {
  1907. position: number;
  1908. verticesStart: number;
  1909. verticesCount: number;
  1910. indexStart: number;
  1911. indexCount: number;
  1912. hasMaterial: boolean;
  1913. sphereCenter: Array<number>;
  1914. sphereRadius: number;
  1915. boxMinimum: Array<number>;
  1916. boxMaximum: Array<number>;
  1917. }
  1918. interface SerializedGeometry {
  1919. id: string;
  1920. positions: Float32Array;
  1921. indices: Int32Array;
  1922. normals: Float32Array;
  1923. }
  1924. interface BabylonMessage {
  1925. taskType: WorkerTaskType;
  1926. payload: InitPayload | CollidePayload | UpdatePayload;
  1927. }
  1928. interface SerializedColliderToWorker {
  1929. position: Array<number>;
  1930. velocity: Array<number>;
  1931. radius: Array<number>;
  1932. }
  1933. enum WorkerTaskType {
  1934. INIT = 0,
  1935. UPDATE = 1,
  1936. COLLIDE = 2,
  1937. }
  1938. interface WorkerReply {
  1939. error: WorkerReplyType;
  1940. taskType: WorkerTaskType;
  1941. payload?: any;
  1942. }
  1943. interface CollisionReplyPayload {
  1944. newPosition: Array<number>;
  1945. collisionId: number;
  1946. collidedMeshUniqueId: number;
  1947. }
  1948. interface InitPayload {
  1949. }
  1950. interface CollidePayload {
  1951. collisionId: number;
  1952. collider: SerializedColliderToWorker;
  1953. maximumRetry: number;
  1954. excludedMeshUniqueId?: number;
  1955. }
  1956. interface UpdatePayload {
  1957. updatedMeshes: {
  1958. [n: number]: SerializedMesh;
  1959. };
  1960. updatedGeometries: {
  1961. [s: string]: SerializedGeometry;
  1962. };
  1963. removedMeshes: Array<number>;
  1964. removedGeometries: Array<string>;
  1965. }
  1966. enum WorkerReplyType {
  1967. SUCCESS = 0,
  1968. UNKNOWN_ERROR = 1,
  1969. }
  1970. class CollisionCoordinatorWorker implements ICollisionCoordinator {
  1971. private _scene;
  1972. private _scaledPosition;
  1973. private _scaledVelocity;
  1974. private _collisionsCallbackArray;
  1975. private _init;
  1976. private _runningUpdated;
  1977. private _runningCollisionTask;
  1978. private _worker;
  1979. private _addUpdateMeshesList;
  1980. private _addUpdateGeometriesList;
  1981. private _toRemoveMeshesArray;
  1982. private _toRemoveGeometryArray;
  1983. constructor();
  1984. static SerializeMesh: (mesh: AbstractMesh) => SerializedMesh;
  1985. static SerializeGeometry: (geometry: Geometry) => SerializedGeometry;
  1986. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: BABYLON.Vector3, collidedMesh?: BABYLON.AbstractMesh) => void, collisionIndex: number): void;
  1987. init(scene: Scene): void;
  1988. destroy(): void;
  1989. onMeshAdded(mesh: AbstractMesh): void;
  1990. onMeshUpdated: (mesh: AbstractMesh) => void;
  1991. onMeshRemoved(mesh: AbstractMesh): void;
  1992. onGeometryAdded(geometry: Geometry): void;
  1993. onGeometryUpdated: (geometry: Geometry) => void;
  1994. onGeometryDeleted(geometry: Geometry): void;
  1995. private _afterRender;
  1996. private _onMessageFromWorker;
  1997. }
  1998. class CollisionCoordinatorLegacy implements ICollisionCoordinator {
  1999. private _scene;
  2000. private _scaledPosition;
  2001. private _scaledVelocity;
  2002. private _finalPosition;
  2003. getNewPosition(position: Vector3, velocity: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: BABYLON.Vector3, collidedMesh?: BABYLON.AbstractMesh) => void, collisionIndex: number): void;
  2004. init(scene: Scene): void;
  2005. destroy(): void;
  2006. onMeshAdded(mesh: AbstractMesh): void;
  2007. onMeshUpdated(mesh: AbstractMesh): void;
  2008. onMeshRemoved(mesh: AbstractMesh): void;
  2009. onGeometryAdded(geometry: Geometry): void;
  2010. onGeometryUpdated(geometry: Geometry): void;
  2011. onGeometryDeleted(geometry: Geometry): void;
  2012. private _collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh?);
  2013. }
  2014. }
  2015. declare module BABYLON {
  2016. var WorkerIncluded: boolean;
  2017. class CollisionCache {
  2018. private _meshes;
  2019. private _geometries;
  2020. getMeshes(): {
  2021. [n: number]: SerializedMesh;
  2022. };
  2023. getGeometries(): {
  2024. [s: number]: SerializedGeometry;
  2025. };
  2026. getMesh(id: any): SerializedMesh;
  2027. addMesh(mesh: SerializedMesh): void;
  2028. getGeometry(id: string): SerializedGeometry;
  2029. addGeometry(geometry: SerializedGeometry): void;
  2030. }
  2031. class CollideWorker {
  2032. collider: BABYLON.Collider;
  2033. private _collisionCache;
  2034. private finalPosition;
  2035. private collisionsScalingMatrix;
  2036. private collisionTranformationMatrix;
  2037. constructor(collider: BABYLON.Collider, _collisionCache: CollisionCache, finalPosition: BABYLON.Vector3);
  2038. collideWithWorld(position: BABYLON.Vector3, velocity: BABYLON.Vector3, maximumRetry: number, excludedMeshUniqueId?: number): void;
  2039. private checkCollision(mesh);
  2040. private processCollisionsForSubMeshes(transformMatrix, mesh);
  2041. private collideForSubMesh(subMesh, transformMatrix, meshGeometry);
  2042. private checkSubmeshCollision(subMesh);
  2043. }
  2044. interface ICollisionDetector {
  2045. onInit(payload: InitPayload): void;
  2046. onUpdate(payload: UpdatePayload): void;
  2047. onCollision(payload: CollidePayload): void;
  2048. }
  2049. class CollisionDetectorTransferable implements ICollisionDetector {
  2050. private _collisionCache;
  2051. onInit(payload: InitPayload): void;
  2052. onUpdate(payload: UpdatePayload): void;
  2053. onCollision(payload: CollidePayload): void;
  2054. }
  2055. }
  2056. declare module BABYLON {
  2057. class IntersectionInfo {
  2058. bu: number;
  2059. bv: number;
  2060. distance: number;
  2061. faceId: number;
  2062. subMeshId: number;
  2063. constructor(bu: number, bv: number, distance: number);
  2064. }
  2065. class PickingInfo {
  2066. hit: boolean;
  2067. distance: number;
  2068. pickedPoint: Vector3;
  2069. pickedMesh: AbstractMesh;
  2070. bu: number;
  2071. bv: number;
  2072. faceId: number;
  2073. subMeshId: number;
  2074. getNormal(useWorldCoordinates?: boolean): Vector3;
  2075. getTextureCoordinates(): Vector2;
  2076. }
  2077. }
  2078. declare module BABYLON {
  2079. class BoundingBox {
  2080. minimum: Vector3;
  2081. maximum: Vector3;
  2082. vectors: Vector3[];
  2083. center: Vector3;
  2084. extendSize: Vector3;
  2085. directions: Vector3[];
  2086. vectorsWorld: Vector3[];
  2087. minimumWorld: Vector3;
  2088. maximumWorld: Vector3;
  2089. private _worldMatrix;
  2090. constructor(minimum: Vector3, maximum: Vector3);
  2091. getWorldMatrix(): Matrix;
  2092. _update(world: Matrix): void;
  2093. isInFrustum(frustumPlanes: Plane[]): boolean;
  2094. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2095. intersectsPoint(point: Vector3): boolean;
  2096. intersectsSphere(sphere: BoundingSphere): boolean;
  2097. intersectsMinMax(min: Vector3, max: Vector3): boolean;
  2098. static Intersects(box0: BoundingBox, box1: BoundingBox): boolean;
  2099. static IntersectsSphere(minPoint: Vector3, maxPoint: Vector3, sphereCenter: Vector3, sphereRadius: number): boolean;
  2100. static IsCompletelyInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2101. static IsInFrustum(boundingVectors: Vector3[], frustumPlanes: Plane[]): boolean;
  2102. }
  2103. }
  2104. declare module BABYLON {
  2105. class BoundingInfo {
  2106. minimum: Vector3;
  2107. maximum: Vector3;
  2108. boundingBox: BoundingBox;
  2109. boundingSphere: BoundingSphere;
  2110. constructor(minimum: Vector3, maximum: Vector3);
  2111. _update(world: Matrix): void;
  2112. isInFrustum(frustumPlanes: Plane[]): boolean;
  2113. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  2114. _checkCollision(collider: Collider): boolean;
  2115. intersectsPoint(point: Vector3): boolean;
  2116. intersects(boundingInfo: BoundingInfo, precise: boolean): boolean;
  2117. }
  2118. }
  2119. declare module BABYLON {
  2120. class BoundingSphere {
  2121. minimum: Vector3;
  2122. maximum: Vector3;
  2123. center: Vector3;
  2124. radius: number;
  2125. centerWorld: Vector3;
  2126. radiusWorld: number;
  2127. private _tempRadiusVector;
  2128. constructor(minimum: Vector3, maximum: Vector3);
  2129. _update(world: Matrix): void;
  2130. isInFrustum(frustumPlanes: Plane[]): boolean;
  2131. intersectsPoint(point: Vector3): boolean;
  2132. static Intersects(sphere0: BoundingSphere, sphere1: BoundingSphere): boolean;
  2133. }
  2134. }
  2135. declare module BABYLON {
  2136. interface IOctreeContainer<T> {
  2137. blocks: Array<OctreeBlock<T>>;
  2138. }
  2139. class Octree<T> {
  2140. maxDepth: number;
  2141. blocks: Array<OctreeBlock<T>>;
  2142. dynamicContent: T[];
  2143. private _maxBlockCapacity;
  2144. private _selectionContent;
  2145. private _creationFunc;
  2146. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number, maxDepth?: number);
  2147. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  2148. addMesh(entry: T): void;
  2149. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  2150. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  2151. intersectsRay(ray: Ray): SmartArray<T>;
  2152. 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;
  2153. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  2154. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  2155. }
  2156. }
  2157. declare module BABYLON {
  2158. class OctreeBlock<T> {
  2159. entries: T[];
  2160. blocks: Array<OctreeBlock<T>>;
  2161. private _depth;
  2162. private _maxDepth;
  2163. private _capacity;
  2164. private _minPoint;
  2165. private _maxPoint;
  2166. private _boundingVectors;
  2167. private _creationFunc;
  2168. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  2169. capacity: number;
  2170. minPoint: Vector3;
  2171. maxPoint: Vector3;
  2172. addEntry(entry: T): void;
  2173. addEntries(entries: T[]): void;
  2174. select(frustumPlanes: Plane[], selection: SmartArray<T>, allowDuplicate?: boolean): void;
  2175. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArray<T>, allowDuplicate?: boolean): void;
  2176. intersectsRay(ray: Ray, selection: SmartArray<T>): void;
  2177. createInnerBlocks(): void;
  2178. }
  2179. }
  2180. declare module BABYLON {
  2181. class DebugLayer {
  2182. private _scene;
  2183. private _camera;
  2184. private _transformationMatrix;
  2185. private _enabled;
  2186. private _labelsEnabled;
  2187. private _displayStatistics;
  2188. private _displayTree;
  2189. private _displayLogs;
  2190. private _globalDiv;
  2191. private _statsDiv;
  2192. private _statsSubsetDiv;
  2193. private _optionsDiv;
  2194. private _optionsSubsetDiv;
  2195. private _logDiv;
  2196. private _logSubsetDiv;
  2197. private _treeDiv;
  2198. private _treeSubsetDiv;
  2199. private _drawingCanvas;
  2200. private _drawingContext;
  2201. private _syncPositions;
  2202. private _syncData;
  2203. private _syncUI;
  2204. private _onCanvasClick;
  2205. private _clickPosition;
  2206. private _ratio;
  2207. private _identityMatrix;
  2208. private _showUI;
  2209. private _needToRefreshMeshesTree;
  2210. shouldDisplayLabel: (node: Node) => boolean;
  2211. shouldDisplayAxis: (mesh: Mesh) => boolean;
  2212. axisRatio: number;
  2213. accentColor: string;
  2214. customStatsFunction: () => string;
  2215. constructor(scene: Scene);
  2216. private _refreshMeshesTreeContent();
  2217. private _renderSingleAxis(zero, unit, unitText, label, color);
  2218. private _renderAxis(projectedPosition, mesh, globalViewport);
  2219. private _renderLabel(text, projectedPosition, labelOffset, onClick, getFillStyle);
  2220. private _isClickInsideRect(x, y, width, height);
  2221. isVisible(): boolean;
  2222. hide(): void;
  2223. show(showUI?: boolean, camera?: Camera): void;
  2224. private _clearLabels();
  2225. private _generateheader(root, text);
  2226. private _generateTexBox(root, title, color);
  2227. private _generateAdvancedCheckBox(root, leftTitle, rightTitle, initialState, task, tag?);
  2228. private _generateCheckBox(root, title, initialState, task, tag?);
  2229. private _generateButton(root, title, task, tag?);
  2230. private _generateRadio(root, title, name, initialState, task, tag?);
  2231. private _generateDOMelements();
  2232. private _displayStats();
  2233. }
  2234. }
  2235. declare module BABYLON {
  2236. class Layer {
  2237. name: string;
  2238. texture: Texture;
  2239. isBackground: boolean;
  2240. color: Color4;
  2241. onDispose: () => void;
  2242. private _scene;
  2243. private _vertexDeclaration;
  2244. private _vertexStrideSize;
  2245. private _vertexBuffer;
  2246. private _indexBuffer;
  2247. private _effect;
  2248. constructor(name: string, imgUrl: string, scene: Scene, isBackground?: boolean, color?: Color4);
  2249. render(): void;
  2250. dispose(): void;
  2251. }
  2252. }
  2253. declare module BABYLON {
  2254. class LensFlare {
  2255. size: number;
  2256. position: number;
  2257. color: Color3;
  2258. texture: Texture;
  2259. private _system;
  2260. constructor(size: number, position: number, color: any, imgUrl: string, system: LensFlareSystem);
  2261. dispose: () => void;
  2262. }
  2263. }
  2264. declare module BABYLON {
  2265. class LensFlareSystem {
  2266. name: string;
  2267. lensFlares: LensFlare[];
  2268. borderLimit: number;
  2269. meshesSelectionPredicate: (mesh: Mesh) => boolean;
  2270. private _scene;
  2271. private _emitter;
  2272. private _vertexDeclaration;
  2273. private _vertexStrideSize;
  2274. private _vertexBuffer;
  2275. private _indexBuffer;
  2276. private _effect;
  2277. private _positionX;
  2278. private _positionY;
  2279. private _isEnabled;
  2280. constructor(name: string, emitter: any, scene: Scene);
  2281. isEnabled: boolean;
  2282. getScene(): Scene;
  2283. getEmitter(): any;
  2284. getEmitterPosition(): Vector3;
  2285. computeEffectivePosition(globalViewport: Viewport): boolean;
  2286. _isVisible(): boolean;
  2287. render(): boolean;
  2288. dispose(): void;
  2289. }
  2290. }
  2291. declare module BABYLON {
  2292. class DirectionalLight extends Light implements IShadowLight {
  2293. direction: Vector3;
  2294. position: Vector3;
  2295. private _transformedDirection;
  2296. transformedPosition: Vector3;
  2297. private _worldMatrix;
  2298. shadowOrthoScale: number;
  2299. constructor(name: string, direction: Vector3, scene: Scene);
  2300. getAbsolutePosition(): Vector3;
  2301. setDirectionToTarget(target: Vector3): Vector3;
  2302. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2303. supportsVSM(): boolean;
  2304. needRefreshPerFrame(): boolean;
  2305. computeTransformedPosition(): boolean;
  2306. transferToEffect(effect: Effect, directionUniformName: string): void;
  2307. _getWorldMatrix(): Matrix;
  2308. }
  2309. }
  2310. declare module BABYLON {
  2311. class HemisphericLight extends Light {
  2312. direction: Vector3;
  2313. groundColor: Color3;
  2314. private _worldMatrix;
  2315. constructor(name: string, direction: Vector3, scene: Scene);
  2316. setDirectionToTarget(target: Vector3): Vector3;
  2317. getShadowGenerator(): ShadowGenerator;
  2318. transferToEffect(effect: Effect, directionUniformName: string, groundColorUniformName: string): void;
  2319. _getWorldMatrix(): Matrix;
  2320. }
  2321. }
  2322. declare module BABYLON {
  2323. interface IShadowLight {
  2324. position: Vector3;
  2325. direction: Vector3;
  2326. transformedPosition: Vector3;
  2327. name: string;
  2328. computeTransformedPosition(): boolean;
  2329. getScene(): Scene;
  2330. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2331. supportsVSM(): boolean;
  2332. needRefreshPerFrame(): boolean;
  2333. _shadowGenerator: ShadowGenerator;
  2334. }
  2335. class Light extends Node {
  2336. diffuse: Color3;
  2337. specular: Color3;
  2338. intensity: number;
  2339. range: number;
  2340. includeOnlyWithLayerMask: number;
  2341. includedOnlyMeshes: AbstractMesh[];
  2342. excludedMeshes: AbstractMesh[];
  2343. excludeWithLayerMask: number;
  2344. _shadowGenerator: ShadowGenerator;
  2345. private _parentedWorldMatrix;
  2346. _excludedMeshesIds: string[];
  2347. _includedOnlyMeshesIds: string[];
  2348. constructor(name: string, scene: Scene);
  2349. getShadowGenerator(): ShadowGenerator;
  2350. getAbsolutePosition(): Vector3;
  2351. transferToEffect(effect: Effect, uniformName0?: string, uniformName1?: string): void;
  2352. _getWorldMatrix(): Matrix;
  2353. canAffectMesh(mesh: AbstractMesh): boolean;
  2354. getWorldMatrix(): Matrix;
  2355. dispose(): void;
  2356. }
  2357. }
  2358. declare module BABYLON {
  2359. class PointLight extends Light {
  2360. position: Vector3;
  2361. private _worldMatrix;
  2362. private _transformedPosition;
  2363. constructor(name: string, position: Vector3, scene: Scene);
  2364. getAbsolutePosition(): Vector3;
  2365. transferToEffect(effect: Effect, positionUniformName: string): void;
  2366. getShadowGenerator(): ShadowGenerator;
  2367. _getWorldMatrix(): Matrix;
  2368. }
  2369. }
  2370. declare module BABYLON {
  2371. class SpotLight extends Light implements IShadowLight {
  2372. position: Vector3;
  2373. direction: Vector3;
  2374. angle: number;
  2375. exponent: number;
  2376. transformedPosition: Vector3;
  2377. private _transformedDirection;
  2378. private _worldMatrix;
  2379. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  2380. getAbsolutePosition(): Vector3;
  2381. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  2382. supportsVSM(): boolean;
  2383. needRefreshPerFrame(): boolean;
  2384. setDirectionToTarget(target: Vector3): Vector3;
  2385. computeTransformedPosition(): boolean;
  2386. transferToEffect(effect: Effect, positionUniformName: string, directionUniformName: string): void;
  2387. _getWorldMatrix(): Matrix;
  2388. }
  2389. }
  2390. declare module BABYLON {
  2391. class ShadowGenerator {
  2392. private static _FILTER_NONE;
  2393. private static _FILTER_VARIANCESHADOWMAP;
  2394. private static _FILTER_POISSONSAMPLING;
  2395. private static _FILTER_BLURVARIANCESHADOWMAP;
  2396. static FILTER_NONE: number;
  2397. static FILTER_VARIANCESHADOWMAP: number;
  2398. static FILTER_POISSONSAMPLING: number;
  2399. static FILTER_BLURVARIANCESHADOWMAP: number;
  2400. private _filter;
  2401. blurScale: number;
  2402. private _blurBoxOffset;
  2403. private _bias;
  2404. bias: number;
  2405. blurBoxOffset: number;
  2406. filter: number;
  2407. useVarianceShadowMap: boolean;
  2408. usePoissonSampling: boolean;
  2409. useBlurVarianceShadowMap: boolean;
  2410. private _light;
  2411. private _scene;
  2412. private _shadowMap;
  2413. private _shadowMap2;
  2414. private _darkness;
  2415. private _transparencyShadow;
  2416. private _effect;
  2417. private _viewMatrix;
  2418. private _projectionMatrix;
  2419. private _transformMatrix;
  2420. private _worldViewProjection;
  2421. private _cachedPosition;
  2422. private _cachedDirection;
  2423. private _cachedDefines;
  2424. private _currentRenderID;
  2425. private _downSamplePostprocess;
  2426. private _boxBlurPostprocess;
  2427. private _mapSize;
  2428. constructor(mapSize: number, light: IShadowLight);
  2429. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  2430. getShadowMap(): RenderTargetTexture;
  2431. getShadowMapForRendering(): RenderTargetTexture;
  2432. getLight(): IShadowLight;
  2433. getTransformMatrix(): Matrix;
  2434. getDarkness(): number;
  2435. setDarkness(darkness: number): void;
  2436. setTransparencyShadow(hasShadow: boolean): void;
  2437. private _packHalf(depth);
  2438. dispose(): void;
  2439. }
  2440. }
  2441. declare module BABYLON {
  2442. interface ISceneLoaderPlugin {
  2443. extensions: string;
  2444. importMesh: (meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => boolean;
  2445. load: (scene: Scene, data: string, rootUrl: string) => boolean;
  2446. }
  2447. class SceneLoader {
  2448. private static _ForceFullSceneLoadingForIncremental;
  2449. private static _ShowLoadingScreen;
  2450. static ForceFullSceneLoadingForIncremental: boolean;
  2451. static ShowLoadingScreen: boolean;
  2452. private static _registeredPlugins;
  2453. private static _getPluginForFilename(sceneFilename);
  2454. static RegisterPlugin(plugin: ISceneLoaderPlugin): void;
  2455. static ImportMesh(meshesNames: any, rootUrl: string, sceneFilename: string, scene: Scene, onsuccess?: (meshes: AbstractMesh[], particleSystems: ParticleSystem[], skeletons: Skeleton[]) => void, progressCallBack?: () => void, onerror?: (scene: Scene, e: any) => void): void;
  2456. /**
  2457. * Load a scene
  2458. * @param rootUrl a string that defines the root url for scene and resources
  2459. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  2460. * @param engine is the instance of BABYLON.Engine to use to create the scene
  2461. */
  2462. static Load(rootUrl: string, sceneFilename: any, engine: Engine, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  2463. /**
  2464. * Append a scene
  2465. * @param rootUrl a string that defines the root url for scene and resources
  2466. * @param sceneFilename a string that defines the name of the scene file. can start with "data:" following by the stringified version of the scene
  2467. * @param scene is the instance of BABYLON.Scene to append to
  2468. */
  2469. static Append(rootUrl: string, sceneFilename: any, scene: Scene, onsuccess?: (scene: Scene) => void, progressCallBack?: any, onerror?: (scene: Scene) => void): void;
  2470. }
  2471. }
  2472. declare module BABYLON.Internals {
  2473. }
  2474. declare module BABYLON {
  2475. class EffectFallbacks {
  2476. private _defines;
  2477. private _currentRank;
  2478. private _maxRank;
  2479. addFallback(rank: number, define: string): void;
  2480. isMoreFallbacks: boolean;
  2481. reduce(currentDefines: string): string;
  2482. }
  2483. class Effect {
  2484. name: any;
  2485. defines: string;
  2486. onCompiled: (effect: Effect) => void;
  2487. onError: (effect: Effect, errors: string) => void;
  2488. onBind: (effect: Effect) => void;
  2489. private _engine;
  2490. private _uniformsNames;
  2491. private _samplers;
  2492. private _isReady;
  2493. private _compilationError;
  2494. private _attributesNames;
  2495. private _attributes;
  2496. private _uniforms;
  2497. _key: string;
  2498. private _program;
  2499. private _valueCache;
  2500. constructor(baseName: any, attributesNames: string[], uniformsNames: string[], samplers: string[], engine: any, defines?: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void);
  2501. isReady(): boolean;
  2502. getProgram(): WebGLProgram;
  2503. getAttributesNames(): string[];
  2504. getAttributeLocation(index: number): number;
  2505. getAttributeLocationByName(name: string): number;
  2506. getAttributesCount(): number;
  2507. getUniformIndex(uniformName: string): number;
  2508. getUniform(uniformName: string): WebGLUniformLocation;
  2509. getSamplers(): string[];
  2510. getCompilationError(): string;
  2511. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  2512. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  2513. private _prepareEffect(vertexSourceCode, fragmentSourceCode, attributesNames, defines, fallbacks?);
  2514. _bindTexture(channel: string, texture: WebGLTexture): void;
  2515. setTexture(channel: string, texture: BaseTexture): void;
  2516. setTextureFromPostProcess(channel: string, postProcess: PostProcess): void;
  2517. _cacheFloat2(uniformName: string, x: number, y: number): void;
  2518. _cacheFloat3(uniformName: string, x: number, y: number, z: number): void;
  2519. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): void;
  2520. setArray(uniformName: string, array: number[]): Effect;
  2521. setArray2(uniformName: string, array: number[]): Effect;
  2522. setArray3(uniformName: string, array: number[]): Effect;
  2523. setArray4(uniformName: string, array: number[]): Effect;
  2524. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  2525. setMatrix(uniformName: string, matrix: Matrix): Effect;
  2526. setFloat(uniformName: string, value: number): Effect;
  2527. setBool(uniformName: string, bool: boolean): Effect;
  2528. setVector2(uniformName: string, vector2: Vector2): Effect;
  2529. setFloat2(uniformName: string, x: number, y: number): Effect;
  2530. setVector3(uniformName: string, vector3: Vector3): Effect;
  2531. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  2532. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  2533. setColor3(uniformName: string, color3: Color3): Effect;
  2534. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  2535. static ShadersStore: {};
  2536. }
  2537. }
  2538. declare module BABYLON {
  2539. class Material {
  2540. name: string;
  2541. private static _TriangleFillMode;
  2542. private static _WireFrameFillMode;
  2543. private static _PointFillMode;
  2544. static TriangleFillMode: number;
  2545. static WireFrameFillMode: number;
  2546. static PointFillMode: number;
  2547. id: string;
  2548. checkReadyOnEveryCall: boolean;
  2549. checkReadyOnlyOnce: boolean;
  2550. state: string;
  2551. alpha: number;
  2552. backFaceCulling: boolean;
  2553. onCompiled: (effect: Effect) => void;
  2554. onError: (effect: Effect, errors: string) => void;
  2555. onDispose: () => void;
  2556. onBind: (material: Material, mesh: Mesh) => void;
  2557. getRenderTargetTextures: () => SmartArray<RenderTargetTexture>;
  2558. _effect: Effect;
  2559. _wasPreviouslyReady: boolean;
  2560. private _scene;
  2561. private _fillMode;
  2562. pointSize: number;
  2563. zOffset: number;
  2564. wireframe: boolean;
  2565. pointsCloud: boolean;
  2566. fillMode: number;
  2567. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  2568. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2569. getEffect(): Effect;
  2570. getScene(): Scene;
  2571. needAlphaBlending(): boolean;
  2572. needAlphaTesting(): boolean;
  2573. getAlphaTestTexture(): BaseTexture;
  2574. trackCreation(onCompiled: (effect: Effect) => void, onError: (effect: Effect, errors: string) => void): void;
  2575. _preBind(): void;
  2576. bind(world: Matrix, mesh?: Mesh): void;
  2577. bindOnlyWorldMatrix(world: Matrix): void;
  2578. unbind(): void;
  2579. dispose(forceDisposeEffect?: boolean): void;
  2580. }
  2581. }
  2582. declare module BABYLON {
  2583. class MultiMaterial extends Material {
  2584. subMaterials: Material[];
  2585. constructor(name: string, scene: Scene);
  2586. getSubMaterial(index: any): Material;
  2587. isReady(mesh?: AbstractMesh): boolean;
  2588. clone(name: string): MultiMaterial;
  2589. }
  2590. }
  2591. declare module BABYLON {
  2592. class ShaderMaterial extends Material {
  2593. private _shaderPath;
  2594. private _options;
  2595. private _textures;
  2596. private _floats;
  2597. private _floatsArrays;
  2598. private _colors3;
  2599. private _colors4;
  2600. private _vectors2;
  2601. private _vectors3;
  2602. private _matrices;
  2603. private _cachedWorldViewMatrix;
  2604. private _renderId;
  2605. constructor(name: string, scene: Scene, shaderPath: any, options: any);
  2606. needAlphaBlending(): boolean;
  2607. needAlphaTesting(): boolean;
  2608. private _checkUniform(uniformName);
  2609. setTexture(name: string, texture: Texture): ShaderMaterial;
  2610. setFloat(name: string, value: number): ShaderMaterial;
  2611. setFloats(name: string, value: number[]): ShaderMaterial;
  2612. setColor3(name: string, value: Color3): ShaderMaterial;
  2613. setColor4(name: string, value: Color4): ShaderMaterial;
  2614. setVector2(name: string, value: Vector2): ShaderMaterial;
  2615. setVector3(name: string, value: Vector3): ShaderMaterial;
  2616. setMatrix(name: string, value: Matrix): ShaderMaterial;
  2617. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2618. bindOnlyWorldMatrix(world: Matrix): void;
  2619. bind(world: Matrix, mesh?: Mesh): void;
  2620. dispose(forceDisposeEffect?: boolean): void;
  2621. }
  2622. }
  2623. declare module BABYLON {
  2624. class FresnelParameters {
  2625. isEnabled: boolean;
  2626. leftColor: Color3;
  2627. rightColor: Color3;
  2628. bias: number;
  2629. power: number;
  2630. }
  2631. class StandardMaterial extends Material {
  2632. diffuseTexture: BaseTexture;
  2633. ambientTexture: BaseTexture;
  2634. opacityTexture: BaseTexture;
  2635. reflectionTexture: BaseTexture;
  2636. emissiveTexture: BaseTexture;
  2637. specularTexture: BaseTexture;
  2638. bumpTexture: BaseTexture;
  2639. ambientColor: Color3;
  2640. diffuseColor: Color3;
  2641. specularColor: Color3;
  2642. specularPower: number;
  2643. emissiveColor: Color3;
  2644. useAlphaFromDiffuseTexture: boolean;
  2645. useSpecularOverAlpha: boolean;
  2646. fogEnabled: boolean;
  2647. diffuseFresnelParameters: FresnelParameters;
  2648. opacityFresnelParameters: FresnelParameters;
  2649. reflectionFresnelParameters: FresnelParameters;
  2650. emissiveFresnelParameters: FresnelParameters;
  2651. private _cachedDefines;
  2652. private _renderTargets;
  2653. private _worldViewProjectionMatrix;
  2654. private _globalAmbientColor;
  2655. private _scaledDiffuse;
  2656. private _scaledSpecular;
  2657. private _renderId;
  2658. constructor(name: string, scene: Scene);
  2659. needAlphaBlending(): boolean;
  2660. needAlphaTesting(): boolean;
  2661. private _shouldUseAlphaFromDiffuseTexture();
  2662. getAlphaTestTexture(): BaseTexture;
  2663. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  2664. unbind(): void;
  2665. bindOnlyWorldMatrix(world: Matrix): void;
  2666. bind(world: Matrix, mesh?: Mesh): void;
  2667. getAnimatables(): IAnimatable[];
  2668. dispose(forceDisposeEffect?: boolean): void;
  2669. clone(name: string): StandardMaterial;
  2670. static DiffuseTextureEnabled: boolean;
  2671. static AmbientTextureEnabled: boolean;
  2672. static OpacityTextureEnabled: boolean;
  2673. static ReflectionTextureEnabled: boolean;
  2674. static EmissiveTextureEnabled: boolean;
  2675. static SpecularTextureEnabled: boolean;
  2676. static BumpTextureEnabled: boolean;
  2677. static FresnelEnabled: boolean;
  2678. }
  2679. }
  2680. declare module BABYLON {
  2681. class BaseTexture {
  2682. name: string;
  2683. delayLoadState: number;
  2684. hasAlpha: boolean;
  2685. getAlphaFromRGB: boolean;
  2686. level: number;
  2687. isCube: boolean;
  2688. isRenderTarget: boolean;
  2689. animations: Animation[];
  2690. onDispose: () => void;
  2691. coordinatesIndex: number;
  2692. coordinatesMode: number;
  2693. wrapU: number;
  2694. wrapV: number;
  2695. anisotropicFilteringLevel: number;
  2696. _cachedAnisotropicFilteringLevel: number;
  2697. private _scene;
  2698. _texture: WebGLTexture;
  2699. constructor(scene: Scene);
  2700. getScene(): Scene;
  2701. getTextureMatrix(): Matrix;
  2702. getReflectionTextureMatrix(): Matrix;
  2703. getInternalTexture(): WebGLTexture;
  2704. isReady(): boolean;
  2705. getSize(): ISize;
  2706. getBaseSize(): ISize;
  2707. scale(ratio: number): void;
  2708. canRescale: boolean;
  2709. _removeFromCache(url: string, noMipmap: boolean): void;
  2710. _getFromCache(url: string, noMipmap: boolean, sampling?: number): WebGLTexture;
  2711. delayLoad(): void;
  2712. releaseInternalTexture(): void;
  2713. clone(): BaseTexture;
  2714. dispose(): void;
  2715. }
  2716. }
  2717. declare module BABYLON {
  2718. class CubeTexture extends BaseTexture {
  2719. url: string;
  2720. coordinatesMode: number;
  2721. private _noMipmap;
  2722. private _extensions;
  2723. private _textureMatrix;
  2724. constructor(rootUrl: string, scene: Scene, extensions?: string[], noMipmap?: boolean);
  2725. clone(): CubeTexture;
  2726. delayLoad(): void;
  2727. getReflectionTextureMatrix(): Matrix;
  2728. }
  2729. }
  2730. declare module BABYLON {
  2731. class DynamicTexture extends Texture {
  2732. private _generateMipMaps;
  2733. private _canvas;
  2734. private _context;
  2735. constructor(name: string, options: any, scene: Scene, generateMipMaps: boolean, samplingMode?: number);
  2736. canRescale: boolean;
  2737. scale(ratio: number): void;
  2738. getContext(): CanvasRenderingContext2D;
  2739. clear(): void;
  2740. update(invertY?: boolean): void;
  2741. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  2742. clone(): DynamicTexture;
  2743. }
  2744. }
  2745. declare module BABYLON {
  2746. class MirrorTexture extends RenderTargetTexture {
  2747. mirrorPlane: Plane;
  2748. private _transformMatrix;
  2749. private _mirrorMatrix;
  2750. private _savedViewMatrix;
  2751. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  2752. clone(): MirrorTexture;
  2753. }
  2754. }
  2755. declare module BABYLON {
  2756. class RawTexture extends Texture {
  2757. constructor(data: ArrayBufferView, width: number, height: number, format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number);
  2758. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2759. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2760. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2761. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2762. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  2763. }
  2764. }
  2765. declare module BABYLON {
  2766. class RenderTargetTexture extends Texture {
  2767. renderList: AbstractMesh[];
  2768. renderParticles: boolean;
  2769. renderSprites: boolean;
  2770. coordinatesMode: number;
  2771. onBeforeRender: () => void;
  2772. onAfterRender: () => void;
  2773. onAfterUnbind: () => void;
  2774. onClear: (engine: Engine) => void;
  2775. activeCamera: Camera;
  2776. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  2777. private _size;
  2778. _generateMipMaps: boolean;
  2779. private _renderingManager;
  2780. _waitingRenderList: string[];
  2781. private _doNotChangeAspectRatio;
  2782. private _currentRefreshId;
  2783. private _refreshRate;
  2784. constructor(name: string, size: any, scene: Scene, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number);
  2785. resetRefreshCounter(): void;
  2786. refreshRate: number;
  2787. _shouldRender(): boolean;
  2788. isReady(): boolean;
  2789. getRenderSize(): number;
  2790. canRescale: boolean;
  2791. scale(ratio: number): void;
  2792. resize(size: any, generateMipMaps?: boolean): void;
  2793. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  2794. clone(): RenderTargetTexture;
  2795. }
  2796. }
  2797. declare module BABYLON {
  2798. class Texture extends BaseTexture {
  2799. static NEAREST_SAMPLINGMODE: number;
  2800. static BILINEAR_SAMPLINGMODE: number;
  2801. static TRILINEAR_SAMPLINGMODE: number;
  2802. static EXPLICIT_MODE: number;
  2803. static SPHERICAL_MODE: number;
  2804. static PLANAR_MODE: number;
  2805. static CUBIC_MODE: number;
  2806. static PROJECTION_MODE: number;
  2807. static SKYBOX_MODE: number;
  2808. static CLAMP_ADDRESSMODE: number;
  2809. static WRAP_ADDRESSMODE: number;
  2810. static MIRROR_ADDRESSMODE: number;
  2811. url: string;
  2812. uOffset: number;
  2813. vOffset: number;
  2814. uScale: number;
  2815. vScale: number;
  2816. uAng: number;
  2817. vAng: number;
  2818. wAng: number;
  2819. private _noMipmap;
  2820. _invertY: boolean;
  2821. private _rowGenerationMatrix;
  2822. private _cachedTextureMatrix;
  2823. private _projectionModeMatrix;
  2824. private _t0;
  2825. private _t1;
  2826. private _t2;
  2827. private _cachedUOffset;
  2828. private _cachedVOffset;
  2829. private _cachedUScale;
  2830. private _cachedVScale;
  2831. private _cachedUAng;
  2832. private _cachedVAng;
  2833. private _cachedWAng;
  2834. private _cachedCoordinatesMode;
  2835. _samplingMode: number;
  2836. private _buffer;
  2837. private _deleteBuffer;
  2838. constructor(url: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void, buffer?: any, deleteBuffer?: boolean);
  2839. delayLoad(): void;
  2840. updateSamplingMode(samplingMode: number): void;
  2841. private _prepareRowForTextureGeneration(x, y, z, t);
  2842. getTextureMatrix(): Matrix;
  2843. getReflectionTextureMatrix(): Matrix;
  2844. clone(): Texture;
  2845. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: () => void, onError?: () => void): Texture;
  2846. }
  2847. }
  2848. declare module BABYLON {
  2849. class VideoTexture extends Texture {
  2850. video: HTMLVideoElement;
  2851. private _autoLaunch;
  2852. private _lastUpdate;
  2853. constructor(name: string, urls: string[], size: any, scene: Scene, generateMipMaps: boolean, invertY: boolean, samplingMode?: number);
  2854. update(): boolean;
  2855. }
  2856. }
  2857. declare module BABYLON {
  2858. class CustomProceduralTexture extends ProceduralTexture {
  2859. private _animate;
  2860. private _time;
  2861. private _config;
  2862. private _texturePath;
  2863. constructor(name: string, texturePath: any, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2864. private loadJson(jsonUrl);
  2865. isReady(): boolean;
  2866. render(useCameraPostProcess?: boolean): void;
  2867. updateTextures(): void;
  2868. updateShaderUniforms(): void;
  2869. animate: boolean;
  2870. }
  2871. }
  2872. declare module BABYLON {
  2873. class ProceduralTexture extends Texture {
  2874. private _size;
  2875. _generateMipMaps: boolean;
  2876. private _doNotChangeAspectRatio;
  2877. private _currentRefreshId;
  2878. private _refreshRate;
  2879. private _vertexBuffer;
  2880. private _indexBuffer;
  2881. private _effect;
  2882. private _vertexDeclaration;
  2883. private _vertexStrideSize;
  2884. private _uniforms;
  2885. private _samplers;
  2886. private _fragment;
  2887. _textures: Texture[];
  2888. private _floats;
  2889. private _floatsArrays;
  2890. private _colors3;
  2891. private _colors4;
  2892. private _vectors2;
  2893. private _vectors3;
  2894. private _matrices;
  2895. private _fallbackTexture;
  2896. private _fallbackTextureUsed;
  2897. constructor(name: string, size: any, fragment: any, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2898. reset(): void;
  2899. isReady(): boolean;
  2900. resetRefreshCounter(): void;
  2901. setFragment(fragment: any): void;
  2902. refreshRate: number;
  2903. _shouldRender(): boolean;
  2904. getRenderSize(): number;
  2905. resize(size: any, generateMipMaps: any): void;
  2906. private _checkUniform(uniformName);
  2907. setTexture(name: string, texture: Texture): ProceduralTexture;
  2908. setFloat(name: string, value: number): ProceduralTexture;
  2909. setFloats(name: string, value: number[]): ProceduralTexture;
  2910. setColor3(name: string, value: Color3): ProceduralTexture;
  2911. setColor4(name: string, value: Color4): ProceduralTexture;
  2912. setVector2(name: string, value: Vector2): ProceduralTexture;
  2913. setVector3(name: string, value: Vector3): ProceduralTexture;
  2914. setMatrix(name: string, value: Matrix): ProceduralTexture;
  2915. render(useCameraPostProcess?: boolean): void;
  2916. clone(): ProceduralTexture;
  2917. dispose(): void;
  2918. }
  2919. }
  2920. declare module BABYLON {
  2921. class WoodProceduralTexture extends ProceduralTexture {
  2922. private _ampScale;
  2923. private _woodColor;
  2924. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2925. updateShaderUniforms(): void;
  2926. ampScale: number;
  2927. woodColor: Color3;
  2928. }
  2929. class FireProceduralTexture extends ProceduralTexture {
  2930. private _time;
  2931. private _speed;
  2932. private _autoGenerateTime;
  2933. private _fireColors;
  2934. private _alphaThreshold;
  2935. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2936. updateShaderUniforms(): void;
  2937. render(useCameraPostProcess?: boolean): void;
  2938. static PurpleFireColors: Color3[];
  2939. static GreenFireColors: Color3[];
  2940. static RedFireColors: Color3[];
  2941. static BlueFireColors: Color3[];
  2942. fireColors: Color3[];
  2943. time: number;
  2944. speed: Vector2;
  2945. alphaThreshold: number;
  2946. }
  2947. class CloudProceduralTexture extends ProceduralTexture {
  2948. private _skyColor;
  2949. private _cloudColor;
  2950. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2951. updateShaderUniforms(): void;
  2952. skyColor: Color3;
  2953. cloudColor: Color3;
  2954. }
  2955. class GrassProceduralTexture extends ProceduralTexture {
  2956. private _grassColors;
  2957. private _herb1;
  2958. private _herb2;
  2959. private _herb3;
  2960. private _groundColor;
  2961. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2962. updateShaderUniforms(): void;
  2963. grassColors: Color3[];
  2964. groundColor: Color3;
  2965. }
  2966. class RoadProceduralTexture extends ProceduralTexture {
  2967. private _roadColor;
  2968. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2969. updateShaderUniforms(): void;
  2970. roadColor: Color3;
  2971. }
  2972. class BrickProceduralTexture extends ProceduralTexture {
  2973. private _numberOfBricksHeight;
  2974. private _numberOfBricksWidth;
  2975. private _jointColor;
  2976. private _brickColor;
  2977. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2978. updateShaderUniforms(): void;
  2979. numberOfBricksHeight: number;
  2980. numberOfBricksWidth: number;
  2981. jointColor: Color3;
  2982. brickColor: Color3;
  2983. }
  2984. class MarbleProceduralTexture extends ProceduralTexture {
  2985. private _numberOfTilesHeight;
  2986. private _numberOfTilesWidth;
  2987. private _amplitude;
  2988. private _marbleColor;
  2989. private _jointColor;
  2990. constructor(name: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  2991. updateShaderUniforms(): void;
  2992. numberOfTilesHeight: number;
  2993. numberOfTilesWidth: number;
  2994. jointColor: Color3;
  2995. marbleColor: Color3;
  2996. }
  2997. }
  2998. declare module BABYLON {
  2999. class Color3 {
  3000. r: number;
  3001. g: number;
  3002. b: number;
  3003. constructor(r?: number, g?: number, b?: number);
  3004. toString(): string;
  3005. toArray(array: number[], index?: number): Color3;
  3006. toColor4(alpha?: number): Color4;
  3007. asArray(): number[];
  3008. toLuminance(): number;
  3009. multiply(otherColor: Color3): Color3;
  3010. multiplyToRef(otherColor: Color3, result: Color3): Color3;
  3011. equals(otherColor: Color3): boolean;
  3012. scale(scale: number): Color3;
  3013. scaleToRef(scale: number, result: Color3): Color3;
  3014. add(otherColor: Color3): Color3;
  3015. addToRef(otherColor: Color3, result: Color3): Color3;
  3016. subtract(otherColor: Color3): Color3;
  3017. subtractToRef(otherColor: Color3, result: Color3): Color3;
  3018. clone(): Color3;
  3019. copyFrom(source: Color3): Color3;
  3020. copyFromFloats(r: number, g: number, b: number): Color3;
  3021. static FromArray(array: number[], offset?: number): Color3;
  3022. static FromInts(r: number, g: number, b: number): Color3;
  3023. static Lerp(start: Color3, end: Color3, amount: number): Color3;
  3024. static Red(): Color3;
  3025. static Green(): Color3;
  3026. static Blue(): Color3;
  3027. static Black(): Color3;
  3028. static White(): Color3;
  3029. static Purple(): Color3;
  3030. static Magenta(): Color3;
  3031. static Yellow(): Color3;
  3032. static Gray(): Color3;
  3033. }
  3034. class Color4 {
  3035. r: number;
  3036. g: number;
  3037. b: number;
  3038. a: number;
  3039. constructor(r: number, g: number, b: number, a: number);
  3040. addInPlace(right: any): Color4;
  3041. asArray(): number[];
  3042. toArray(array: number[], index?: number): Color4;
  3043. add(right: Color4): Color4;
  3044. subtract(right: Color4): Color4;
  3045. subtractToRef(right: Color4, result: Color4): Color4;
  3046. scale(scale: number): Color4;
  3047. scaleToRef(scale: number, result: Color4): Color4;
  3048. toString(): string;
  3049. clone(): Color4;
  3050. copyFrom(source: Color4): Color4;
  3051. static Lerp(left: Color4, right: Color4, amount: number): Color4;
  3052. static LerpToRef(left: Color4, right: Color4, amount: number, result: Color4): void;
  3053. static FromArray(array: number[], offset?: number): Color4;
  3054. static FromInts(r: number, g: number, b: number, a: number): Color4;
  3055. }
  3056. class Vector2 {
  3057. x: number;
  3058. y: number;
  3059. constructor(x: number, y: number);
  3060. toString(): string;
  3061. toArray(array: number[], index?: number): Vector2;
  3062. asArray(): number[];
  3063. copyFrom(source: Vector2): Vector2;
  3064. copyFromFloats(x: number, y: number): Vector2;
  3065. add(otherVector: Vector2): Vector2;
  3066. addVector3(otherVector: Vector3): Vector2;
  3067. subtract(otherVector: Vector2): Vector2;
  3068. subtractInPlace(otherVector: Vector2): Vector2;
  3069. multiplyInPlace(otherVector: Vector2): Vector2;
  3070. multiply(otherVector: Vector2): Vector2;
  3071. multiplyToRef(otherVector: Vector2, result: Vector2): Vector2;
  3072. multiplyByFloats(x: number, y: number): Vector2;
  3073. divide(otherVector: Vector2): Vector2;
  3074. divideToRef(otherVector: Vector2, result: Vector2): Vector2;
  3075. negate(): Vector2;
  3076. scaleInPlace(scale: number): Vector2;
  3077. scale(scale: number): Vector2;
  3078. equals(otherVector: Vector2): boolean;
  3079. length(): number;
  3080. lengthSquared(): number;
  3081. normalize(): Vector2;
  3082. clone(): Vector2;
  3083. static Zero(): Vector2;
  3084. static FromArray(array: number[], offset?: number): Vector2;
  3085. static FromArrayToRef(array: number[], offset: number, result: Vector2): void;
  3086. static CatmullRom(value1: Vector2, value2: Vector2, value3: Vector2, value4: Vector2, amount: number): Vector2;
  3087. static Clamp(value: Vector2, min: Vector2, max: Vector2): Vector2;
  3088. static Hermite(value1: Vector2, tangent1: Vector2, value2: Vector2, tangent2: Vector2, amount: number): Vector2;
  3089. static Lerp(start: Vector2, end: Vector2, amount: number): Vector2;
  3090. static Dot(left: Vector2, right: Vector2): number;
  3091. static Normalize(vector: Vector2): Vector2;
  3092. static Minimize(left: Vector2, right: Vector2): Vector2;
  3093. static Maximize(left: Vector2, right: Vector2): Vector2;
  3094. static Transform(vector: Vector2, transformation: Matrix): Vector2;
  3095. static Distance(value1: Vector2, value2: Vector2): number;
  3096. static DistanceSquared(value1: Vector2, value2: Vector2): number;
  3097. }
  3098. class Vector3 {
  3099. x: number;
  3100. y: number;
  3101. z: number;
  3102. constructor(x: number, y: number, z: number);
  3103. toString(): string;
  3104. asArray(): number[];
  3105. toArray(array: number[], index?: number): Vector3;
  3106. toQuaternion(): Quaternion;
  3107. addInPlace(otherVector: Vector3): Vector3;
  3108. add(otherVector: Vector3): Vector3;
  3109. addToRef(otherVector: Vector3, result: Vector3): Vector3;
  3110. subtractInPlace(otherVector: Vector3): Vector3;
  3111. subtract(otherVector: Vector3): Vector3;
  3112. subtractToRef(otherVector: Vector3, result: Vector3): Vector3;
  3113. subtractFromFloats(x: number, y: number, z: number): Vector3;
  3114. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  3115. negate(): Vector3;
  3116. scaleInPlace(scale: number): Vector3;
  3117. scale(scale: number): Vector3;
  3118. scaleToRef(scale: number, result: Vector3): void;
  3119. equals(otherVector: Vector3): boolean;
  3120. equalsWithEpsilon(otherVector: Vector3): boolean;
  3121. equalsToFloats(x: number, y: number, z: number): boolean;
  3122. multiplyInPlace(otherVector: Vector3): Vector3;
  3123. multiply(otherVector: Vector3): Vector3;
  3124. multiplyToRef(otherVector: Vector3, result: Vector3): Vector3;
  3125. multiplyByFloats(x: number, y: number, z: number): Vector3;
  3126. divide(otherVector: Vector3): Vector3;
  3127. divideToRef(otherVector: Vector3, result: Vector3): Vector3;
  3128. MinimizeInPlace(other: Vector3): Vector3;
  3129. MaximizeInPlace(other: Vector3): Vector3;
  3130. length(): number;
  3131. lengthSquared(): number;
  3132. normalize(): Vector3;
  3133. clone(): Vector3;
  3134. copyFrom(source: Vector3): Vector3;
  3135. copyFromFloats(x: number, y: number, z: number): Vector3;
  3136. static GetClipFactor(vector0: Vector3, vector1: Vector3, axis: Vector3, size: any): number;
  3137. static FromArray(array: number[], offset?: number): Vector3;
  3138. static FromArrayToRef(array: number[], offset: number, result: Vector3): void;
  3139. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector3): void;
  3140. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  3141. static Zero(): Vector3;
  3142. static Up(): Vector3;
  3143. static TransformCoordinates(vector: Vector3, transformation: Matrix): Vector3;
  3144. static TransformCoordinatesToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3145. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3146. static TransformCoordinatesToRefSIMD(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3147. static TransformCoordinatesFromFloatsToRefSIMD(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3148. static TransformNormal(vector: Vector3, transformation: Matrix): Vector3;
  3149. static TransformNormalToRef(vector: Vector3, transformation: Matrix, result: Vector3): void;
  3150. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: Matrix, result: Vector3): void;
  3151. static CatmullRom(value1: Vector3, value2: Vector3, value3: Vector3, value4: Vector3, amount: number): Vector3;
  3152. static Clamp(value: Vector3, min: Vector3, max: Vector3): Vector3;
  3153. static Hermite(value1: Vector3, tangent1: Vector3, value2: Vector3, tangent2: Vector3, amount: number): Vector3;
  3154. static Lerp(start: Vector3, end: Vector3, amount: number): Vector3;
  3155. static Dot(left: Vector3, right: Vector3): number;
  3156. static Cross(left: Vector3, right: Vector3): Vector3;
  3157. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  3158. static Normalize(vector: Vector3): Vector3;
  3159. static NormalizeToRef(vector: Vector3, result: Vector3): void;
  3160. static Project(vector: Vector3, world: Matrix, transform: Matrix, viewport: Viewport): Vector3;
  3161. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, transform: Matrix): Vector3;
  3162. static Unproject(source: Vector3, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Vector3;
  3163. static Minimize(left: Vector3, right: Vector3): Vector3;
  3164. static Maximize(left: Vector3, right: Vector3): Vector3;
  3165. static Distance(value1: Vector3, value2: Vector3): number;
  3166. static DistanceSquared(value1: Vector3, value2: Vector3): number;
  3167. static Center(value1: Vector3, value2: Vector3): Vector3;
  3168. }
  3169. class Vector4 {
  3170. x: number;
  3171. y: number;
  3172. z: number;
  3173. w: number;
  3174. constructor(x: number, y: number, z: number, w: number);
  3175. toString(): string;
  3176. asArray(): number[];
  3177. toArray(array: number[], index?: number): Vector4;
  3178. addInPlace(otherVector: Vector4): Vector4;
  3179. add(otherVector: Vector4): Vector4;
  3180. addToRef(otherVector: Vector4, result: Vector4): Vector4;
  3181. subtractInPlace(otherVector: Vector4): Vector4;
  3182. subtract(otherVector: Vector4): Vector4;
  3183. subtractToRef(otherVector: Vector4, result: Vector4): Vector4;
  3184. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3185. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3186. negate(): Vector4;
  3187. scaleInPlace(scale: number): Vector4;
  3188. scale(scale: number): Vector4;
  3189. scaleToRef(scale: number, result: Vector4): void;
  3190. equals(otherVector: Vector4): boolean;
  3191. equalsWithEpsilon(otherVector: Vector4): boolean;
  3192. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3193. multiplyInPlace(otherVector: Vector4): Vector4;
  3194. multiply(otherVector: Vector4): Vector4;
  3195. multiplyToRef(otherVector: Vector4, result: Vector4): Vector4;
  3196. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3197. divide(otherVector: Vector4): Vector4;
  3198. divideToRef(otherVector: Vector4, result: Vector4): Vector4;
  3199. MinimizeInPlace(other: Vector4): Vector4;
  3200. MaximizeInPlace(other: Vector4): Vector4;
  3201. length(): number;
  3202. lengthSquared(): number;
  3203. normalize(): Vector4;
  3204. clone(): Vector4;
  3205. copyFrom(source: Vector4): Vector4;
  3206. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3207. static FromArray(array: number[], offset?: number): Vector4;
  3208. static FromArrayToRef(array: number[], offset: number, result: Vector4): void;
  3209. static FromFloatArrayToRef(array: Float32Array, offset: number, result: Vector4): void;
  3210. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3211. static Zero(): Vector4;
  3212. static Normalize(vector: Vector4): Vector4;
  3213. static NormalizeToRef(vector: Vector4, result: Vector4): void;
  3214. static Minimize(left: Vector4, right: Vector4): Vector4;
  3215. static Maximize(left: Vector4, right: Vector4): Vector4;
  3216. static Distance(value1: Vector4, value2: Vector4): number;
  3217. static DistanceSquared(value1: Vector4, value2: Vector4): number;
  3218. static Center(value1: Vector4, value2: Vector4): Vector4;
  3219. }
  3220. class Quaternion {
  3221. x: number;
  3222. y: number;
  3223. z: number;
  3224. w: number;
  3225. constructor(x?: number, y?: number, z?: number, w?: number);
  3226. toString(): string;
  3227. asArray(): number[];
  3228. equals(otherQuaternion: Quaternion): boolean;
  3229. clone(): Quaternion;
  3230. copyFrom(other: Quaternion): Quaternion;
  3231. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3232. add(other: Quaternion): Quaternion;
  3233. subtract(other: Quaternion): Quaternion;
  3234. scale(value: number): Quaternion;
  3235. multiply(q1: Quaternion): Quaternion;
  3236. multiplyToRef(q1: Quaternion, result: Quaternion): Quaternion;
  3237. length(): number;
  3238. normalize(): Quaternion;
  3239. toEulerAngles(): Vector3;
  3240. toEulerAnglesToRef(result: Vector3): Quaternion;
  3241. toRotationMatrix(result: Matrix): Quaternion;
  3242. fromRotationMatrix(matrix: Matrix): Quaternion;
  3243. static FromRotationMatrix(matrix: Matrix): Quaternion;
  3244. static FromRotationMatrixToRef(matrix: Matrix, result: Quaternion): void;
  3245. static Inverse(q: Quaternion): Quaternion;
  3246. static Identity(): Quaternion;
  3247. static RotationAxis(axis: Vector3, angle: number): Quaternion;
  3248. static FromArray(array: number[], offset?: number): Quaternion;
  3249. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  3250. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  3251. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  3252. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  3253. static Slerp(left: Quaternion, right: Quaternion, amount: number): Quaternion;
  3254. }
  3255. class Matrix {
  3256. private static _tempQuaternion;
  3257. private static _xAxis;
  3258. private static _yAxis;
  3259. private static _zAxis;
  3260. m: Float32Array;
  3261. isIdentity(): boolean;
  3262. determinant(): number;
  3263. toArray(): Float32Array;
  3264. asArray(): Float32Array;
  3265. invert(): Matrix;
  3266. invertToRef(other: Matrix): Matrix;
  3267. invertToRefSIMD(other: Matrix): Matrix;
  3268. setTranslation(vector3: Vector3): Matrix;
  3269. multiply(other: Matrix): Matrix;
  3270. copyFrom(other: Matrix): Matrix;
  3271. copyToArray(array: Float32Array, offset?: number): Matrix;
  3272. multiplyToRef(other: Matrix, result: Matrix): Matrix;
  3273. multiplyToArray(other: Matrix, result: Float32Array, offset: number): Matrix;
  3274. multiplyToArraySIMD(other: Matrix, result: Matrix, offset?: number): void;
  3275. equals(value: Matrix): boolean;
  3276. clone(): Matrix;
  3277. decompose(scale: Vector3, rotation: Quaternion, translation: Vector3): boolean;
  3278. static FromArray(array: number[], offset?: number): Matrix;
  3279. static FromArrayToRef(array: number[], offset: number, result: Matrix): void;
  3280. 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;
  3281. 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;
  3282. static Compose(scale: Vector3, rotation: Quaternion, translation: Vector3): Matrix;
  3283. static Identity(): Matrix;
  3284. static IdentityToRef(result: Matrix): void;
  3285. static Zero(): Matrix;
  3286. static RotationX(angle: number): Matrix;
  3287. static Invert(source: Matrix): Matrix;
  3288. static RotationXToRef(angle: number, result: Matrix): void;
  3289. static RotationY(angle: number): Matrix;
  3290. static RotationYToRef(angle: number, result: Matrix): void;
  3291. static RotationZ(angle: number): Matrix;
  3292. static RotationZToRef(angle: number, result: Matrix): void;
  3293. static RotationAxis(axis: Vector3, angle: number): Matrix;
  3294. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3295. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3296. static Scaling(x: number, y: number, z: number): Matrix;
  3297. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3298. static Translation(x: number, y: number, z: number): Matrix;
  3299. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3300. static LookAtLH(eye: Vector3, target: Vector3, up: Vector3): Matrix;
  3301. static LookAtLHToRef(eye: Vector3, target: Vector3, up: Vector3, result: Matrix): void;
  3302. static LookAtLHToRefSIMD(eyeRef: Vector3, targetRef: Vector3, upRef: Vector3, result: Matrix): void;
  3303. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3304. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3305. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3306. static OrthoOffCenterLHToRef(left: number, right: any, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3307. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3308. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3309. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, fovMode?: number): void;
  3310. static GetFinalMatrix(viewport: Viewport, world: Matrix, view: Matrix, projection: Matrix, zmin: number, zmax: number): Matrix;
  3311. static Transpose(matrix: Matrix): Matrix;
  3312. static Reflection(plane: Plane): Matrix;
  3313. static ReflectionToRef(plane: Plane, result: Matrix): void;
  3314. }
  3315. class Plane {
  3316. normal: Vector3;
  3317. d: number;
  3318. constructor(a: number, b: number, c: number, d: number);
  3319. asArray(): number[];
  3320. clone(): Plane;
  3321. normalize(): Plane;
  3322. transform(transformation: Matrix): Plane;
  3323. dotCoordinate(point: any): number;
  3324. copyFromPoints(point1: Vector3, point2: Vector3, point3: Vector3): Plane;
  3325. isFrontFacingTo(direction: Vector3, epsilon: number): boolean;
  3326. signedDistanceTo(point: Vector3): number;
  3327. static FromArray(array: number[]): Plane;
  3328. static FromPoints(point1: any, point2: any, point3: any): Plane;
  3329. static FromPositionAndNormal(origin: Vector3, normal: Vector3): Plane;
  3330. static SignedDistanceToPlaneFromPositionAndNormal(origin: Vector3, normal: Vector3, point: Vector3): number;
  3331. }
  3332. class Viewport {
  3333. x: number;
  3334. y: number;
  3335. width: number;
  3336. height: number;
  3337. constructor(x: number, y: number, width: number, height: number);
  3338. toGlobal(engine: any): Viewport;
  3339. }
  3340. class Frustum {
  3341. static GetPlanes(transform: Matrix): Plane[];
  3342. static GetPlanesToRef(transform: Matrix, frustumPlanes: Plane[]): void;
  3343. }
  3344. class Ray {
  3345. origin: Vector3;
  3346. direction: Vector3;
  3347. length: number;
  3348. private _edge1;
  3349. private _edge2;
  3350. private _pvec;
  3351. private _tvec;
  3352. private _qvec;
  3353. constructor(origin: Vector3, direction: Vector3, length?: number);
  3354. intersectsBoxMinMax(minimum: Vector3, maximum: Vector3): boolean;
  3355. intersectsBox(box: BoundingBox): boolean;
  3356. intersectsSphere(sphere: any): boolean;
  3357. intersectsTriangle(vertex0: Vector3, vertex1: Vector3, vertex2: Vector3): IntersectionInfo;
  3358. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: Matrix, view: Matrix, projection: Matrix): Ray;
  3359. /**
  3360. * 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
  3361. * transformed to the given world matrix.
  3362. * @param origin The origin point
  3363. * @param end The end point
  3364. * @param world a matrix to transform the ray to. Default is the identity matrix.
  3365. */
  3366. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: Matrix): Ray;
  3367. static Transform(ray: Ray, matrix: Matrix): Ray;
  3368. }
  3369. enum Space {
  3370. LOCAL = 0,
  3371. WORLD = 1,
  3372. }
  3373. class Axis {
  3374. static X: Vector3;
  3375. static Y: Vector3;
  3376. static Z: Vector3;
  3377. }
  3378. class BezierCurve {
  3379. static interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3380. }
  3381. enum Orientation {
  3382. CW = 0,
  3383. CCW = 1,
  3384. }
  3385. class Angle {
  3386. private _radians;
  3387. constructor(radians: number);
  3388. degrees: () => number;
  3389. radians: () => number;
  3390. static BetweenTwoPoints(a: Vector2, b: Vector2): Angle;
  3391. static FromRadians(radians: number): Angle;
  3392. static FromDegrees(degrees: number): Angle;
  3393. }
  3394. class Arc2 {
  3395. startPoint: Vector2;
  3396. midPoint: Vector2;
  3397. endPoint: Vector2;
  3398. centerPoint: Vector2;
  3399. radius: number;
  3400. angle: Angle;
  3401. startAngle: Angle;
  3402. orientation: Orientation;
  3403. constructor(startPoint: Vector2, midPoint: Vector2, endPoint: Vector2);
  3404. }
  3405. class PathCursor {
  3406. private path;
  3407. private _onchange;
  3408. value: number;
  3409. animations: Animation[];
  3410. constructor(path: Path2);
  3411. getPoint(): Vector3;
  3412. moveAhead(step?: number): PathCursor;
  3413. moveBack(step?: number): PathCursor;
  3414. move(step: number): PathCursor;
  3415. private ensureLimits();
  3416. private markAsDirty(propertyName);
  3417. private raiseOnChange();
  3418. onchange(f: (cursor: PathCursor) => void): PathCursor;
  3419. }
  3420. class Path2 {
  3421. private _points;
  3422. private _length;
  3423. closed: boolean;
  3424. constructor(x: number, y: number);
  3425. addLineTo(x: number, y: number): Path2;
  3426. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3427. close(): Path2;
  3428. length(): number;
  3429. getPoints(): Vector2[];
  3430. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3431. static StartingAt(x: number, y: number): Path2;
  3432. }
  3433. class Path3D {
  3434. path: Vector3[];
  3435. private _curve;
  3436. private _distances;
  3437. private _tangents;
  3438. private _normals;
  3439. private _binormals;
  3440. constructor(path: Vector3[], firstNormal?: Vector3);
  3441. getCurve(): Vector3[];
  3442. getTangents(): Vector3[];
  3443. getNormals(): Vector3[];
  3444. getBinormals(): Vector3[];
  3445. getDistances(): number[];
  3446. update(path: Vector3[], firstNormal?: Vector3): Path3D;
  3447. private _compute(firstNormal);
  3448. private _getFirstNonNullVector(index);
  3449. private _getLastNonNullVector(index);
  3450. private _normalVector(v0, vt, va);
  3451. }
  3452. class Curve3 {
  3453. private _points;
  3454. private _length;
  3455. static CreateQuadraticBezier(v0: Vector3, v1: Vector3, v2: Vector3, nbPoints: number): Curve3;
  3456. static CreateCubicBezier(v0: Vector3, v1: Vector3, v2: Vector3, v3: Vector3, nbPoints: number): Curve3;
  3457. static CreateHermiteSpline(p1: Vector3, t1: Vector3, p2: Vector3, t2: Vector3, nbPoints: number): Curve3;
  3458. constructor(points: Vector3[]);
  3459. getPoints(): Vector3[];
  3460. length(): number;
  3461. continue(curve: Curve3): Curve3;
  3462. private _computeLength(path);
  3463. }
  3464. class PositionNormalVertex {
  3465. position: Vector3;
  3466. normal: Vector3;
  3467. constructor(position?: Vector3, normal?: Vector3);
  3468. clone(): PositionNormalVertex;
  3469. }
  3470. class PositionNormalTextureVertex {
  3471. position: Vector3;
  3472. normal: Vector3;
  3473. uv: Vector2;
  3474. constructor(position?: Vector3, normal?: Vector3, uv?: Vector2);
  3475. clone(): PositionNormalTextureVertex;
  3476. }
  3477. class SIMDHelper {
  3478. private static _isEnabled;
  3479. static IsEnabled: boolean;
  3480. static DisableSIMD(): void;
  3481. static EnableSIMD(): void;
  3482. }
  3483. }
  3484. declare module BABYLON {
  3485. class AbstractMesh extends Node implements IDisposable {
  3486. private static _BILLBOARDMODE_NONE;
  3487. private static _BILLBOARDMODE_X;
  3488. private static _BILLBOARDMODE_Y;
  3489. private static _BILLBOARDMODE_Z;
  3490. private static _BILLBOARDMODE_ALL;
  3491. static BILLBOARDMODE_NONE: number;
  3492. static BILLBOARDMODE_X: number;
  3493. static BILLBOARDMODE_Y: number;
  3494. static BILLBOARDMODE_Z: number;
  3495. static BILLBOARDMODE_ALL: number;
  3496. definedFacingForward: boolean;
  3497. position: Vector3;
  3498. rotation: Vector3;
  3499. rotationQuaternion: Quaternion;
  3500. scaling: Vector3;
  3501. billboardMode: number;
  3502. visibility: number;
  3503. alphaIndex: number;
  3504. infiniteDistance: boolean;
  3505. isVisible: boolean;
  3506. isPickable: boolean;
  3507. showBoundingBox: boolean;
  3508. showSubMeshesBoundingBox: boolean;
  3509. onDispose: any;
  3510. checkCollisions: boolean;
  3511. isBlocker: boolean;
  3512. skeleton: Skeleton;
  3513. renderingGroupId: number;
  3514. material: Material;
  3515. receiveShadows: boolean;
  3516. actionManager: ActionManager;
  3517. renderOutline: boolean;
  3518. outlineColor: Color3;
  3519. outlineWidth: number;
  3520. renderOverlay: boolean;
  3521. overlayColor: Color3;
  3522. overlayAlpha: number;
  3523. hasVertexAlpha: boolean;
  3524. useVertexColors: boolean;
  3525. applyFog: boolean;
  3526. useOctreeForRenderingSelection: boolean;
  3527. useOctreeForPicking: boolean;
  3528. useOctreeForCollisions: boolean;
  3529. layerMask: number;
  3530. alwaysSelectAsActiveMesh: boolean;
  3531. _physicImpostor: number;
  3532. _physicsMass: number;
  3533. _physicsFriction: number;
  3534. _physicRestitution: number;
  3535. ellipsoid: Vector3;
  3536. ellipsoidOffset: Vector3;
  3537. private _collider;
  3538. private _oldPositionForCollisions;
  3539. private _diffPositionForCollisions;
  3540. private _newPositionForCollisions;
  3541. private _localScaling;
  3542. private _localRotation;
  3543. private _localTranslation;
  3544. private _localBillboard;
  3545. private _localPivotScaling;
  3546. private _localPivotScalingRotation;
  3547. private _localWorld;
  3548. _worldMatrix: Matrix;
  3549. private _rotateYByPI;
  3550. private _absolutePosition;
  3551. private _collisionsTransformMatrix;
  3552. private _collisionsScalingMatrix;
  3553. _positions: Vector3[];
  3554. private _isDirty;
  3555. _masterMesh: AbstractMesh;
  3556. _boundingInfo: BoundingInfo;
  3557. private _pivotMatrix;
  3558. _isDisposed: boolean;
  3559. _renderId: number;
  3560. subMeshes: SubMesh[];
  3561. _submeshesOctree: Octree<SubMesh>;
  3562. _intersectionsInProgress: AbstractMesh[];
  3563. private _onAfterWorldMatrixUpdate;
  3564. private _isWorldMatrixFrozen;
  3565. _waitingActions: any;
  3566. constructor(name: string, scene: Scene);
  3567. isBlocked: boolean;
  3568. getLOD(camera: Camera): AbstractMesh;
  3569. getTotalVertices(): number;
  3570. getIndices(): number[];
  3571. getVerticesData(kind: string): number[];
  3572. isVerticesDataPresent(kind: string): boolean;
  3573. getBoundingInfo(): BoundingInfo;
  3574. useBones: boolean;
  3575. _preActivate(): void;
  3576. _activate(renderId: number): void;
  3577. getWorldMatrix(): Matrix;
  3578. worldMatrixFromCache: Matrix;
  3579. absolutePosition: Vector3;
  3580. freezeWorldMatrix(): void;
  3581. unfreezeWorldMatrix(): void;
  3582. isWorldMatrixFrozen: boolean;
  3583. rotate(axis: Vector3, amount: number, space: Space): void;
  3584. translate(axis: Vector3, distance: number, space: Space): void;
  3585. getAbsolutePosition(): Vector3;
  3586. setAbsolutePosition(absolutePosition: Vector3): void;
  3587. /**
  3588. * Perform relative position change from the point of view of behind the front of the mesh.
  3589. * This is performed taking into account the meshes current rotation, so you do not have to care.
  3590. * Supports definition of mesh facing forward or backward.
  3591. * @param {number} amountRight
  3592. * @param {number} amountUp
  3593. * @param {number} amountForward
  3594. */
  3595. movePOV(amountRight: number, amountUp: number, amountForward: number): void;
  3596. /**
  3597. * Calculate relative position change from the point of view of behind the front of the mesh.
  3598. * This is performed taking into account the meshes current rotation, so you do not have to care.
  3599. * Supports definition of mesh facing forward or backward.
  3600. * @param {number} amountRight
  3601. * @param {number} amountUp
  3602. * @param {number} amountForward
  3603. */
  3604. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  3605. /**
  3606. * Perform relative rotation change from the point of view of behind the front of the mesh.
  3607. * Supports definition of mesh facing forward or backward.
  3608. * @param {number} flipBack
  3609. * @param {number} twirlClockwise
  3610. * @param {number} tiltRight
  3611. */
  3612. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): void;
  3613. /**
  3614. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  3615. * Supports definition of mesh facing forward or backward.
  3616. * @param {number} flipBack
  3617. * @param {number} twirlClockwise
  3618. * @param {number} tiltRight
  3619. */
  3620. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  3621. setPivotMatrix(matrix: Matrix): void;
  3622. getPivotMatrix(): Matrix;
  3623. _isSynchronized(): boolean;
  3624. _initCache(): void;
  3625. markAsDirty(property: string): void;
  3626. _updateBoundingInfo(): void;
  3627. _updateSubMeshesBoundingInfo(matrix: Matrix): void;
  3628. computeWorldMatrix(force?: boolean): Matrix;
  3629. /**
  3630. * If you'd like to be callbacked after the mesh position, rotation or scaling has been updated
  3631. * @param func: callback function to add
  3632. */
  3633. registerAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  3634. unregisterAfterWorldMatrixUpdate(func: (mesh: AbstractMesh) => void): void;
  3635. setPositionWithLocalVector(vector3: Vector3): void;
  3636. getPositionExpressedInLocalSpace(): Vector3;
  3637. locallyTranslate(vector3: Vector3): void;
  3638. lookAt(targetPoint: Vector3, yawCor: number, pitchCor: number, rollCor: number): void;
  3639. isInFrustum(frustumPlanes: Plane[]): boolean;
  3640. isCompletelyInFrustum(camera?: Camera): boolean;
  3641. intersectsMesh(mesh: AbstractMesh, precise?: boolean): boolean;
  3642. intersectsPoint(point: Vector3): boolean;
  3643. setPhysicsState(impostor?: any, options?: PhysicsBodyCreationOptions): any;
  3644. getPhysicsImpostor(): number;
  3645. getPhysicsMass(): number;
  3646. getPhysicsFriction(): number;
  3647. getPhysicsRestitution(): number;
  3648. getPositionInCameraSpace(camera?: Camera): Vector3;
  3649. getDistanceToCamera(camera?: Camera): number;
  3650. applyImpulse(force: Vector3, contactPoint: Vector3): void;
  3651. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): void;
  3652. updatePhysicsBodyPosition(): void;
  3653. moveWithCollisions(velocity: Vector3): void;
  3654. private _onCollisionPositionChange;
  3655. /**
  3656. * This function will create an octree to help select the right submeshes for rendering, picking and collisions
  3657. * Please note that you must have a decent number of submeshes to get performance improvements when using octree
  3658. */
  3659. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  3660. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): void;
  3661. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): void;
  3662. _checkCollision(collider: Collider): void;
  3663. _generatePointsArray(): boolean;
  3664. intersects(ray: Ray, fastCheck?: boolean): PickingInfo;
  3665. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): AbstractMesh;
  3666. releaseSubMeshes(): void;
  3667. dispose(doNotRecurse?: boolean): void;
  3668. }
  3669. }
  3670. declare module BABYLON {
  3671. class CSG {
  3672. private polygons;
  3673. matrix: Matrix;
  3674. position: Vector3;
  3675. rotation: Vector3;
  3676. scaling: Vector3;
  3677. static FromMesh(mesh: Mesh): CSG;
  3678. private static FromPolygons(polygons);
  3679. clone(): CSG;
  3680. private toPolygons();
  3681. union(csg: CSG): CSG;
  3682. unionInPlace(csg: CSG): void;
  3683. subtract(csg: CSG): CSG;
  3684. subtractInPlace(csg: CSG): void;
  3685. intersect(csg: CSG): CSG;
  3686. intersectInPlace(csg: CSG): void;
  3687. inverse(): CSG;
  3688. inverseInPlace(): void;
  3689. copyTransformAttributes(csg: CSG): CSG;
  3690. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  3691. toMesh(name: string, material: Material, scene: Scene, keepSubMeshes: boolean): Mesh;
  3692. }
  3693. }
  3694. declare module BABYLON {
  3695. class Geometry implements IGetSetVerticesData {
  3696. id: string;
  3697. delayLoadState: number;
  3698. delayLoadingFile: string;
  3699. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  3700. private _scene;
  3701. private _engine;
  3702. private _meshes;
  3703. private _totalVertices;
  3704. private _indices;
  3705. private _vertexBuffers;
  3706. private _isDisposed;
  3707. _delayInfo: any;
  3708. private _indexBuffer;
  3709. _boundingInfo: BoundingInfo;
  3710. _delayLoadingFunction: (any, Geometry) => void;
  3711. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Mesh);
  3712. getScene(): Scene;
  3713. getEngine(): Engine;
  3714. isReady(): boolean;
  3715. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  3716. setVerticesData(kind: string, data: number[], updatable?: boolean, stride?: number): void;
  3717. updateVerticesDataDirectly(kind: string, data: Float32Array, offset: number): void;
  3718. updateVerticesData(kind: string, data: number[], updateExtends?: boolean): void;
  3719. getTotalVertices(): number;
  3720. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  3721. getVertexBuffer(kind: string): VertexBuffer;
  3722. getVertexBuffers(): VertexBuffer[];
  3723. isVerticesDataPresent(kind: string): boolean;
  3724. getVerticesDataKinds(): string[];
  3725. setIndices(indices: number[], totalVertices?: number): void;
  3726. getTotalIndices(): number;
  3727. getIndices(copyWhenShared?: boolean): number[];
  3728. getIndexBuffer(): any;
  3729. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  3730. applyToMesh(mesh: Mesh): void;
  3731. private _applyToMesh(mesh);
  3732. private notifyUpdate(kind?);
  3733. load(scene: Scene, onLoaded?: () => void): void;
  3734. isDisposed(): boolean;
  3735. dispose(): void;
  3736. copy(id: string): Geometry;
  3737. static ExtractFromMesh(mesh: Mesh, id: string): Geometry;
  3738. static RandomId(): string;
  3739. }
  3740. module Geometry.Primitives {
  3741. class _Primitive extends Geometry {
  3742. private _beingRegenerated;
  3743. private _canBeRegenerated;
  3744. constructor(id: string, scene: Scene, vertexData?: VertexData, canBeRegenerated?: boolean, mesh?: Mesh);
  3745. canBeRegenerated(): boolean;
  3746. regenerate(): void;
  3747. asNewGeometry(id: string): Geometry;
  3748. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  3749. setVerticesData(kind: string, data: number[], updatable?: boolean): void;
  3750. _regenerateVertexData(): VertexData;
  3751. copy(id: string): Geometry;
  3752. }
  3753. class Ribbon extends _Primitive {
  3754. pathArray: Vector3[][];
  3755. closeArray: boolean;
  3756. closePath: boolean;
  3757. offset: number;
  3758. side: number;
  3759. constructor(id: string, scene: Scene, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3760. _regenerateVertexData(): VertexData;
  3761. copy(id: string): Geometry;
  3762. }
  3763. class Box extends _Primitive {
  3764. size: number;
  3765. side: number;
  3766. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3767. _regenerateVertexData(): VertexData;
  3768. copy(id: string): Geometry;
  3769. }
  3770. class Sphere extends _Primitive {
  3771. segments: number;
  3772. diameter: number;
  3773. side: number;
  3774. constructor(id: string, scene: Scene, segments: number, diameter: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3775. _regenerateVertexData(): VertexData;
  3776. copy(id: string): Geometry;
  3777. }
  3778. class Cylinder extends _Primitive {
  3779. height: number;
  3780. diameterTop: number;
  3781. diameterBottom: number;
  3782. tessellation: number;
  3783. subdivisions: number;
  3784. side: number;
  3785. constructor(id: string, scene: Scene, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3786. _regenerateVertexData(): VertexData;
  3787. copy(id: string): Geometry;
  3788. }
  3789. class Torus extends _Primitive {
  3790. diameter: number;
  3791. thickness: number;
  3792. tessellation: number;
  3793. side: number;
  3794. constructor(id: string, scene: Scene, diameter: number, thickness: number, tessellation: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3795. _regenerateVertexData(): VertexData;
  3796. copy(id: string): Geometry;
  3797. }
  3798. class Ground extends _Primitive {
  3799. width: number;
  3800. height: number;
  3801. subdivisions: number;
  3802. constructor(id: string, scene: Scene, width: number, height: number, subdivisions: number, canBeRegenerated?: boolean, mesh?: Mesh);
  3803. _regenerateVertexData(): VertexData;
  3804. copy(id: string): Geometry;
  3805. }
  3806. class TiledGround extends _Primitive {
  3807. xmin: number;
  3808. zmin: number;
  3809. xmax: number;
  3810. zmax: number;
  3811. subdivisions: {
  3812. w: number;
  3813. h: number;
  3814. };
  3815. precision: {
  3816. w: number;
  3817. h: number;
  3818. };
  3819. constructor(id: string, scene: Scene, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  3820. w: number;
  3821. h: number;
  3822. }, precision: {
  3823. w: number;
  3824. h: number;
  3825. }, canBeRegenerated?: boolean, mesh?: Mesh);
  3826. _regenerateVertexData(): VertexData;
  3827. copy(id: string): Geometry;
  3828. }
  3829. class Plane extends _Primitive {
  3830. size: number;
  3831. side: number;
  3832. constructor(id: string, scene: Scene, size: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3833. _regenerateVertexData(): VertexData;
  3834. copy(id: string): Geometry;
  3835. }
  3836. class TorusKnot extends _Primitive {
  3837. radius: number;
  3838. tube: number;
  3839. radialSegments: number;
  3840. tubularSegments: number;
  3841. p: number;
  3842. q: number;
  3843. side: number;
  3844. constructor(id: string, scene: Scene, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, canBeRegenerated?: boolean, mesh?: Mesh, side?: number);
  3845. _regenerateVertexData(): VertexData;
  3846. copy(id: string): Geometry;
  3847. }
  3848. }
  3849. }
  3850. declare module BABYLON {
  3851. class GroundMesh extends Mesh {
  3852. generateOctree: boolean;
  3853. private _worldInverse;
  3854. _subdivisions: number;
  3855. constructor(name: string, scene: Scene);
  3856. subdivisions: number;
  3857. optimize(chunksCount: number): void;
  3858. getHeightAtCoordinates(x: number, z: number): number;
  3859. }
  3860. }
  3861. declare module BABYLON {
  3862. /**
  3863. * Creates an instance based on a source mesh.
  3864. */
  3865. class InstancedMesh extends AbstractMesh {
  3866. private _sourceMesh;
  3867. private _currentLOD;
  3868. constructor(name: string, source: Mesh);
  3869. receiveShadows: boolean;
  3870. material: Material;
  3871. visibility: number;
  3872. skeleton: Skeleton;
  3873. getTotalVertices(): number;
  3874. sourceMesh: Mesh;
  3875. getVerticesData(kind: string): number[];
  3876. isVerticesDataPresent(kind: string): boolean;
  3877. getIndices(): number[];
  3878. _positions: Vector3[];
  3879. refreshBoundingInfo(): void;
  3880. _preActivate(): void;
  3881. _activate(renderId: number): void;
  3882. getLOD(camera: Camera): AbstractMesh;
  3883. _syncSubMeshes(): void;
  3884. _generatePointsArray(): boolean;
  3885. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  3886. dispose(doNotRecurse?: boolean): void;
  3887. }
  3888. }
  3889. declare module BABYLON {
  3890. class LinesMesh extends Mesh {
  3891. color: Color3;
  3892. alpha: number;
  3893. private _colorShader;
  3894. private _ib;
  3895. private _indicesLength;
  3896. private _indices;
  3897. constructor(name: string, scene: Scene, updatable?: boolean);
  3898. material: Material;
  3899. isPickable: boolean;
  3900. checkCollisions: boolean;
  3901. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  3902. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  3903. intersects(ray: Ray, fastCheck?: boolean): any;
  3904. dispose(doNotRecurse?: boolean): void;
  3905. }
  3906. }
  3907. declare module BABYLON {
  3908. class _InstancesBatch {
  3909. mustReturn: boolean;
  3910. visibleInstances: InstancedMesh[][];
  3911. renderSelf: boolean[];
  3912. }
  3913. class Mesh extends AbstractMesh implements IGetSetVerticesData {
  3914. static _FRONTSIDE: number;
  3915. static _BACKSIDE: number;
  3916. static _DOUBLESIDE: number;
  3917. static _DEFAULTSIDE: number;
  3918. static _NO_CAP: number;
  3919. static _CAP_START: number;
  3920. static _CAP_END: number;
  3921. static _CAP_ALL: number;
  3922. static FRONTSIDE: number;
  3923. static BACKSIDE: number;
  3924. static DOUBLESIDE: number;
  3925. static DEFAULTSIDE: number;
  3926. static NO_CAP: number;
  3927. static CAP_START: number;
  3928. static CAP_END: number;
  3929. static CAP_ALL: number;
  3930. delayLoadState: number;
  3931. instances: InstancedMesh[];
  3932. delayLoadingFile: string;
  3933. _binaryInfo: any;
  3934. private _LODLevels;
  3935. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Mesh) => void;
  3936. _geometry: Geometry;
  3937. private _onBeforeRenderCallbacks;
  3938. private _onAfterRenderCallbacks;
  3939. _delayInfo: any;
  3940. _delayLoadingFunction: (any, Mesh) => void;
  3941. _visibleInstances: any;
  3942. private _renderIdForInstances;
  3943. private _batchCache;
  3944. private _worldMatricesInstancesBuffer;
  3945. private _worldMatricesInstancesArray;
  3946. private _instancesBufferSize;
  3947. _shouldGenerateFlatShading: boolean;
  3948. private _preActivateId;
  3949. private _sideOrientation;
  3950. private _areNormalsFrozen;
  3951. /**
  3952. * @constructor
  3953. * @param {string} name - The value used by scene.getMeshByName() to do a lookup.
  3954. * @param {Scene} scene - The scene to add this mesh to.
  3955. * @param {Node} parent - The parent of this mesh, if it has one
  3956. * @param {Mesh} source - An optional Mesh from which geometry is shared, cloned.
  3957. * @param {boolean} doNotCloneChildren - When cloning, skip cloning child meshes of source, default False.
  3958. * When false, achieved by calling a clone(), also passing False.
  3959. * This will make creation of children, recursive.
  3960. */
  3961. constructor(name: string, scene: Scene, parent?: Node, source?: Mesh, doNotCloneChildren?: boolean);
  3962. hasLODLevels: boolean;
  3963. private _sortLODLevels();
  3964. /**
  3965. * Add a mesh as LOD level triggered at the given distance.
  3966. * @param {number} distance - the distance from the center of the object to show this level
  3967. * @param {BABYLON.Mesh} mesh - the mesh to be added as LOD level
  3968. * @return {BABYLON.Mesh} this mesh (for chaining)
  3969. */
  3970. addLODLevel(distance: number, mesh: Mesh): Mesh;
  3971. getLODLevelAtDistance(distance: number): Mesh;
  3972. /**
  3973. * Remove a mesh from the LOD array
  3974. * @param {BABYLON.Mesh} mesh - the mesh to be removed.
  3975. * @return {BABYLON.Mesh} this mesh (for chaining)
  3976. */
  3977. removeLODLevel(mesh: Mesh): Mesh;
  3978. getLOD(camera: Camera, boundingSphere?: BoundingSphere): AbstractMesh;
  3979. geometry: Geometry;
  3980. getTotalVertices(): number;
  3981. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  3982. getVertexBuffer(kind: any): VertexBuffer;
  3983. isVerticesDataPresent(kind: string): boolean;
  3984. getVerticesDataKinds(): string[];
  3985. getTotalIndices(): number;
  3986. getIndices(copyWhenShared?: boolean): number[];
  3987. isBlocked: boolean;
  3988. isReady(): boolean;
  3989. isDisposed(): boolean;
  3990. sideOrientation: number;
  3991. areNormalsFrozen: boolean;
  3992. /** This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
  3993. freezeNormals(): void;
  3994. /** This function affects parametric shapes on update only : ribbons, tubes, etc. It has no effect at all on other shapes */
  3995. unfreezeNormals(): void;
  3996. _preActivate(): void;
  3997. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): void;
  3998. refreshBoundingInfo(): void;
  3999. _createGlobalSubMesh(): SubMesh;
  4000. subdivide(count: number): void;
  4001. setVerticesData(kind: any, data: any, updatable?: boolean, stride?: number): void;
  4002. updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
  4003. updateVerticesDataDirectly(kind: string, data: Float32Array, offset?: number, makeItUnique?: boolean): void;
  4004. updateMeshPositions(positionFunction: any, computeNormals?: boolean): void;
  4005. makeGeometryUnique(): void;
  4006. setIndices(indices: number[], totalVertices?: number): void;
  4007. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): void;
  4008. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): void;
  4009. registerBeforeRender(func: (mesh: AbstractMesh) => void): void;
  4010. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): void;
  4011. registerAfterRender(func: (mesh: AbstractMesh) => void): void;
  4012. unregisterAfterRender(func: (mesh: AbstractMesh) => void): void;
  4013. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  4014. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): void;
  4015. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix) => void): void;
  4016. render(subMesh: SubMesh): void;
  4017. getEmittedParticleSystems(): ParticleSystem[];
  4018. getHierarchyEmittedParticleSystems(): ParticleSystem[];
  4019. getChildren(): Node[];
  4020. _checkDelayState(): void;
  4021. isInFrustum(frustumPlanes: Plane[]): boolean;
  4022. setMaterialByID(id: string): void;
  4023. getAnimatables(): IAnimatable[];
  4024. bakeTransformIntoVertices(transform: Matrix): void;
  4025. _resetPointsArrayCache(): void;
  4026. _generatePointsArray(): boolean;
  4027. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): Mesh;
  4028. dispose(doNotRecurse?: boolean): void;
  4029. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void): void;
  4030. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number): void;
  4031. convertToFlatShadedMesh(): void;
  4032. createInstance(name: string): InstancedMesh;
  4033. synchronizeInstances(): void;
  4034. /**
  4035. * Simplify the mesh according to the given array of settings.
  4036. * Function will return immediately and will simplify async.
  4037. * @param settings a collection of simplification settings.
  4038. * @param parallelProcessing should all levels calculate parallel or one after the other.
  4039. * @param type the type of simplification to run.
  4040. * @param successCallback optional success callback to be called after the simplification finished processing all settings.
  4041. */
  4042. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): void;
  4043. /**
  4044. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  4045. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  4046. * This should be used together with the simplification to avoid disappearing triangles.
  4047. * @param successCallback an optional success callback to be called after the optimization finished.
  4048. */
  4049. optimizeIndices(successCallback?: (mesh?: Mesh) => void): void;
  4050. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene: Scene, updatable?: boolean, sideOrientation?: number, ribbonInstance?: Mesh): Mesh;
  4051. static CreateDisc(name: string, radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4052. static CreateBox(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4053. static CreateSphere(name: string, segments: number, diameter: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4054. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene: Scene, updatable?: any, sideOrientation?: number): Mesh;
  4055. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4056. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4057. static CreateLines(name: string, points: Vector3[], scene: Scene, updatable?: boolean, linesInstance?: LinesMesh): LinesMesh;
  4058. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, extrudedInstance?: Mesh): Mesh;
  4059. static ExtrudeShapeCustom(name: string, shape: Vector3[], path: Vector3[], scaleFunction: any, rotationFunction: any, ribbonCloseArray: boolean, ribbonClosePath: boolean, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, extrudedInstance?: Mesh): Mesh;
  4060. private static _ExtrudeShapeGeneric(name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance);
  4061. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  4062. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene: Scene, updatable?: boolean): Mesh;
  4063. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  4064. w: number;
  4065. h: number;
  4066. }, precision: {
  4067. w: number;
  4068. h: number;
  4069. }, scene: Scene, updatable?: boolean): Mesh;
  4070. 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;
  4071. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  4072. (i: number, distance: number): number;
  4073. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, tubeInstance?: Mesh): Mesh;
  4074. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle?: number): Mesh;
  4075. static MinMax(meshes: AbstractMesh[]): {
  4076. min: Vector3;
  4077. max: Vector3;
  4078. };
  4079. static Center(meshesOrMinMaxVector: any): Vector3;
  4080. /**
  4081. * Merge the array of meshes into a single mesh for performance reasons.
  4082. * @param {Array<Mesh>} meshes - The vertices source. They should all be of the same material. Entries can empty
  4083. * @param {boolean} disposeSource - When true (default), dispose of the vertices from the source meshes
  4084. * @param {boolean} allow32BitsIndices - When the sum of the vertices > 64k, this must be set to true.
  4085. * @param {Mesh} meshSubclass - When set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  4086. */
  4087. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh): Mesh;
  4088. }
  4089. }
  4090. declare module BABYLON {
  4091. interface IGetSetVerticesData {
  4092. isVerticesDataPresent(kind: string): boolean;
  4093. getVerticesData(kind: string, copyWhenShared?: boolean): number[];
  4094. getIndices(copyWhenShared?: boolean): number[];
  4095. setVerticesData(kind: string, data: number[], updatable?: boolean): void;
  4096. updateVerticesData(kind: string, data: number[], updateExtends?: boolean, makeItUnique?: boolean): void;
  4097. setIndices(indices: number[]): void;
  4098. }
  4099. class VertexData {
  4100. positions: number[];
  4101. normals: number[];
  4102. uvs: number[];
  4103. uv2s: number[];
  4104. colors: number[];
  4105. matricesIndices: number[];
  4106. matricesWeights: number[];
  4107. indices: number[];
  4108. set(data: number[], kind: string): void;
  4109. applyToMesh(mesh: Mesh, updatable?: boolean): void;
  4110. applyToGeometry(geometry: Geometry, updatable?: boolean): void;
  4111. updateMesh(mesh: Mesh, updateExtends?: boolean, makeItUnique?: boolean): void;
  4112. updateGeometry(geometry: Geometry, updateExtends?: boolean, makeItUnique?: boolean): void;
  4113. private _applyTo(meshOrGeometry, updatable?);
  4114. private _update(meshOrGeometry, updateExtends?, makeItUnique?);
  4115. transform(matrix: Matrix): void;
  4116. merge(other: VertexData): void;
  4117. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean): VertexData;
  4118. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean): VertexData;
  4119. private static _ExtractFrom(meshOrGeometry, copyWhenShared?);
  4120. static CreateRibbon(pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, sideOrientation?: number): VertexData;
  4121. static CreateBox(size: number, sideOrientation?: number): VertexData;
  4122. static CreateSphere(segments: number, diameter: number, sideOrientation?: number): VertexData;
  4123. static CreateCylinder(height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions?: number, sideOrientation?: number): VertexData;
  4124. static CreateTorus(diameter: any, thickness: any, tessellation: any, sideOrientation?: number): VertexData;
  4125. static CreateLines(points: Vector3[]): VertexData;
  4126. static CreateGround(width: number, height: number, subdivisions: number): VertexData;
  4127. static CreateTiledGround(xmin: number, zmin: number, xmax: number, zmax: number, subdivisions?: {
  4128. w: number;
  4129. h: number;
  4130. }, precision?: {
  4131. w: number;
  4132. h: number;
  4133. }): VertexData;
  4134. static CreateGroundFromHeightMap(width: number, height: number, subdivisions: number, minHeight: number, maxHeight: number, buffer: Uint8Array, bufferWidth: number, bufferHeight: number): VertexData;
  4135. static CreatePlane(size: number, sideOrientation?: number): VertexData;
  4136. static CreateDisc(radius: number, tessellation: number, sideOrientation?: number): VertexData;
  4137. static CreateTorusKnot(radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, sideOrientation?: number): VertexData;
  4138. /**
  4139. * @param {any} - positions (number[] or Float32Array)
  4140. * @param {any} - indices (number[] or Uint16Array)
  4141. * @param {any} - normals (number[] or Float32Array)
  4142. */
  4143. static ComputeNormals(positions: any, indices: any, normals: any): void;
  4144. private static _ComputeSides(sideOrientation, positions, indices, normals, uvs);
  4145. }
  4146. }
  4147. declare module BABYLON.Internals {
  4148. class MeshLODLevel {
  4149. distance: number;
  4150. mesh: Mesh;
  4151. constructor(distance: number, mesh: Mesh);
  4152. }
  4153. }
  4154. declare module BABYLON {
  4155. /**
  4156. * A simplifier interface for future simplification implementations.
  4157. */
  4158. interface ISimplifier {
  4159. /**
  4160. * Simplification of a given mesh according to the given settings.
  4161. * Since this requires computation, it is assumed that the function runs async.
  4162. * @param settings The settings of the simplification, including quality and distance
  4163. * @param successCallback A callback that will be called after the mesh was simplified.
  4164. * @param errorCallback in case of an error, this callback will be called. optional.
  4165. */
  4166. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  4167. }
  4168. /**
  4169. * Expected simplification settings.
  4170. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%);
  4171. */
  4172. interface ISimplificationSettings {
  4173. quality: number;
  4174. distance: number;
  4175. optimizeMesh?: boolean;
  4176. }
  4177. class SimplificationSettings implements ISimplificationSettings {
  4178. quality: number;
  4179. distance: number;
  4180. optimizeMesh: boolean;
  4181. constructor(quality: number, distance: number, optimizeMesh?: boolean);
  4182. }
  4183. interface ISimplificationTask {
  4184. settings: Array<ISimplificationSettings>;
  4185. simplificationType: SimplificationType;
  4186. mesh: Mesh;
  4187. successCallback?: () => void;
  4188. parallelProcessing: boolean;
  4189. }
  4190. class SimplificationQueue {
  4191. private _simplificationArray;
  4192. running: any;
  4193. constructor();
  4194. addTask(task: ISimplificationTask): void;
  4195. executeNext(): void;
  4196. runSimplification(task: ISimplificationTask): void;
  4197. private getSimplifier(task);
  4198. }
  4199. /**
  4200. * The implemented types of simplification.
  4201. * At the moment only Quadratic Error Decimation is implemented.
  4202. */
  4203. enum SimplificationType {
  4204. QUADRATIC = 0,
  4205. }
  4206. class DecimationTriangle {
  4207. vertices: Array<DecimationVertex>;
  4208. normal: Vector3;
  4209. error: Array<number>;
  4210. deleted: boolean;
  4211. isDirty: boolean;
  4212. borderFactor: number;
  4213. deletePending: boolean;
  4214. originalOffset: number;
  4215. constructor(vertices: Array<DecimationVertex>);
  4216. }
  4217. class DecimationVertex {
  4218. position: Vector3;
  4219. id: any;
  4220. q: QuadraticMatrix;
  4221. isBorder: boolean;
  4222. triangleStart: number;
  4223. triangleCount: number;
  4224. originalOffsets: Array<number>;
  4225. constructor(position: Vector3, id: any);
  4226. updatePosition(newPosition: Vector3): void;
  4227. }
  4228. class QuadraticMatrix {
  4229. data: Array<number>;
  4230. constructor(data?: Array<number>);
  4231. det(a11: any, a12: any, a13: any, a21: any, a22: any, a23: any, a31: any, a32: any, a33: any): number;
  4232. addInPlace(matrix: QuadraticMatrix): void;
  4233. addArrayInPlace(data: Array<number>): void;
  4234. add(matrix: QuadraticMatrix): QuadraticMatrix;
  4235. static FromData(a: number, b: number, c: number, d: number): QuadraticMatrix;
  4236. static DataFromNumbers(a: number, b: number, c: number, d: number): number[];
  4237. }
  4238. class Reference {
  4239. vertexId: number;
  4240. triangleId: number;
  4241. constructor(vertexId: number, triangleId: number);
  4242. }
  4243. /**
  4244. * An implementation of the Quadratic Error simplification algorithm.
  4245. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  4246. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  4247. * @author RaananW
  4248. */
  4249. class QuadraticErrorSimplification implements ISimplifier {
  4250. private _mesh;
  4251. private triangles;
  4252. private vertices;
  4253. private references;
  4254. private initialized;
  4255. private _reconstructedMesh;
  4256. syncIterations: number;
  4257. aggressiveness: number;
  4258. decimationIterations: number;
  4259. boundingBoxEpsilon: number;
  4260. constructor(_mesh: Mesh);
  4261. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  4262. private isTriangleOnBoundingBox(triangle);
  4263. private runDecimation(settings, submeshIndex, successCallback);
  4264. private initWithMesh(submeshIndex, callback, optimizeMesh?);
  4265. private init(callback);
  4266. private reconstructMesh(submeshIndex);
  4267. private initDecimatedMesh();
  4268. private isFlipped(vertex1, vertex2, point, deletedArray, borderFactor, delTr);
  4269. private updateTriangles(origVertex, vertex, deletedArray, deletedTriangles);
  4270. private identifyBorder();
  4271. private updateMesh(identifyBorders?);
  4272. private vertexError(q, point);
  4273. private calculateError(vertex1, vertex2, pointResult?, normalResult?, uvResult?, colorResult?);
  4274. }
  4275. }
  4276. declare module BABYLON {
  4277. class Polygon {
  4278. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  4279. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  4280. static Parse(input: string): Vector2[];
  4281. static StartingAt(x: number, y: number): Path2;
  4282. }
  4283. class PolygonMeshBuilder {
  4284. private _swctx;
  4285. private _points;
  4286. private _name;
  4287. private _scene;
  4288. constructor(name: string, contours: Path2, scene: Scene);
  4289. constructor(name: string, contours: Vector2[], scene: Scene);
  4290. addHole(hole: Vector2[]): PolygonMeshBuilder;
  4291. build(updatable?: boolean): Mesh;
  4292. }
  4293. }
  4294. declare module BABYLON {
  4295. class SubMesh {
  4296. materialIndex: number;
  4297. verticesStart: number;
  4298. verticesCount: number;
  4299. indexStart: any;
  4300. indexCount: number;
  4301. linesIndexCount: number;
  4302. private _mesh;
  4303. private _renderingMesh;
  4304. private _boundingInfo;
  4305. private _linesIndexBuffer;
  4306. _lastColliderWorldVertices: Vector3[];
  4307. _trianglePlanes: Plane[];
  4308. _lastColliderTransformMatrix: Matrix;
  4309. _renderId: number;
  4310. _alphaIndex: number;
  4311. _distanceToCamera: number;
  4312. _id: number;
  4313. constructor(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: any, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  4314. getBoundingInfo(): BoundingInfo;
  4315. getMesh(): AbstractMesh;
  4316. getRenderingMesh(): Mesh;
  4317. getMaterial(): Material;
  4318. refreshBoundingInfo(): void;
  4319. _checkCollision(collider: Collider): boolean;
  4320. updateBoundingInfo(world: Matrix): void;
  4321. isInFrustum(frustumPlanes: Plane[]): boolean;
  4322. render(): void;
  4323. getLinesIndexBuffer(indices: number[], engine: any): WebGLBuffer;
  4324. canIntersects(ray: Ray): boolean;
  4325. intersects(ray: Ray, positions: Vector3[], indices: number[], fastCheck?: boolean): IntersectionInfo;
  4326. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  4327. dispose(): void;
  4328. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  4329. }
  4330. }
  4331. declare module BABYLON {
  4332. class VertexBuffer {
  4333. private _mesh;
  4334. private _engine;
  4335. private _buffer;
  4336. private _data;
  4337. private _updatable;
  4338. private _kind;
  4339. private _strideSize;
  4340. constructor(engine: any, data: number[], kind: string, updatable: boolean, postponeInternalCreation?: boolean, stride?: number);
  4341. isUpdatable(): boolean;
  4342. getData(): number[];
  4343. getBuffer(): WebGLBuffer;
  4344. getStrideSize(): number;
  4345. create(data?: number[]): void;
  4346. update(data: number[]): void;
  4347. updateDirectly(data: Float32Array, offset: number): void;
  4348. dispose(): void;
  4349. private static _PositionKind;
  4350. private static _NormalKind;
  4351. private static _UVKind;
  4352. private static _UV2Kind;
  4353. private static _ColorKind;
  4354. private static _MatricesIndicesKind;
  4355. private static _MatricesWeightsKind;
  4356. static PositionKind: string;
  4357. static NormalKind: string;
  4358. static UVKind: string;
  4359. static UV2Kind: string;
  4360. static ColorKind: string;
  4361. static MatricesIndicesKind: string;
  4362. static MatricesWeightsKind: string;
  4363. }
  4364. }
  4365. declare module BABYLON {
  4366. class Particle {
  4367. position: Vector3;
  4368. direction: Vector3;
  4369. color: Color4;
  4370. colorStep: Color4;
  4371. lifeTime: number;
  4372. age: number;
  4373. size: number;
  4374. angle: number;
  4375. angularSpeed: number;
  4376. copyTo(other: Particle): void;
  4377. }
  4378. }
  4379. declare module BABYLON {
  4380. class ParticleSystem implements IDisposable {
  4381. name: string;
  4382. static BLENDMODE_ONEONE: number;
  4383. static BLENDMODE_STANDARD: number;
  4384. id: string;
  4385. renderingGroupId: number;
  4386. emitter: any;
  4387. emitRate: number;
  4388. manualEmitCount: number;
  4389. updateSpeed: number;
  4390. targetStopDuration: number;
  4391. disposeOnStop: boolean;
  4392. minEmitPower: number;
  4393. maxEmitPower: number;
  4394. minLifeTime: number;
  4395. maxLifeTime: number;
  4396. minSize: number;
  4397. maxSize: number;
  4398. minAngularSpeed: number;
  4399. maxAngularSpeed: number;
  4400. particleTexture: Texture;
  4401. onDispose: () => void;
  4402. updateFunction: (particles: Particle[]) => void;
  4403. blendMode: number;
  4404. forceDepthWrite: boolean;
  4405. gravity: Vector3;
  4406. direction1: Vector3;
  4407. direction2: Vector3;
  4408. minEmitBox: Vector3;
  4409. maxEmitBox: Vector3;
  4410. color1: Color4;
  4411. color2: Color4;
  4412. colorDead: Color4;
  4413. textureMask: Color4;
  4414. startDirectionFunction: (emitPower: number, worldMatrix: Matrix, directionToUpdate: Vector3) => void;
  4415. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3) => void;
  4416. private particles;
  4417. private _capacity;
  4418. private _scene;
  4419. private _vertexDeclaration;
  4420. private _vertexStrideSize;
  4421. private _stockParticles;
  4422. private _newPartsExcess;
  4423. private _vertexBuffer;
  4424. private _indexBuffer;
  4425. private _vertices;
  4426. private _effect;
  4427. private _customEffect;
  4428. private _cachedDefines;
  4429. private _scaledColorStep;
  4430. private _colorDiff;
  4431. private _scaledDirection;
  4432. private _scaledGravity;
  4433. private _currentRenderId;
  4434. private _alive;
  4435. private _started;
  4436. private _stopped;
  4437. private _actualFrame;
  4438. private _scaledUpdateSpeed;
  4439. constructor(name: string, capacity: number, scene: Scene, customEffect?: Effect);
  4440. recycleParticle(particle: Particle): void;
  4441. getCapacity(): number;
  4442. isAlive(): boolean;
  4443. isStarted(): boolean;
  4444. start(): void;
  4445. stop(): void;
  4446. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  4447. private _update(newParticles);
  4448. private _getEffect();
  4449. animate(): void;
  4450. render(): number;
  4451. dispose(): void;
  4452. clone(name: string, newEmitter: any): ParticleSystem;
  4453. }
  4454. }
  4455. declare module BABYLON {
  4456. interface IPhysicsEnginePlugin {
  4457. initialize(iterations?: number): any;
  4458. setGravity(gravity: Vector3): void;
  4459. runOneStep(delta: number): void;
  4460. registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4461. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4462. unregisterMesh(mesh: AbstractMesh): any;
  4463. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4464. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4465. dispose(): void;
  4466. isSupported(): boolean;
  4467. updateBodyPosition(mesh: AbstractMesh): void;
  4468. }
  4469. interface PhysicsBodyCreationOptions {
  4470. mass: number;
  4471. friction: number;
  4472. restitution: number;
  4473. }
  4474. interface PhysicsCompoundBodyPart {
  4475. mesh: Mesh;
  4476. impostor: number;
  4477. }
  4478. class PhysicsEngine {
  4479. gravity: Vector3;
  4480. private _currentPlugin;
  4481. constructor(plugin?: IPhysicsEnginePlugin);
  4482. _initialize(gravity?: Vector3): void;
  4483. _runOneStep(delta: number): void;
  4484. _setGravity(gravity: Vector3): void;
  4485. _registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4486. _registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4487. _unregisterMesh(mesh: AbstractMesh): void;
  4488. _applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4489. _createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4490. _updateBodyPosition(mesh: AbstractMesh): void;
  4491. dispose(): void;
  4492. isSupported(): boolean;
  4493. static NoImpostor: number;
  4494. static SphereImpostor: number;
  4495. static BoxImpostor: number;
  4496. static PlaneImpostor: number;
  4497. static MeshImpostor: number;
  4498. static CapsuleImpostor: number;
  4499. static ConeImpostor: number;
  4500. static CylinderImpostor: number;
  4501. static ConvexHullImpostor: number;
  4502. static Epsilon: number;
  4503. }
  4504. }
  4505. declare module BABYLON {
  4506. class CannonJSPlugin implements IPhysicsEnginePlugin {
  4507. checkWithEpsilon: (value: number) => number;
  4508. private _world;
  4509. private _registeredMeshes;
  4510. private _physicsMaterials;
  4511. initialize(iterations?: number): void;
  4512. private _checkWithEpsilon(value);
  4513. runOneStep(delta: number): void;
  4514. setGravity(gravity: Vector3): void;
  4515. registerMesh(mesh: AbstractMesh, impostor: number, options?: PhysicsBodyCreationOptions): any;
  4516. private _createSphere(radius, mesh, options?);
  4517. private _createBox(x, y, z, mesh, options?);
  4518. private _createPlane(mesh, options?);
  4519. private _createConvexPolyhedron(rawVerts, rawFaces, mesh, options?);
  4520. private _addMaterial(friction, restitution);
  4521. private _createRigidBodyFromShape(shape, mesh, mass, friction, restitution);
  4522. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4523. private _unbindBody(body);
  4524. unregisterMesh(mesh: AbstractMesh): void;
  4525. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4526. updateBodyPosition: (mesh: AbstractMesh) => void;
  4527. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3): boolean;
  4528. dispose(): void;
  4529. isSupported(): boolean;
  4530. }
  4531. }
  4532. declare module BABYLON {
  4533. class OimoJSPlugin implements IPhysicsEnginePlugin {
  4534. private _world;
  4535. private _registeredMeshes;
  4536. private _checkWithEpsilon(value);
  4537. initialize(iterations?: number): void;
  4538. setGravity(gravity: Vector3): void;
  4539. registerMesh(mesh: AbstractMesh, impostor: number, options: PhysicsBodyCreationOptions): any;
  4540. registerMeshesAsCompound(parts: PhysicsCompoundBodyPart[], options: PhysicsBodyCreationOptions): any;
  4541. private _createBodyAsCompound(part, options, initialMesh);
  4542. unregisterMesh(mesh: AbstractMesh): void;
  4543. private _unbindBody(body);
  4544. /**
  4545. * Update the body position according to the mesh position
  4546. * @param mesh
  4547. */
  4548. updateBodyPosition: (mesh: AbstractMesh) => void;
  4549. applyImpulse(mesh: AbstractMesh, force: Vector3, contactPoint: Vector3): void;
  4550. createLink(mesh1: AbstractMesh, mesh2: AbstractMesh, pivot1: Vector3, pivot2: Vector3, options?: any): boolean;
  4551. dispose(): void;
  4552. isSupported(): boolean;
  4553. private _getLastShape(body);
  4554. runOneStep(time: number): void;
  4555. }
  4556. }
  4557. declare module BABYLON {
  4558. class AnaglyphPostProcess extends PostProcess {
  4559. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4560. }
  4561. }
  4562. declare module BABYLON {
  4563. class BlackAndWhitePostProcess extends PostProcess {
  4564. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4565. }
  4566. }
  4567. declare module BABYLON {
  4568. class BlurPostProcess extends PostProcess {
  4569. direction: Vector2;
  4570. blurWidth: number;
  4571. constructor(name: string, direction: Vector2, blurWidth: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4572. }
  4573. }
  4574. declare module BABYLON {
  4575. class ColorCorrectionPostProcess extends PostProcess {
  4576. private _colorTableTexture;
  4577. constructor(name: string, colorTableUrl: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4578. }
  4579. }
  4580. declare module BABYLON {
  4581. class ConvolutionPostProcess extends PostProcess {
  4582. kernel: number[];
  4583. constructor(name: string, kernel: number[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4584. static EdgeDetect0Kernel: number[];
  4585. static EdgeDetect1Kernel: number[];
  4586. static EdgeDetect2Kernel: number[];
  4587. static SharpenKernel: number[];
  4588. static EmbossKernel: number[];
  4589. static GaussianKernel: number[];
  4590. }
  4591. }
  4592. declare module BABYLON {
  4593. class DisplayPassPostProcess extends PostProcess {
  4594. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4595. }
  4596. }
  4597. declare module BABYLON {
  4598. class FilterPostProcess extends PostProcess {
  4599. kernelMatrix: Matrix;
  4600. constructor(name: string, kernelMatrix: Matrix, ratio: number, camera?: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4601. }
  4602. }
  4603. declare module BABYLON {
  4604. class FxaaPostProcess extends PostProcess {
  4605. texelWidth: number;
  4606. texelHeight: number;
  4607. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4608. }
  4609. }
  4610. declare module BABYLON {
  4611. class LensRenderingPipeline extends PostProcessRenderPipeline {
  4612. /**
  4613. * The chromatic aberration PostProcess id in the pipeline
  4614. * @type {string}
  4615. */
  4616. LensChromaticAberrationEffect: string;
  4617. /**
  4618. * The highlights enhancing PostProcess id in the pipeline
  4619. * @type {string}
  4620. */
  4621. HighlightsEnhancingEffect: string;
  4622. /**
  4623. * The depth-of-field PostProcess id in the pipeline
  4624. * @type {string}
  4625. */
  4626. LensDepthOfFieldEffect: string;
  4627. private _scene;
  4628. private _depthTexture;
  4629. private _grainTexture;
  4630. private _chromaticAberrationPostProcess;
  4631. private _highlightsPostProcess;
  4632. private _depthOfFieldPostProcess;
  4633. private _edgeBlur;
  4634. private _grainAmount;
  4635. private _chromaticAberration;
  4636. private _distortion;
  4637. private _highlightsGain;
  4638. private _highlightsThreshold;
  4639. private _dofDepth;
  4640. private _dofAperture;
  4641. private _dofPentagon;
  4642. private _blurNoise;
  4643. /**
  4644. * @constructor
  4645. *
  4646. * Effect parameters are as follow:
  4647. * {
  4648. * chromatic_aberration: number; // from 0 to x (1 for realism)
  4649. * edge_blur: number; // from 0 to x (1 for realism)
  4650. * distortion: number; // from 0 to x (1 for realism)
  4651. * grain_amount: number; // from 0 to 1
  4652. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  4653. * dof_focus_depth: number; // depth-of-field: focus depth; unset to disable (disabled by default)
  4654. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  4655. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  4656. * dof_gain: number; // depth-of-field: depthOfField gain; unset to disable (disabled by default)
  4657. * dof_threshold: number; // depth-of-field: depthOfField threshold (default: 1)
  4658. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  4659. * }
  4660. * Note: if an effect parameter is unset, effect is disabled
  4661. *
  4662. * @param {string} name - The rendering pipeline name
  4663. * @param {object} parameters - An object containing all parameters (see above)
  4664. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  4665. * @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)
  4666. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  4667. */
  4668. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  4669. setEdgeBlur(amount: number): void;
  4670. disableEdgeBlur(): void;
  4671. setGrainAmount(amount: number): void;
  4672. disableGrain(): void;
  4673. setChromaticAberration(amount: number): void;
  4674. disableChromaticAberration(): void;
  4675. setEdgeDistortion(amount: number): void;
  4676. disableEdgeDistortion(): void;
  4677. setFocusDepth(amount: number): void;
  4678. disableDepthOfField(): void;
  4679. setAperture(amount: number): void;
  4680. enablePentagonBokeh(): void;
  4681. disablePentagonBokeh(): void;
  4682. enableNoiseBlur(): void;
  4683. disableNoiseBlur(): void;
  4684. setHighlightsGain(amount: number): void;
  4685. setHighlightsThreshold(amount: number): void;
  4686. disableHighlights(): void;
  4687. /**
  4688. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  4689. */
  4690. dispose(disableDepthRender?: boolean): void;
  4691. private _createChromaticAberrationPostProcess(ratio);
  4692. private _createHighlightsPostProcess(ratio);
  4693. private _createDepthOfFieldPostProcess(ratio);
  4694. private _createGrainTexture();
  4695. }
  4696. }
  4697. declare module BABYLON {
  4698. class OculusDistortionCorrectionPostProcess extends PostProcess {
  4699. aspectRatio: number;
  4700. private _isRightEye;
  4701. private _distortionFactors;
  4702. private _postProcessScaleFactor;
  4703. private _lensCenterOffset;
  4704. private _scaleIn;
  4705. private _scaleFactor;
  4706. private _lensCenter;
  4707. constructor(name: string, camera: Camera, isRightEye: boolean, cameraSettings: any);
  4708. }
  4709. }
  4710. declare module BABYLON {
  4711. class PassPostProcess extends PostProcess {
  4712. constructor(name: string, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4713. }
  4714. }
  4715. declare module BABYLON {
  4716. class PostProcess {
  4717. name: string;
  4718. onApply: (Effect) => void;
  4719. onBeforeRender: (Effect) => void;
  4720. onSizeChanged: () => void;
  4721. onActivate: (Camera) => void;
  4722. width: number;
  4723. height: number;
  4724. renderTargetSamplingMode: number;
  4725. clearColor: Color4;
  4726. private _camera;
  4727. private _scene;
  4728. private _engine;
  4729. private _renderRatio;
  4730. private _reusable;
  4731. _textures: SmartArray<WebGLTexture>;
  4732. _currentRenderTextureInd: number;
  4733. private _effect;
  4734. constructor(name: string, fragmentUrl: string, parameters: string[], samplers: string[], ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean, defines?: string);
  4735. isReusable(): boolean;
  4736. activate(camera: Camera, sourceTexture?: WebGLTexture): void;
  4737. apply(): Effect;
  4738. dispose(camera?: Camera): void;
  4739. }
  4740. }
  4741. declare module BABYLON {
  4742. class PostProcessManager {
  4743. private _scene;
  4744. private _indexBuffer;
  4745. private _vertexDeclaration;
  4746. private _vertexStrideSize;
  4747. private _vertexBuffer;
  4748. constructor(scene: Scene);
  4749. private _prepareBuffers();
  4750. _prepareFrame(sourceTexture?: WebGLTexture): boolean;
  4751. directRender(postProcesses: PostProcess[], targetTexture?: WebGLTexture): void;
  4752. _finalizeFrame(doNotPresent?: boolean, targetTexture?: WebGLTexture, postProcesses?: PostProcess[]): void;
  4753. dispose(): void;
  4754. }
  4755. }
  4756. declare module BABYLON {
  4757. class RefractionPostProcess extends PostProcess {
  4758. color: Color3;
  4759. depth: number;
  4760. colorLevel: number;
  4761. private _refRexture;
  4762. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, ratio: number, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4763. dispose(camera: Camera): void;
  4764. }
  4765. }
  4766. declare module BABYLON {
  4767. class SSAORenderingPipeline extends PostProcessRenderPipeline {
  4768. /**
  4769. * The PassPostProcess id in the pipeline that contains the original scene color
  4770. * @type {string}
  4771. */
  4772. SSAOOriginalSceneColorEffect: string;
  4773. /**
  4774. * The SSAO PostProcess id in the pipeline
  4775. * @type {string}
  4776. */
  4777. SSAORenderEffect: string;
  4778. /**
  4779. * The horizontal blur PostProcess id in the pipeline
  4780. * @type {string}
  4781. */
  4782. SSAOBlurHRenderEffect: string;
  4783. /**
  4784. * The vertical blur PostProcess id in the pipeline
  4785. * @type {string}
  4786. */
  4787. SSAOBlurVRenderEffect: string;
  4788. /**
  4789. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  4790. * @type {string}
  4791. */
  4792. SSAOCombineRenderEffect: string;
  4793. /**
  4794. * The output strength of the SSAO post-process. Default value is 1.0.
  4795. * @type {number}
  4796. */
  4797. totalStrength: number;
  4798. /**
  4799. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0002
  4800. * @type {number}
  4801. */
  4802. radius: number;
  4803. /**
  4804. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  4805. * Must not be equal to fallOff and superior to fallOff.
  4806. * Default value is 0.0075
  4807. * @type {number}
  4808. */
  4809. area: number;
  4810. /**
  4811. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  4812. * Must not be equal to area and inferior to area.
  4813. * Default value is 0.0002
  4814. * @type {number}
  4815. */
  4816. fallOff: number;
  4817. private _scene;
  4818. private _depthTexture;
  4819. private _randomTexture;
  4820. private _originalColorPostProcess;
  4821. private _ssaoPostProcess;
  4822. private _blurHPostProcess;
  4823. private _blurVPostProcess;
  4824. private _ssaoCombinePostProcess;
  4825. private _firstUpdate;
  4826. /**
  4827. * @constructor
  4828. * @param {string} name - The rendering pipeline name
  4829. * @param {BABYLON.Scene} scene - The scene linked to this pipeline
  4830. * @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 }
  4831. * @param {BABYLON.Camera[]} cameras - The array of cameras that the rendering pipeline will be attached to
  4832. */
  4833. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  4834. /**
  4835. * Returns the horizontal blur PostProcess
  4836. * @return {BABYLON.BlurPostProcess} The horizontal blur post-process
  4837. */
  4838. getBlurHPostProcess(): BlurPostProcess;
  4839. /**
  4840. * Returns the vertical blur PostProcess
  4841. * @return {BABYLON.BlurPostProcess} The vertical blur post-process
  4842. */
  4843. getBlurVPostProcess(): BlurPostProcess;
  4844. /**
  4845. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  4846. */
  4847. dispose(disableDepthRender?: boolean): void;
  4848. private _createSSAOPostProcess(ratio);
  4849. private _createSSAOCombinePostProcess(ratio);
  4850. private _createRandomTexture();
  4851. }
  4852. }
  4853. declare module BABYLON {
  4854. class VolumetricLightScatteringPostProcess extends PostProcess {
  4855. private _volumetricLightScatteringPass;
  4856. private _volumetricLightScatteringRTT;
  4857. private _viewPort;
  4858. private _screenCoordinates;
  4859. private _cachedDefines;
  4860. private _customMeshPosition;
  4861. /**
  4862. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  4863. * @type {boolean}
  4864. */
  4865. useCustomMeshPosition: boolean;
  4866. /**
  4867. * If the post-process should inverse the light scattering direction
  4868. * @type {boolean}
  4869. */
  4870. invert: boolean;
  4871. /**
  4872. * The internal mesh used by the post-process
  4873. * @type {boolean}
  4874. */
  4875. mesh: Mesh;
  4876. /**
  4877. * Array containing the excluded meshes not rendered in the internal pass
  4878. */
  4879. excludedMeshes: AbstractMesh[];
  4880. exposure: number;
  4881. decay: number;
  4882. weight: number;
  4883. density: number;
  4884. /**
  4885. * @constructor
  4886. * @param {string} name - The post-process name
  4887. * @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)
  4888. * @param {BABYLON.Camera} camera - The camera that the post-process will be attached to
  4889. * @param {BABYLON.Mesh} mesh - The mesh used to create the light scattering
  4890. * @param {number} samples - The post-process quality, default 100
  4891. * @param {number} samplingMode - The post-process filtering mode
  4892. * @param {BABYLON.Engine} engine - The babylon engine
  4893. * @param {boolean} reusable - If the post-process is reusable
  4894. */
  4895. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean);
  4896. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  4897. /**
  4898. * Sets the new light position for light scattering effect
  4899. * @param {BABYLON.Vector3} The new custom light position
  4900. */
  4901. setCustomMeshPosition(position: Vector3): void;
  4902. /**
  4903. * Returns the light position for light scattering effect
  4904. * @return {BABYLON.Vector3} The custom light position
  4905. */
  4906. getCustomMeshPosition(): Vector3;
  4907. /**
  4908. * Disposes the internal assets and detaches the post-process from the camera
  4909. */
  4910. dispose(camera: Camera): void;
  4911. /**
  4912. * Returns the render target texture used by the post-process
  4913. * @return {BABYLON.RenderTargetTexture} The render target texture used by the post-process
  4914. */
  4915. getPass(): RenderTargetTexture;
  4916. private _meshExcluded(mesh);
  4917. private _createPass(scene, ratio);
  4918. private _updateMeshScreenCoordinates(scene);
  4919. /**
  4920. * Creates a default mesh for the Volumeric Light Scattering post-process
  4921. * @param {string} The mesh name
  4922. * @param {BABYLON.Scene} The scene where to create the mesh
  4923. * @return {BABYLON.Mesh} the default mesh
  4924. */
  4925. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  4926. }
  4927. }
  4928. declare module BABYLON {
  4929. class VRDistortionCorrectionPostProcess extends PostProcess {
  4930. aspectRatio: number;
  4931. private _isRightEye;
  4932. private _distortionFactors;
  4933. private _postProcessScaleFactor;
  4934. private _lensCenterOffset;
  4935. private _scaleIn;
  4936. private _scaleFactor;
  4937. private _lensCenter;
  4938. constructor(name: string, camera: Camera, isRightEye: boolean, cameraSettings: any);
  4939. }
  4940. }
  4941. declare module BABYLON {
  4942. class PostProcessRenderEffect {
  4943. private _engine;
  4944. private _postProcesses;
  4945. private _getPostProcess;
  4946. private _singleInstance;
  4947. private _cameras;
  4948. private _indicesForCamera;
  4949. private _renderPasses;
  4950. private _renderEffectAsPasses;
  4951. _name: string;
  4952. applyParameters: (postProcess: PostProcess) => void;
  4953. constructor(engine: Engine, name: string, getPostProcess: () => PostProcess, singleInstance?: boolean);
  4954. _update(): void;
  4955. addPass(renderPass: PostProcessRenderPass): void;
  4956. removePass(renderPass: PostProcessRenderPass): void;
  4957. addRenderEffectAsPass(renderEffect: PostProcessRenderEffect): void;
  4958. getPass(passName: string): void;
  4959. emptyPasses(): void;
  4960. _attachCameras(cameras: Camera): any;
  4961. _attachCameras(cameras: Camera[]): any;
  4962. _detachCameras(cameras: Camera): any;
  4963. _detachCameras(cameras: Camera[]): any;
  4964. _enable(cameras: Camera): any;
  4965. _enable(cameras: Camera[]): any;
  4966. _disable(cameras: Camera): any;
  4967. _disable(cameras: Camera[]): any;
  4968. getPostProcess(camera?: Camera): PostProcess;
  4969. private _linkParameters();
  4970. private _linkTextures(effect);
  4971. }
  4972. }
  4973. declare module BABYLON {
  4974. class PostProcessRenderPass {
  4975. private _enabled;
  4976. private _renderList;
  4977. private _renderTexture;
  4978. private _scene;
  4979. private _refCount;
  4980. _name: string;
  4981. constructor(scene: Scene, name: string, size: number, renderList: Mesh[], beforeRender: () => void, afterRender: () => void);
  4982. _incRefCount(): number;
  4983. _decRefCount(): number;
  4984. _update(): void;
  4985. setRenderList(renderList: Mesh[]): void;
  4986. getRenderTexture(): RenderTargetTexture;
  4987. }
  4988. }
  4989. declare module BABYLON {
  4990. class PostProcessRenderPipeline {
  4991. private _engine;
  4992. private _renderEffects;
  4993. private _renderEffectsForIsolatedPass;
  4994. private _cameras;
  4995. _name: string;
  4996. private static PASS_EFFECT_NAME;
  4997. private static PASS_SAMPLER_NAME;
  4998. constructor(engine: Engine, name: string);
  4999. addEffect(renderEffect: PostProcessRenderEffect): void;
  5000. _enableEffect(renderEffectName: string, cameras: Camera): any;
  5001. _enableEffect(renderEffectName: string, cameras: Camera[]): any;
  5002. _disableEffect(renderEffectName: string, cameras: Camera): any;
  5003. _disableEffect(renderEffectName: string, cameras: Camera[]): any;
  5004. _attachCameras(cameras: Camera, unique: boolean): any;
  5005. _attachCameras(cameras: Camera[], unique: boolean): any;
  5006. _detachCameras(cameras: Camera): any;
  5007. _detachCameras(cameras: Camera[]): any;
  5008. _enableDisplayOnlyPass(passName: any, cameras: Camera): any;
  5009. _enableDisplayOnlyPass(passName: any, cameras: Camera[]): any;
  5010. _disableDisplayOnlyPass(cameras: Camera): any;
  5011. _disableDisplayOnlyPass(cameras: Camera[]): any;
  5012. _update(): void;
  5013. }
  5014. }
  5015. declare module BABYLON {
  5016. class PostProcessRenderPipelineManager {
  5017. private _renderPipelines;
  5018. constructor();
  5019. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  5020. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera, unique?: boolean): any;
  5021. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: Camera[], unique?: boolean): any;
  5022. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera): any;
  5023. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: Camera[]): any;
  5024. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  5025. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  5026. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera): any;
  5027. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: Camera[]): any;
  5028. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera): any;
  5029. enableDisplayOnlyPassInPipeline(renderPipelineName: string, passName: string, cameras: Camera[]): any;
  5030. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera): any;
  5031. disableDisplayOnlyPassInPipeline(renderPipelineName: string, cameras: Camera[]): any;
  5032. update(): void;
  5033. }
  5034. }
  5035. declare module BABYLON {
  5036. class BoundingBoxRenderer {
  5037. frontColor: Color3;
  5038. backColor: Color3;
  5039. showBackLines: boolean;
  5040. renderList: SmartArray<BoundingBox>;
  5041. private _scene;
  5042. private _colorShader;
  5043. private _vb;
  5044. private _ib;
  5045. constructor(scene: Scene);
  5046. private _prepareRessources();
  5047. reset(): void;
  5048. render(): void;
  5049. dispose(): void;
  5050. }
  5051. }
  5052. declare module BABYLON {
  5053. class DepthRenderer {
  5054. private _scene;
  5055. private _depthMap;
  5056. private _effect;
  5057. private _viewMatrix;
  5058. private _projectionMatrix;
  5059. private _transformMatrix;
  5060. private _worldViewProjection;
  5061. private _cachedDefines;
  5062. constructor(scene: Scene, type?: number);
  5063. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5064. getDepthMap(): RenderTargetTexture;
  5065. dispose(): void;
  5066. }
  5067. }
  5068. declare module BABYLON {
  5069. class OutlineRenderer {
  5070. private _scene;
  5071. private _effect;
  5072. private _cachedDefines;
  5073. constructor(scene: Scene);
  5074. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  5075. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  5076. }
  5077. }
  5078. declare module BABYLON {
  5079. class RenderingGroup {
  5080. index: number;
  5081. private _scene;
  5082. private _opaqueSubMeshes;
  5083. private _transparentSubMeshes;
  5084. private _alphaTestSubMeshes;
  5085. private _activeVertices;
  5086. constructor(index: number, scene: Scene);
  5087. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void): boolean;
  5088. prepare(): void;
  5089. dispatch(subMesh: SubMesh): void;
  5090. }
  5091. }
  5092. declare module BABYLON {
  5093. class RenderingManager {
  5094. static MAX_RENDERINGGROUPS: number;
  5095. private _scene;
  5096. private _renderingGroups;
  5097. private _depthBufferAlreadyCleaned;
  5098. constructor(scene: Scene);
  5099. private _renderParticles(index, activeMeshes);
  5100. private _renderSprites(index);
  5101. private _clearDepthBuffer();
  5102. render(customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>) => void, activeMeshes: AbstractMesh[], renderParticles: boolean, renderSprites: boolean): void;
  5103. reset(): void;
  5104. dispatch(subMesh: SubMesh): void;
  5105. }
  5106. }
  5107. declare module BABYLON {
  5108. class Sprite {
  5109. name: string;
  5110. position: Vector3;
  5111. color: Color4;
  5112. width: number;
  5113. height: number;
  5114. angle: number;
  5115. cellIndex: number;
  5116. invertU: number;
  5117. invertV: number;
  5118. disposeWhenFinishedAnimating: boolean;
  5119. animations: Animation[];
  5120. private _animationStarted;
  5121. private _loopAnimation;
  5122. private _fromIndex;
  5123. private _toIndex;
  5124. private _delay;
  5125. private _direction;
  5126. private _frameCount;
  5127. private _manager;
  5128. private _time;
  5129. size: number;
  5130. constructor(name: string, manager: SpriteManager);
  5131. playAnimation(from: number, to: number, loop: boolean, delay: number): void;
  5132. stopAnimation(): void;
  5133. _animate(deltaTime: number): void;
  5134. dispose(): void;
  5135. }
  5136. }
  5137. declare module BABYLON {
  5138. class SpriteManager {
  5139. name: string;
  5140. cellSize: number;
  5141. sprites: Sprite[];
  5142. renderingGroupId: number;
  5143. onDispose: () => void;
  5144. fogEnabled: boolean;
  5145. private _capacity;
  5146. private _spriteTexture;
  5147. private _epsilon;
  5148. private _scene;
  5149. private _vertexDeclaration;
  5150. private _vertexStrideSize;
  5151. private _vertexBuffer;
  5152. private _indexBuffer;
  5153. private _vertices;
  5154. private _effectBase;
  5155. private _effectFog;
  5156. constructor(name: string, imgUrl: string, capacity: number, cellSize: number, scene: Scene, epsilon?: number, samplingMode?: number);
  5157. private _appendSpriteVertex(index, sprite, offsetX, offsetY, rowSize);
  5158. render(): void;
  5159. dispose(): void;
  5160. }
  5161. }
  5162. declare module BABYLON.Internals {
  5163. class AndOrNotEvaluator {
  5164. static Eval(query: string, evaluateCallback: (val) => boolean): boolean;
  5165. private static _HandleParenthesisContent(parenthesisContent, evaluateCallback);
  5166. private static _SimplifyNegation(booleanString);
  5167. }
  5168. }
  5169. declare module BABYLON {
  5170. interface IAssetTask {
  5171. onSuccess: (task: IAssetTask) => void;
  5172. onError: (task: IAssetTask) => void;
  5173. isCompleted: boolean;
  5174. run(scene: Scene, onSuccess: () => void, onError: () => void): any;
  5175. }
  5176. class MeshAssetTask implements IAssetTask {
  5177. name: string;
  5178. meshesNames: any;
  5179. rootUrl: string;
  5180. sceneFilename: string;
  5181. loadedMeshes: Array<AbstractMesh>;
  5182. loadedParticleSystems: Array<ParticleSystem>;
  5183. loadedSkeletons: Array<Skeleton>;
  5184. onSuccess: (task: IAssetTask) => void;
  5185. onError: (task: IAssetTask) => void;
  5186. isCompleted: boolean;
  5187. constructor(name: string, meshesNames: any, rootUrl: string, sceneFilename: string);
  5188. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5189. }
  5190. class TextFileAssetTask implements IAssetTask {
  5191. name: string;
  5192. url: string;
  5193. onSuccess: (task: IAssetTask) => void;
  5194. onError: (task: IAssetTask) => void;
  5195. isCompleted: boolean;
  5196. text: string;
  5197. constructor(name: string, url: string);
  5198. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5199. }
  5200. class BinaryFileAssetTask implements IAssetTask {
  5201. name: string;
  5202. url: string;
  5203. onSuccess: (task: IAssetTask) => void;
  5204. onError: (task: IAssetTask) => void;
  5205. isCompleted: boolean;
  5206. data: ArrayBuffer;
  5207. constructor(name: string, url: string);
  5208. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5209. }
  5210. class ImageAssetTask implements IAssetTask {
  5211. name: string;
  5212. url: string;
  5213. onSuccess: (task: IAssetTask) => void;
  5214. onError: (task: IAssetTask) => void;
  5215. isCompleted: boolean;
  5216. image: HTMLImageElement;
  5217. constructor(name: string, url: string);
  5218. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5219. }
  5220. class TextureAssetTask implements IAssetTask {
  5221. name: string;
  5222. url: string;
  5223. noMipmap: boolean;
  5224. invertY: boolean;
  5225. samplingMode: number;
  5226. onSuccess: (task: IAssetTask) => void;
  5227. onError: (task: IAssetTask) => void;
  5228. isCompleted: boolean;
  5229. texture: Texture;
  5230. constructor(name: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number);
  5231. run(scene: Scene, onSuccess: () => void, onError: () => void): void;
  5232. }
  5233. class AssetsManager {
  5234. private _tasks;
  5235. private _scene;
  5236. private _waitingTasksCount;
  5237. onFinish: (tasks: IAssetTask[]) => void;
  5238. onTaskSuccess: (task: IAssetTask) => void;
  5239. onTaskError: (task: IAssetTask) => void;
  5240. useDefaultLoadingScreen: boolean;
  5241. constructor(scene: Scene);
  5242. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): IAssetTask;
  5243. addTextFileTask(taskName: string, url: string): IAssetTask;
  5244. addBinaryFileTask(taskName: string, url: string): IAssetTask;
  5245. addImageTask(taskName: string, url: string): IAssetTask;
  5246. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): IAssetTask;
  5247. private _decreaseWaitingTasksCount();
  5248. private _runTask(task);
  5249. reset(): AssetsManager;
  5250. load(): AssetsManager;
  5251. }
  5252. }
  5253. declare module BABYLON {
  5254. class Database {
  5255. private callbackManifestChecked;
  5256. private currentSceneUrl;
  5257. private db;
  5258. private enableSceneOffline;
  5259. private enableTexturesOffline;
  5260. private manifestVersionFound;
  5261. private mustUpdateRessources;
  5262. private hasReachedQuota;
  5263. private isSupported;
  5264. private idbFactory;
  5265. static isUASupportingBlobStorage: boolean;
  5266. constructor(urlToScene: string, callbackManifestChecked: (boolean) => any);
  5267. static parseURL: (url: string) => string;
  5268. static ReturnFullUrlLocation: (url: string) => string;
  5269. checkManifestFile(): void;
  5270. openAsync(successCallback: any, errorCallback: any): void;
  5271. loadImageFromDB(url: string, image: HTMLImageElement): void;
  5272. private _loadImageFromDBAsync(url, image, notInDBCallback);
  5273. private _saveImageIntoDBAsync(url, image);
  5274. private _checkVersionFromDB(url, versionLoaded);
  5275. private _loadVersionFromDBAsync(url, callback, updateInDBCallback);
  5276. private _saveVersionIntoDBAsync(url, callback);
  5277. private loadFileFromDB(url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer?);
  5278. private _loadFileFromDBAsync(url, callback, notInDBCallback, useArrayBuffer?);
  5279. private _saveFileIntoDBAsync(url, callback, progressCallback, useArrayBuffer?);
  5280. }
  5281. }
  5282. declare module BABYLON {
  5283. class FilesInput {
  5284. private _engine;
  5285. private _currentScene;
  5286. private _canvas;
  5287. private _sceneLoadedCallback;
  5288. private _progressCallback;
  5289. private _additionnalRenderLoopLogicCallback;
  5290. private _textureLoadingCallback;
  5291. private _startingProcessingFilesCallback;
  5292. private _elementToMonitor;
  5293. static FilesTextures: any[];
  5294. static FilesToLoad: any[];
  5295. private _sceneFileToLoad;
  5296. private _filesToLoad;
  5297. constructor(p_engine: Engine, p_scene: Scene, p_canvas: HTMLCanvasElement, p_sceneLoadedCallback: any, p_progressCallback: any, p_additionnalRenderLoopLogicCallback: any, p_textureLoadingCallback: any, p_startingProcessingFilesCallback: any);
  5298. monitorElementForDragNDrop(p_elementToMonitor: HTMLElement): void;
  5299. private renderFunction();
  5300. private drag(e);
  5301. private drop(eventDrop);
  5302. loadFiles(event: any): void;
  5303. reload(): void;
  5304. }
  5305. }
  5306. declare module BABYLON {
  5307. class Gamepads {
  5308. private babylonGamepads;
  5309. private oneGamepadConnected;
  5310. private isMonitoring;
  5311. private gamepadEventSupported;
  5312. private gamepadSupportAvailable;
  5313. private _callbackGamepadConnected;
  5314. private buttonADataURL;
  5315. private static gamepadDOMInfo;
  5316. constructor(ongamedpadconnected: (gamepad: Gamepad) => void);
  5317. private _insertGamepadDOMInstructions();
  5318. private _insertGamepadDOMNotSupported();
  5319. dispose(): void;
  5320. private _onGamepadConnected(evt);
  5321. private _addNewGamepad(gamepad);
  5322. private _onGamepadDisconnected(evt);
  5323. private _startMonitoringGamepads();
  5324. private _stopMonitoringGamepads();
  5325. private _checkGamepadsStatus();
  5326. private _updateGamepadObjects();
  5327. }
  5328. class StickValues {
  5329. x: any;
  5330. y: any;
  5331. constructor(x: any, y: any);
  5332. }
  5333. class Gamepad {
  5334. id: string;
  5335. index: number;
  5336. browserGamepad: any;
  5337. private _leftStick;
  5338. private _rightStick;
  5339. private _onleftstickchanged;
  5340. private _onrightstickchanged;
  5341. constructor(id: string, index: number, browserGamepad: any);
  5342. onleftstickchanged(callback: (values: StickValues) => void): void;
  5343. onrightstickchanged(callback: (values: StickValues) => void): void;
  5344. leftStick: StickValues;
  5345. rightStick: StickValues;
  5346. update(): void;
  5347. }
  5348. class GenericPad extends Gamepad {
  5349. id: string;
  5350. index: number;
  5351. gamepad: any;
  5352. private _buttons;
  5353. private _onbuttondown;
  5354. private _onbuttonup;
  5355. onbuttondown(callback: (buttonPressed: number) => void): void;
  5356. onbuttonup(callback: (buttonReleased: number) => void): void;
  5357. constructor(id: string, index: number, gamepad: any);
  5358. private _setButtonValue(newValue, currentValue, buttonIndex);
  5359. update(): void;
  5360. }
  5361. enum Xbox360Button {
  5362. A = 0,
  5363. B = 1,
  5364. X = 2,
  5365. Y = 3,
  5366. Start = 4,
  5367. Back = 5,
  5368. LB = 6,
  5369. RB = 7,
  5370. LeftStick = 8,
  5371. RightStick = 9,
  5372. }
  5373. enum Xbox360Dpad {
  5374. Up = 0,
  5375. Down = 1,
  5376. Left = 2,
  5377. Right = 3,
  5378. }
  5379. class Xbox360Pad extends Gamepad {
  5380. private _leftTrigger;
  5381. private _rightTrigger;
  5382. private _onlefttriggerchanged;
  5383. private _onrighttriggerchanged;
  5384. private _onbuttondown;
  5385. private _onbuttonup;
  5386. private _ondpaddown;
  5387. private _ondpadup;
  5388. private _buttonA;
  5389. private _buttonB;
  5390. private _buttonX;
  5391. private _buttonY;
  5392. private _buttonBack;
  5393. private _buttonStart;
  5394. private _buttonLB;
  5395. private _buttonRB;
  5396. private _buttonLeftStick;
  5397. private _buttonRightStick;
  5398. private _dPadUp;
  5399. private _dPadDown;
  5400. private _dPadLeft;
  5401. private _dPadRight;
  5402. onlefttriggerchanged(callback: (value: number) => void): void;
  5403. onrighttriggerchanged(callback: (value: number) => void): void;
  5404. leftTrigger: number;
  5405. rightTrigger: number;
  5406. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  5407. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  5408. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  5409. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  5410. private _setButtonValue(newValue, currentValue, buttonType);
  5411. private _setDPadValue(newValue, currentValue, buttonType);
  5412. buttonA: number;
  5413. buttonB: number;
  5414. buttonX: number;
  5415. buttonY: number;
  5416. buttonStart: number;
  5417. buttonBack: number;
  5418. buttonLB: number;
  5419. buttonRB: number;
  5420. buttonLeftStick: number;
  5421. buttonRightStick: number;
  5422. dPadUp: number;
  5423. dPadDown: number;
  5424. dPadLeft: number;
  5425. dPadRight: number;
  5426. update(): void;
  5427. }
  5428. }
  5429. interface Navigator {
  5430. getGamepads(func?: any): any;
  5431. webkitGetGamepads(func?: any): any;
  5432. msGetGamepads(func?: any): any;
  5433. webkitGamepads(func?: any): any;
  5434. }
  5435. declare module BABYLON {
  5436. class SceneOptimization {
  5437. priority: number;
  5438. apply: (scene: Scene) => boolean;
  5439. constructor(priority?: number);
  5440. }
  5441. class TextureOptimization extends SceneOptimization {
  5442. priority: number;
  5443. maximumSize: number;
  5444. constructor(priority?: number, maximumSize?: number);
  5445. apply: (scene: Scene) => boolean;
  5446. }
  5447. class HardwareScalingOptimization extends SceneOptimization {
  5448. priority: number;
  5449. maximumScale: number;
  5450. private _currentScale;
  5451. constructor(priority?: number, maximumScale?: number);
  5452. apply: (scene: Scene) => boolean;
  5453. }
  5454. class ShadowsOptimization extends SceneOptimization {
  5455. apply: (scene: Scene) => boolean;
  5456. }
  5457. class PostProcessesOptimization extends SceneOptimization {
  5458. apply: (scene: Scene) => boolean;
  5459. }
  5460. class LensFlaresOptimization extends SceneOptimization {
  5461. apply: (scene: Scene) => boolean;
  5462. }
  5463. class ParticlesOptimization extends SceneOptimization {
  5464. apply: (scene: Scene) => boolean;
  5465. }
  5466. class RenderTargetsOptimization extends SceneOptimization {
  5467. apply: (scene: Scene) => boolean;
  5468. }
  5469. class MergeMeshesOptimization extends SceneOptimization {
  5470. private _canBeMerged;
  5471. apply: (scene: Scene) => boolean;
  5472. }
  5473. class SceneOptimizerOptions {
  5474. targetFrameRate: number;
  5475. trackerDuration: number;
  5476. optimizations: SceneOptimization[];
  5477. constructor(targetFrameRate?: number, trackerDuration?: number);
  5478. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5479. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5480. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  5481. }
  5482. class SceneOptimizer {
  5483. static _CheckCurrentState(scene: Scene, options: SceneOptimizerOptions, currentPriorityLevel: number, onSuccess?: () => void, onFailure?: () => void): void;
  5484. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): void;
  5485. }
  5486. }
  5487. declare module BABYLON {
  5488. class SceneSerializer {
  5489. static Serialize(scene: Scene): any;
  5490. }
  5491. }
  5492. declare module BABYLON {
  5493. class SmartArray<T> {
  5494. data: Array<T>;
  5495. length: number;
  5496. private _id;
  5497. private _duplicateId;
  5498. constructor(capacity: number);
  5499. push(value: any): void;
  5500. pushNoDuplicate(value: any): void;
  5501. sort(compareFn: any): void;
  5502. reset(): void;
  5503. concat(array: any): void;
  5504. concatWithNoDuplicate(array: any): void;
  5505. indexOf(value: any): number;
  5506. private static _GlobalId;
  5507. }
  5508. }
  5509. declare module BABYLON {
  5510. class SmartCollection {
  5511. count: number;
  5512. items: any;
  5513. private _keys;
  5514. private _initialCapacity;
  5515. constructor(capacity?: number);
  5516. add(key: any, item: any): number;
  5517. remove(key: any): number;
  5518. removeItemOfIndex(index: number): number;
  5519. indexOf(key: any): number;
  5520. item(key: any): any;
  5521. getAllKeys(): any[];
  5522. getKeyByIndex(index: number): any;
  5523. getItemByIndex(index: number): any;
  5524. empty(): void;
  5525. forEach(block: (item: any) => void): void;
  5526. }
  5527. }
  5528. declare module BABYLON {
  5529. class Tags {
  5530. static EnableFor(obj: any): void;
  5531. static DisableFor(obj: any): void;
  5532. static HasTags(obj: any): boolean;
  5533. static GetTags(obj: any): any;
  5534. static AddTagsTo(obj: any, tagsString: string): void;
  5535. static _AddTagTo(obj: any, tag: string): void;
  5536. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5537. static _RemoveTagFrom(obj: any, tag: string): void;
  5538. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5539. }
  5540. }
  5541. declare module BABYLON {
  5542. interface IAnimatable {
  5543. animations: Array<Animation>;
  5544. }
  5545. interface ISize {
  5546. width: number;
  5547. height: number;
  5548. }
  5549. class Tools {
  5550. static BaseUrl: string;
  5551. static SetImmediate(action: () => void): void;
  5552. static GetExponantOfTwo: (value: number, max: number) => number;
  5553. static GetFilename(path: string): string;
  5554. static GetDOMTextContent(element: HTMLElement): string;
  5555. static ToDegrees(angle: number): number;
  5556. static ToRadians(angle: number): number;
  5557. static ExtractMinAndMaxIndexed(positions: number[], indices: number[], indexStart: number, indexCount: number): {
  5558. minimum: Vector3;
  5559. maximum: Vector3;
  5560. };
  5561. static ExtractMinAndMax(positions: number[], start: number, count: number): {
  5562. minimum: Vector3;
  5563. maximum: Vector3;
  5564. };
  5565. static MakeArray(obj: any, allowsNullUndefined?: boolean): Array<any>;
  5566. static GetPointerPrefix(): string;
  5567. static QueueNewFrame(func: any): void;
  5568. static RequestFullscreen(element: any): void;
  5569. static ExitFullscreen(): void;
  5570. static CleanUrl(url: string): string;
  5571. static LoadImage(url: string, onload: any, onerror: any, database: any): HTMLImageElement;
  5572. static LoadFile(url: string, callback: (data: any) => void, progressCallBack?: () => void, database?: any, useArrayBuffer?: boolean, onError?: () => void): void;
  5573. static ReadFileAsDataURL(fileToLoad: any, callback: any, progressCallback: any): void;
  5574. static ReadFile(fileToLoad: any, callback: any, progressCallBack: any, useArrayBuffer?: boolean): void;
  5575. static Clamp(value: number, min?: number, max?: number): number;
  5576. static Sign(value: number): number;
  5577. static Format(value: number, decimals?: number): string;
  5578. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  5579. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  5580. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  5581. static IsEmpty(obj: any): boolean;
  5582. static RegisterTopRootEvents(events: {
  5583. name: string;
  5584. handler: EventListener;
  5585. }[]): void;
  5586. static UnregisterTopRootEvents(events: {
  5587. name: string;
  5588. handler: EventListener;
  5589. }[]): void;
  5590. static DumpFramebuffer(width: number, height: number, engine: Engine): void;
  5591. static CreateScreenshot(engine: Engine, camera: Camera, size: any): void;
  5592. static ValidateXHRData(xhr: XMLHttpRequest, dataType?: number): boolean;
  5593. private static _NoneLogLevel;
  5594. private static _MessageLogLevel;
  5595. private static _WarningLogLevel;
  5596. private static _ErrorLogLevel;
  5597. private static _LogCache;
  5598. static OnNewCacheEntry: (entry: string) => void;
  5599. static NoneLogLevel: number;
  5600. static MessageLogLevel: number;
  5601. static WarningLogLevel: number;
  5602. static ErrorLogLevel: number;
  5603. static AllLogLevel: number;
  5604. private static _AddLogEntry(entry);
  5605. private static _FormatMessage(message);
  5606. static Log: (message: string) => void;
  5607. private static _LogDisabled(message);
  5608. private static _LogEnabled(message);
  5609. static Warn: (message: string) => void;
  5610. private static _WarnDisabled(message);
  5611. private static _WarnEnabled(message);
  5612. static Error: (message: string) => void;
  5613. private static _ErrorDisabled(message);
  5614. private static _ErrorEnabled(message);
  5615. static LogCache: string;
  5616. static LogLevels: number;
  5617. private static _PerformanceNoneLogLevel;
  5618. private static _PerformanceUserMarkLogLevel;
  5619. private static _PerformanceConsoleLogLevel;
  5620. private static _performance;
  5621. static PerformanceNoneLogLevel: number;
  5622. static PerformanceUserMarkLogLevel: number;
  5623. static PerformanceConsoleLogLevel: number;
  5624. static PerformanceLogLevel: number;
  5625. static _StartPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  5626. static _EndPerformanceCounterDisabled(counterName: string, condition?: boolean): void;
  5627. static _StartUserMark(counterName: string, condition?: boolean): void;
  5628. static _EndUserMark(counterName: string, condition?: boolean): void;
  5629. static _StartPerformanceConsole(counterName: string, condition?: boolean): void;
  5630. static _EndPerformanceConsole(counterName: string, condition?: boolean): void;
  5631. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  5632. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  5633. static Now: number;
  5634. static GetFps(): number;
  5635. }
  5636. /**
  5637. * An implementation of a loop for asynchronous functions.
  5638. */
  5639. class AsyncLoop {
  5640. iterations: number;
  5641. private _fn;
  5642. private _successCallback;
  5643. index: number;
  5644. private _done;
  5645. /**
  5646. * Constroctor.
  5647. * @param iterations the number of iterations.
  5648. * @param _fn the function to run each iteration
  5649. * @param _successCallback the callback that will be called upon succesful execution
  5650. * @param offset starting offset.
  5651. */
  5652. constructor(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number);
  5653. /**
  5654. * Execute the next iteration. Must be called after the last iteration was finished.
  5655. */
  5656. executeNext(): void;
  5657. /**
  5658. * Break the loop and run the success callback.
  5659. */
  5660. breakLoop(): void;
  5661. /**
  5662. * Helper function
  5663. */
  5664. static Run(iterations: number, _fn: (asyncLoop: AsyncLoop) => void, _successCallback: () => void, offset?: number): AsyncLoop;
  5665. /**
  5666. * A for-loop that will run a given number of iterations synchronous and the rest async.
  5667. * @param iterations total number of iterations
  5668. * @param syncedIterations number of synchronous iterations in each async iteration.
  5669. * @param fn the function to call each iteration.
  5670. * @param callback a success call back that will be called when iterating stops.
  5671. * @param breakFunction a break condition (optional)
  5672. * @param timeout timeout settings for the setTimeout function. default - 0.
  5673. * @constructor
  5674. */
  5675. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): void;
  5676. }
  5677. }
  5678. declare module BABYLON.Internals {
  5679. interface DDSInfo {
  5680. width: number;
  5681. height: number;
  5682. mipmapCount: number;
  5683. isFourCC: boolean;
  5684. isRGB: boolean;
  5685. isLuminance: boolean;
  5686. isCube: boolean;
  5687. }
  5688. class DDSTools {
  5689. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  5690. private static GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5691. private static GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5692. private static GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  5693. static UploadDDSLevels(gl: WebGLRenderingContext, ext: any, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number): void;
  5694. }
  5695. }
  5696. declare module BABYLON.Internals {
  5697. class TGATools {
  5698. private static _TYPE_NO_DATA;
  5699. private static _TYPE_INDEXED;
  5700. private static _TYPE_RGB;
  5701. private static _TYPE_GREY;
  5702. private static _TYPE_RLE_INDEXED;
  5703. private static _TYPE_RLE_RGB;
  5704. private static _TYPE_RLE_GREY;
  5705. private static _ORIGIN_MASK;
  5706. private static _ORIGIN_SHIFT;
  5707. private static _ORIGIN_BL;
  5708. private static _ORIGIN_BR;
  5709. private static _ORIGIN_UL;
  5710. private static _ORIGIN_UR;
  5711. static GetTGAHeader(data: Uint8Array): any;
  5712. static UploadContent(gl: WebGLRenderingContext, data: Uint8Array): void;
  5713. 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;
  5714. 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;
  5715. 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;
  5716. 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;
  5717. 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;
  5718. 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;
  5719. }
  5720. }
  5721. declare module BABYLON {
  5722. enum JoystickAxis {
  5723. X = 0,
  5724. Y = 1,
  5725. Z = 2,
  5726. }
  5727. class VirtualJoystick {
  5728. reverseLeftRight: boolean;
  5729. reverseUpDown: boolean;
  5730. deltaPosition: Vector3;
  5731. pressed: boolean;
  5732. private static _globalJoystickIndex;
  5733. private static vjCanvas;
  5734. private static vjCanvasContext;
  5735. private static vjCanvasWidth;
  5736. private static vjCanvasHeight;
  5737. private static halfWidth;
  5738. private static halfHeight;
  5739. private _action;
  5740. private _axisTargetedByLeftAndRight;
  5741. private _axisTargetedByUpAndDown;
  5742. private _joystickSensibility;
  5743. private _inversedSensibility;
  5744. private _rotationSpeed;
  5745. private _inverseRotationSpeed;
  5746. private _rotateOnAxisRelativeToMesh;
  5747. private _joystickPointerID;
  5748. private _joystickColor;
  5749. private _joystickPointerPos;
  5750. private _joystickPointerStartPos;
  5751. private _deltaJoystickVector;
  5752. private _leftJoystick;
  5753. private _joystickIndex;
  5754. private _touches;
  5755. constructor(leftJoystick?: boolean);
  5756. setJoystickSensibility(newJoystickSensibility: number): void;
  5757. private _onPointerDown(e);
  5758. private _onPointerMove(e);
  5759. private _onPointerUp(e);
  5760. /**
  5761. * Change the color of the virtual joystick
  5762. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  5763. */
  5764. setJoystickColor(newColor: string): void;
  5765. setActionOnTouch(action: () => any): void;
  5766. setAxisForLeftRight(axis: JoystickAxis): void;
  5767. setAxisForUpDown(axis: JoystickAxis): void;
  5768. private _clearCanvas();
  5769. private _drawVirtualJoystick();
  5770. releaseCanvas(): void;
  5771. }
  5772. }