babylon.2.0.d.ts 204 KB

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