babylon.2.1.d.ts 242 KB

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